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

Add Style/OpenStructUse Cop #10217

Merged
merged 1 commit into from Nov 3, 2021
Merged

Conversation

mttkay
Copy link
Contributor

@mttkay mttkay commented Oct 27, 2021

This flags any use of the OpenStruct type, whose use is now officially discouraged.

Originally written as part of https://gitlab.com/gitlab-org/gitlab-styles/-/merge_requests/92.

This PR addresses existing OpenStruct offenses in RuboCop itself as well.

Fixes #10206


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@mttkay
Copy link
Contributor Author

mttkay commented Oct 27, 2021

Tests are failing because RuboCop uses OpenStruct 😬 Where's the dreidel emoji.

@dvandersluis
Copy link
Member

Can you add a test that no offense is registered for MyNamespace::OpenStruct.new?

spec/spec_helper.rb Outdated Show resolved Hide resolved
config/default.yml Outdated Show resolved Hide resolved
@mttkay
Copy link
Contributor Author

mttkay commented Oct 29, 2021

Thanks for all the thorough feedback @dvandersluis ; before I get into cleaning up the commit history, would you mind having a final pass over the changes?

Copy link
Member

@dvandersluis dvandersluis left a comment

Choose a reason for hiding this comment

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

@mttkay this is looking great! I added one last comment but this is basically good to go once squashed. Thanks for your work! ❤️

This flags any use of the OpenStruct type,
whose use is now officially discouraged.
@mttkay mttkay changed the title [DRAFT] Add Style/OpenStructUse Cop Add Style/OpenStructUse Cop Nov 1, 2021
@mttkay
Copy link
Contributor Author

mttkay commented Nov 1, 2021

Thanks for all the help @dvandersluis -- I believe this is ready for a final review. I added a changelog entry and squashed commits.

I noticed that the spellcheck jobs require additional approval?

This workflow is awaiting approval from a maintainer in #10217

@dvandersluis
Copy link
Member

dvandersluis commented Nov 1, 2021

Thank you again for your work on this! It's looking ready to go for me now.

I noticed that the spellcheck jobs require additional approval?

Github actions runs have to be approved for first time contributors, it's running now.

@dvandersluis dvandersluis merged commit f1e7209 into rubocop:master Nov 3, 2021
koic added a commit that referenced this pull request Nov 8, 2023
Follow up #10217.

This commit removes useless `require 'ostruct'`.
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.

Consider flagging all uses of OpenStruct
2 participants