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 CountAsOne config option to RSpec/ExampleLength #1139

Merged
merged 1 commit into from Apr 14, 2021
Merged

Add CountAsOne config option to RSpec/ExampleLength #1139

merged 1 commit into from Apr 14, 2021

Conversation

stephannv
Copy link
Contributor

@stephannv stephannv commented Apr 13, 2021

To add CountAsOne configuration I had to adapt ExampleLength cop to use CodeLength methods like Metrics/BlockLength, Metrics/MethodLength, Metrics/ClassLength already uses.


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded in default/config.yml to the next minor version.

If you have modified an existing cop's configuration options:

  • Set VersionChanged in config/default.yml to the next major version.

@stephannv stephannv changed the title Add `CountAsconfig option to RSpec/ExampleLength Add CountAsOne config option to RSpec/ExampleLength Apr 13, 2021
@stephannv stephannv changed the title Add CountAsOne config option to RSpec/ExampleLength Add CountAsOne config option to RSpec/ExampleLength Apr 13, 2021
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Looks great, thank you.

@pirj pirj requested review from Darhazer and bquorning April 14, 2021 09:23
Copy link
Member

@Darhazer Darhazer left a comment

Choose a reason for hiding this comment

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

Thank you 🙇

Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

Thank you.

I was missing a link to the CodeLength module when reviewing this, so here it is :-)

@stephannv
Copy link
Contributor Author

stephannv commented Apr 14, 2021

I realized that I forgot to adapt specs to ExampleLength:
It was (copy-pasted from ModuleLength specs):

expect_no_offenses(<<~RUBY)
  module Test 
    ...

I fixed to:

expect_no_offenses(<<~RUBY)
  it do
    ...

Sorry hehe.

@bquorning
Copy link
Collaborator

If you rebase on master, the edge tests should pass on CI.

@stephannv
Copy link
Contributor Author

Done @bquorning. Thanks.

@bquorning bquorning merged commit 098bd42 into rubocop:master Apr 14, 2021
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.

None yet

4 participants