rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Fix Metrics/ClassLength violation

Open bquorning opened this issue 5 years ago • 1 comments

Our TODO file mentioned that the DescribedClass class was too long. Looking closer at it, I found a couple of methods (#full_const_name, #collapse_namespace, #const_name, and #namespace) working on the isolated problem of determining the “full constant name”, of a const node. This PR extracts those methods into a separate FullConstNameFinder module.

The code that I move was introduced in one single commit, bdc8723c65a0521e6df3e0b481592d19fdc000ca, and I wonder if @pirj wouldn’t like to help me with this here PR? 😄

TODO

  • [ ] Code documentation.
  • [ ] Add tests specifically for the extracted module.
  • [ ] Consider extracting the code into a separate file so it can be re-used elsewhere.

Before submitting the PR make sure the following are checked:

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

bquorning avatar Jul 31 '20 07:07 bquorning

[ ] Code documentation

Looks pretty good already.

[ ] Add tests specifically for the extracted module

We don't have much tests for modules, we rely on cops' tests to cover module's behavior, so we're good here from my point of view.

[ ] Consider extracting the code into a separate file so it can be re-used elsewhere

Did you have some other cops in mind that could use this? I can't think of any.

pirj avatar Aug 02 '20 14:08 pirj