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

Update RuboCop configuration to inherit from theforeman-rubocop #886

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

archanaserver
Copy link
Contributor

  • Added theforeman-rubocop as a development dependency in the gemspec.
  • Changed the RuboCop configuration to inherit from default.yml provided
    by theforeman-rubocop for better style alignment.
  • Removed redundant cops as they are already included in the inherited
    default.yml or not needed anymore.

default.yml: https://github.com/theforeman/theforeman-rubocop/?tab=readme-ov-file#basic-style---default-performance-and-rails-cops

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

Copy link

@qcjames53 qcjames53 left a comment

Choose a reason for hiding this comment

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

Hi Archana!

I'm sorry it took me so long to review this PR, I wanted to triple check everything in the config file since this will end up being pretty important for devs and QE. I had a few questions and suggestions there but all in all everything looks great.

I expanded on this below but I don't think we can call .update on an ActiveRecord::Relation. It's not in any documentation I could find. I asked ChatGPT if the changes were ok and it said NO 3 times and YES once 🤷‍♂️. I'd put everything in a .each loop if validations are important and would keep the lines as .update_all if not.

.rubocop.yml Outdated Show resolved Hide resolved
.rubocop.yml Show resolved Hide resolved
lib/insights_cloud/async/insights_client_status_aging.rb Outdated Show resolved Hide resolved
lib/insights_cloud/async/insights_full_sync.rb Outdated Show resolved Hide resolved
test/unit/foreman_rh_cloud_self_host_test.rb Outdated Show resolved Hide resolved
@archanaserver
Copy link
Contributor Author

I expanded on this below but I don't think we can call .update on an ActiveRecord::Relation.

Yes you are right, I had similar conversation few weeks back in one of my another PR on update and update_all, I misunderstood few things here in the code, but I was following the RuboCop doc: https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsskipsmodelvalidations So I did this to few other places as well that is disabling this cop because it is not safe to use.

- Added theforeman-rubocop as a development dependency in the gemspec.
- Changed the RuboCop configuration to inherit from default.yml provided
by theforeman-rubocop for better style alignment.
- Removed redundant cops as they are already included in the inherited
default.yml or not needed anymore.
Copy link

@qcjames53 qcjames53 left a comment

Choose a reason for hiding this comment

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

The changes look great to me, thank you! I'm totally ok with keeping update_all instead of refactoring into an each loop; I can see several ways that could end up a big headache. I just had one question about the included styles (posted elsewhere) but I'm happy to ACK once that is resolved.

Copy link
Contributor Author

@archanaserver archanaserver left a comment

Choose a reason for hiding this comment

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

Dropping those cops from here because we already have it in theforeman-rubocop.

.rubocop.yml Show resolved Hide resolved
Copy link
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

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

Thanks @archanaserver for your contribution and @qcjames53 for reviewing this, looks good from my end too.

@chris1984 chris1984 merged commit e939a23 into theforeman:v10 Jul 17, 2024
18 checks passed
@archanaserver
Copy link
Contributor Author

Thanks @chris1984 and @qcjames53 :)

@archanaserver archanaserver deleted the rubocop branch July 17, 2024 17:36
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