Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocorrection for Lint/UnusedMethodArgument should update Sorbet sig #11021

Open
dduugg opened this issue Sep 27, 2022 · 1 comment
Open

Autocorrection for Lint/UnusedMethodArgument should update Sorbet sig #11021

dduugg opened this issue Sep 27, 2022 · 1 comment

Comments

@dduugg
Copy link
Contributor

dduugg commented Sep 27, 2022


Expected behavior

Per #11020 (comment) the autocorrect for Lint/UnusedMethodArgument should update the Sorbet type signature, e.g.

sig { params(x: Integer).void }
def foo(x); end

should autocorrect to:

sig { params(_x: Integer).void }
def foo(_x); end

(Alternatively, the cop could be marked SafeAutoCorrect: false, which was attempted in #11020 )

Actual behavior

The parameter is renamed under autocorrection, but not the type signature:

sig { params(x: Integer).void }
def foo(_x); end

This code will fail to typecheck, as well as resulting in a RuntimeError on method invocation.

Steps to reproduce the problem

run rubocop -a on this snippet:

sig { params(x: Integer).void }
def foo(x); end

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ bundle exec rubocop -V
1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.1) [x86_64-darwin21]
@dduugg
Copy link
Contributor Author

dduugg commented Sep 27, 2022

On further consideration, the autocorrect would still break rbi/rbs files, and I'm not sure rubocop supports the necessary correction across files (and file tops). I think the cop still needs to be marked SafeAutoCorrect: false. What do you think, @koic ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant