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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gemfiles/Gemfile.rubocop-next
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

eval_gemfile "../Gemfile"

gem "rubocop", "~> 1.37.1"
gem "rubocop", ">= 1.38.0"
8 changes: 7 additions & 1 deletion lib/erb_lint/linters/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,17 @@ def tempfile_from(filename, content)
end

def rubocop_processed_source(content, filename)
::RuboCop::ProcessedSource.new(
source = ::RuboCop::ProcessedSource.new(
content,
@rubocop_config.target_ruby_version,
filename
)
if ::RuboCop::Version::STRING.to_f >= 1.38
registry = RuboCop::Cop::Registry.global
source.registry = registry
source.config = @rubocop_config
end
Comment on lines +139 to +143
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

source
end

def cop_classes
Expand Down