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

automatic fix unexpectedly modifying the file #948

Closed
fabiopelosin opened this issue Apr 3, 2014 · 3 comments
Closed

automatic fix unexpectedly modifying the file #948

fabiopelosin opened this issue Apr 3, 2014 · 3 comments
Assignees
Labels

Comments

@fabiopelosin
Copy link
Contributor

I'm shaping up some specs files and I have disabled all the cops which where detecting an infraction:

$ rubocop spec/specification_spec.rb
Inspecting 1 file
.

1 file inspected, no offences detected

I would then expect that the automatic fix would not modify the file, instead it does:

$ rubocop spec/specification_spec.rb -a
Inspecting 1 file
E

Offenses:

spec/specification_spec.rb:98:34: W: ambiguous first argument; parenthesize arguments or add whitespace to the right
        end.message.should.match /Invalid string representation/
                                 ^
spec/specification_spec.rb:235:31: E: unexpected token tLCURLY
          s.subspec 'Subspec' { |sp| }
                              ^
spec/specification_spec.rb:404:34: W: ambiguous first argument; parenthesize arguments or add whitespace to the right
        end.message.should.match /No podspec exists/
                                 ^
spec/specification_spec.rb:412:34: W: ambiguous first argument; parenthesize arguments or add whitespace to the right
        end.message.should.match /Unsupported specification format/
                                 ^
spec/specification_spec.rb:439:31: E: unexpected token tLCURLY
          s.subspec 'Subspec' { |sp| }
                              ^
spec/specification_spec.rb:443:34: W: ambiguous first argument; parenthesize arguments or add whitespace to the right
        end.message.should.match /can be set only for root specs/
                                 ^
spec/specification_spec.rb:451:1: E: unexpected token $end

1 file inspected, 7 offences detected

An example of the diff:

         @spec = Spec.new do |s|
           s.name = "Pod"
           s.version = "1.0"
-          s.subspec 'Subspec' do |sp| end
+          s.subspec 'Subspec' { |sp| }
         end
         @subspec = @spec.subspecs.first
       end

I understand that this is not elegant Ruby and that the original file should be changed, but still is valid Ruby and rubocop should not break it (hence why I'm reporting the issue).

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 4, 2014

Yep, we'll fix this. @jonas054 has been fixing all sorts of similar problems lately. Unfortunately auto-correction is not easy by a long shot. :-)

@fabiopelosin
Copy link
Contributor Author

Unfortunately auto-correction is not easy by a long shot. :-)

I guess it... but it is such an amazing feature!

@fabiopelosin
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

3 participants