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

Enable Style/Encoding for Ruby >= 2.0 #1304

Closed
yous opened this issue Aug 27, 2014 · 5 comments
Closed

Enable Style/Encoding for Ruby >= 2.0 #1304

yous opened this issue Aug 27, 2014 · 5 comments

Comments

@yous
Copy link
Contributor

yous commented Aug 27, 2014

Though I mainly develop and use RuboCop on Ruby 2.1, I want to force to use # encoding: utf-8 comment on every file for Ruby 1.9 compatibility. But now RuboCop doesn't do anything with Ruby 2.0.

Style/Encoding cop has SupportedStyles as always and when_needed so I thought cop registers an offense for every Ruby version when I set always to EnforcedStyle, for Ruby < 2.0 when I set when_needed to EnforcedStyle. But it doesn't mean it, it was about content of file.

Is there any idea to enable Encoding cop for every Ruby version, like adding a style to SupportedStyles?

@bbatsov
Copy link
Collaborator

bbatsov commented Aug 27, 2014

I agree the current behaviour is less than ideal.

Is there any idea to enable Encoding cop for every Ruby version, like adding a style to SupportedStyles?

Perhaps. Alternative we can just remove the Ruby 2.0 check and make the cop disabled by default, which sounds like a better idea to me.

@yujinakayama @jonas054 Thoughts?

@jonas054
Copy link
Collaborator

I would suggest adding a new configuration parameter:

Style/Encoding:
  # If false, checks are only made when running under Ruby 1.9.
  ForAllRubyVersions: false

Disabling the cop doesn't really solve this issue, and adding a SupportedStyle gets complicated as ruby version and file contents can vary independently and we need to support combinations.

@bbatsov
Copy link
Collaborator

bbatsov commented Aug 29, 2014

Unless a project supports 1.9, running the cop makes zero sense. If a project supports 1.9 than the existing configs - when_needed and always are quite sufficient. Seems to me we'll be complicating this more than it's needed with an extra config option.

@yujinakayama
Copy link
Collaborator

Alternative we can just remove the Ruby 2.0 check and make the cop disabled by default, which sounds like a better idea to me.

I agree.

I've also been thinking the current Encoding cop behavior is odd. If a team declared that encoding comments are always required in a project, it should be always checked regardless of each local runtime environment since it's a project-specific thing (like RuboCop project itself).

Also, we've forgotten to add encoding comments several times carelessly, but it's something we want to automate with RuboCop.

By the way, though I have no strong opinion on whether it should be enabled by default or not, the maintenance support for Ruby 1.9.3 will end on Feb 23, 2015.

@jonas054
Copy link
Collaborator

@bbatsov When you said "remove the Ruby 2.0 check", I read it as "remove the check when running Ruby 2.0". So forget what I said. I agree with what you actually said.

@bbatsov bbatsov closed this as completed in 89e5be3 Sep 3, 2014
yous added a commit to yous/dotfiles that referenced this issue Sep 4, 2014
`Style/Encoding` cop is disabled by default from RuboCop v0.26.0. See
rubocop/rubocop#1304.
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

4 participants