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

Make the cop generator to work on rubocop-rspec #5270

Merged
merged 1 commit into from Dec 26, 2017

Conversation

Projects
None yet
2 participants
@pocke
Member

pocke commented Dec 17, 2017

I would like to use the cop generator in rubocop-rspec. However, the task does not work well on the project now.
This change will make the generator to work on rubocop-rspec.

It changes the following things.

  • Make inject_require and inject_config to receive a file name that is a target of injection as a keyword argument.
  • Tweak snake_case method. The method convert "RSpec" to r_spec now. It will be "rspec" by this change.
  • Refactor the generator.
  • Modify the output style of the generator. The new style is similar to rails generator's output.
    • The new style's implementation is easier and simpler than the old style.
    • before
      $ bundle exec rake new_cop[Style/Foo]
      Files created:
        - lib/rubocop/cop/style/foo.rb
        - spec/rubocop/cop/style/foo_spec.rb
      File modified:
        - `require_relative 'rubocop/cop/style/foo'` added into lib/rubocop.rb
        - A configuration for the cop is added into config/enabled.yml
          - If you want to disable the cop by default, move the added config to config/disabled.yml
      
      Do 3 steps:
        1. Add an entry to the "New features" section in CHANGELOG.md,
           e.g. "Add new `Style/Foo` cop. ([@your_id][])"
        2. Modify the description of Style/Foo in config/enabled.yml
        3. Implement your new cop in the generated file!
      
    • after
      $ bundle exec rake new_cop[Style/Foo]
      [create] lib/rubocop/cop/style/foo.rb
      [create] spec/rubocop/cop/style/foo_spec.rb
      [modify] lib/rubocop.rb - `require_relative 'rubocop/cop/style/foo'` was injected.
      [modify] A configuration for the cop is added into config/enabled.yml.
               If you want to disable the cop by default, move the added config to config/disabled.yml
      Do 3 steps:
        1. Add an entry to the "New features" section in CHANGELOG.md,
           e.g. "Add new `Style/Foo` cop. ([@your_id][])"
        2. Modify the description of Style/Foo in config/enabled.yml
        3. Implement your new cop in the generated file!
      

Before submitting the PR make sure the following are checked:

  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.

@pocke pocke changed the title from Make the cop generator to work on rubocop-rspec to [WIP] Make the cop generator to work on rubocop-rspec Dec 17, 2017

@pocke pocke changed the title from [WIP] Make the cop generator to work on rubocop-rspec to Make the cop generator to work on rubocop-rspec Dec 25, 2017

@pocke pocke referenced this pull request Dec 25, 2017

Merged

Add a task to generate a new cop #517

3 of 5 tasks complete
@pocke

This comment has been minimized.

Show comment
Hide comment
@pocke

pocke Dec 25, 2017

Member

I've finished refactoring! And I also opened a pull-request on rubocop-rspec. rubocop-hq/rubocop-rspec#517

Member

pocke commented Dec 25, 2017

I've finished refactoring! And I also opened a pull-request on rubocop-rspec. rubocop-hq/rubocop-rspec#517

@bbatsov bbatsov merged commit b3ef2d2 into rubocop-hq:master Dec 26, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@pocke pocke deleted the pocke:rubocop-rspec-new_cop branch Dec 26, 2017

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