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

Support RuboCop 1.38 #288

Merged
merged 2 commits into from
Nov 10, 2022
Merged

Support RuboCop 1.38 #288

merged 2 commits into from
Nov 10, 2022

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Nov 9, 2022

This fixes #286.

  • Bump and loosen rubocop version in rubocop-next bundle
  • Make RuboCop linter work with RuboCop 1.38

This version of RuboCop needs registry and config attributes to be set
on the ProcessedSource object. These attributes do not exist in earlier
versions of RuboCop.
@mvz
Copy link
Contributor Author

mvz commented Nov 9, 2022

Perhaps another Gemfile needs to be added in gemfiles/ to test with RubuCop 1.x before version 1.38.

Comment on lines +139 to +143
if ::RuboCop::Version::STRING.to_f >= 1.38
registry = RuboCop::Cop::Registry.global
source.registry = registry
source.config = @rubocop_config
end
Copy link
Member

Choose a reason for hiding this comment

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

Can we do the check on feature rather than version?

Suggested change
if ::RuboCop::Version::STRING.to_f >= 1.38
registry = RuboCop::Cop::Registry.global
source.registry = registry
source.config = @rubocop_config
end
source.registry = RuboCop::Cop::Registry.global if source.respond_to?(:registry=)
source.config = @rubocop_config if source.respond_to?(:config=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, the two things go together so it doesn't seem sensible to have two conditions.

Also, there is already a version check in that file: https://github.com/Shopify/erb-lint/blob/9b7dec10f51cd5e505347aded25d4d7e1aec94c4/lib/erb_lint/linters/rubocop.rb#L39, so it seems consistent to handle this the same way.

Finally, if ever in the distant future erb-lint supports only RuboCop 1.38 and above, it will be easier to see that the condition can be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough

@etiennebarrie etiennebarrie merged commit e152faf into Shopify:main Nov 10, 2022
@mvz mvz deleted the support-rubocop-1-38 branch November 10, 2022 10:36
@shopify-shipit shopify-shipit bot temporarily deployed to production November 10, 2022 12:11 Inactive
@mvz
Copy link
Contributor Author

mvz commented Nov 10, 2022

Thanks, @etiennebarrie!

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.

Rubocop issue with 0.3.0
2 participants