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

Use theforeman-rubocop gem #750

Merged
merged 1 commit into from
May 7, 2024
Merged

Conversation

archanaserver
Copy link
Contributor

Choose to inherit some cops only, because i wanted to inherit rules from style_lenient.yml as well, i followed this:
https://github.com/theforeman/theforeman-rubocop?tab=readme-ov-file#choose-just-some-cops

Also drop some cops from the .rubocop.yml config, because that was present in inherit-gem and clean gemfile by adding theforeman-rubocop gem.

This is part of Rubocop standerdization, link for the reference: https://community.theforeman.org/t/standardizing-rubocop-with-theforeman-rubocop/37239

.rubocop.yml Outdated
Comment on lines 5 to 12
- rules/base.yml
- rules/ruby_target.yml
- rules/style.yml
- rules/metrics.yml
- rules/performance.yml
- rules/rails.yml
- rules/minitest.yml
- rules/style_lenient.yml
Copy link
Member

Choose a reason for hiding this comment

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

This enables almost all the same rules and doesn't cause additional violations. It's also easier to use a single file than to pick individual rulesets.

Suggested change
- rules/base.yml
- rules/ruby_target.yml
- rules/style.yml
- rules/metrics.yml
- rules/performance.yml
- rules/rails.yml
- rules/minitest.yml
- rules/style_lenient.yml
- lenient.yml

.rubocop.yml Outdated
- 'node_modules/**/*'
- 'locale/*'
- 'vendor/**/*'
TargetRubyVersion: 2.7
Copy link
Member

Choose a reason for hiding this comment

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

This is still needed because it uses Ruby 2.7+ syntax.

Comment on lines 81 to 85
# Offense count: 2
# Cop supports --auto-correct.
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/foreman_tasks/tasks/export_tasks.rake'
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the rubocop control statements instead

.rubocop.yml Outdated
Exclude:
- 'node_modules/**/*'
- 'locale/*'
- 'vendor/**/*'
Copy link
Member

Choose a reason for hiding this comment

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

If you keep Exclude, you must include this. It's causing the CI failures. And node_modules is probably just for performance, because it's scanning a lot of files that aren't needed.

That said, rules/base.yml already has a good definition in rules/base so I'd leave the whole Exclude out. If locale is a problem, I wonder why it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to keep it as it was previously because of this failure:

app/models/foreman_tasks/concerns/action_triggering.rb:30:17: E: Lint/Syntax: unexpected token tDOT3
(Using Ruby 2.5 parser; configure using TargetRubyVersion parameter, under AllCops)
      def save!(...)

and added few cops offense count in the rubocop todo file.

Choose to inherit some cops only, because i wanted to inherit rules from
style_lenient.yml as well, i followed this:
https://github.com/theforeman/theforeman-rubocop?tab=readme-ov-file#choose-just-some-cops

Also drop some cops from the .rubocop.yml config, because that was present
in inherit-gem and clean gemfile by adding theforeman-rubocop gem.

This is part of Rubocop standerdization, link for the reference:
https://community.theforeman.org/t/standardizing-rubocop-with-theforeman-rubocop/37239
@adamruzicka adamruzicka merged commit 124e9c6 into theforeman:master May 7, 2024
20 of 21 checks passed
@adamruzicka
Copy link
Contributor

Thank you @archanaserver !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants