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

Allow Style/Encoding to enforce using no encoding comment #3092

Merged
merged 1 commit into from
Apr 30, 2016

Conversation

NobodysNightmare
Copy link
Contributor

@NobodysNightmare NobodysNightmare commented Apr 29, 2016

Whats in

You can now configure rubocop to enforce having no encoding comments:

Style/Encoding:
  EnforcedStyle: never
  Enabled: true

This means even if there are non-ASCII characters in a file, rubocop will offend on an # encoding: utf-8 comment.
I deem this useful for applications that are running on a recent ruby version and therefore do not need the comment anymore. Since many applications used to be running on 1.9, they may still contain those comments, even if they are unneccessary.

@@ -425,10 +425,11 @@ Style/EmptyLinesAroundModuleBody:
# AutoCorrectEncodingComment must match the regex
# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
Style/Encoding:
EnforcedStyle: always
EnforcedStyle: never
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this cop is disabled by default, I assume that the default is that we live in a"post 1.9" world.
Therefore I thought never would be the more apropriate default.

However, this will cause offenses on existing configurations, when you just enabled this cop, without specifying an enforced style, e.g.:

Style/Encoding:
  Enabled: true

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. We can re-enable it once we drop support for 1.9.

Usable for applications that moved from <= 1.9 to >= 2.0,
since autocorrection can now remove those comments again.
@bbatsov bbatsov merged commit 4d5176e into rubocop:master Apr 30, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016
Usable for applications that moved from <= 1.9 to >= 2.0,
since autocorrection can now remove those comments again.
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

Successfully merging this pull request may close these issues.

2 participants