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

Style/Encoding AutoCorrect with EnforcedStyle: when_needed goes into an infinite loop #2631

Closed
hesalx opened this issue Jan 13, 2016 · 2 comments

Comments

@hesalx
Copy link

hesalx commented Jan 13, 2016

rubocop version: master at 9732d37
0.35.1 (using Parser 2.3.0.pre.6, running on ruby 2.3.0 x86_64-linux)

.rubocop.yml:

AllCops:
  TargetRubyVersion: 2.3

Style/Encoding:
  Enabled: true
  EnforcedStyle: when_needed

My actions:

$ bundle exec rubocop 
file.rb:1:1: C: Unnecessary utf-8 encoding comment.
# encoding: utf-8
^
$ bundle exec rubocop --auto-correct

Expected behaviour: line # encoding: utf-8 is deleted from all files.
Actual behaviour: infinite addition of # encoding: utf-8 lines to the first encountered file.

@hesalx
Copy link
Author

hesalx commented Jan 13, 2016

Just a little thought: for TargetRubyVersion >= 2.0 this cop should always report encoding comment as unnecessary regardless of EnforcedStyle.

@pasha
Copy link

pasha commented Feb 12, 2016

Having similar issue.
using latest version 0.37.2
ruby 2.2.3p173

Style/Encoding:
  Description: 'Use UTF-8 as the source file encoding.'
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
  EnforcedStyle: when_needed
  Enabled: true

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

2 participants