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 a rake task for generation a new cop #3533

Merged
merged 1 commit into from Sep 26, 2016

Conversation

Projects
None yet
4 participants
@pocke
Member

pocke commented Sep 24, 2016

e.g.

$ bundle exec rake new_cop[Lint/UnifiedInteger]
created
- lib/rubocop/cop/lint/unified_integer.rb
- spec/rubocop/cop/lint/unified_integer_spec.rb

Do 4 steps
- Add an entry to `New feature` section in CHANGELOG.md
  - e.g. Add new `Lint/UnifiedInteger` cop. ([@your_id][])
- Add `require 'lib/rubocop/cop/lint/unified_integer'` into lib/rubocop.rb
- Add an entry into config/enabled.yml or config/disabled.yml
- Implement a new cop to the generated file!

The task generates two ruby files.
And it displays next steps.


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).
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
@backus

This comment has been minimized.

Show comment
Hide comment
@backus

backus Sep 24, 2016

Contributor

Would be cool if you could give it an example of offending code. Could potentially setup a node matcher for you and maybe setup your first test.

Contributor

backus commented Sep 24, 2016

Would be cool if you could give it an example of offending code. Could potentially setup a node matcher for you and maybe setup your first test.

@Drenmi

This comment has been minimized.

Show comment
Hide comment
@Drenmi

Drenmi Sep 24, 2016

Collaborator

This is neat. Anything that lowers the barrier to contribution is great, if you ask me. 😀

Collaborator

Drenmi commented Sep 24, 2016

This is neat. Anything that lowers the barrier to contribution is great, if you ask me. 😀

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Sep 24, 2016

Collaborator

This should probably be mentioned in the manual.

Collaborator

bbatsov commented Sep 24, 2016

This should probably be mentioned in the manual.

@pocke

This comment has been minimized.

Show comment
Hide comment
@pocke

pocke Sep 25, 2016

Member

@backus
Thanks for nice suggestion!
I've added some example code to generated files.

@bbatsov
I've added manual/development.md.

Member

pocke commented Sep 25, 2016

@backus
Thanks for nice suggestion!
I've added some example code to generated files.

@bbatsov
I've added manual/development.md.

@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Sep 26, 2016

Collaborator

Th build is failing.

Collaborator

bbatsov commented Sep 26, 2016

Th build is failing.

Add a rake task for generation a new cop
e.g.

```sh
$ bundle exec rake new_cop[Lint/UnifiedInteger]
created
- lib/rubocop/cop/lint/unified_integer.rb
- spec/rubocop/cop/lint/unified_integer_spec.rb

Do 4 steps
- Add an entry to `New feature` section in CHANGELOG.md
  - e.g. Add new `Lint/UnifiedInteger` cop. ([@your_id][])
- Add `require 'lib/rubocop/cop/lint/unified_integer'` into lib/rubocop.rb
- Add an entry into config/enabled.yml or config/disabled.yml
- Implement a new cop to the generated file!
```

The task generates two ruby files.
And it displays next steps.
@pocke

This comment has been minimized.

Show comment
Hide comment
@pocke

pocke Sep 26, 2016

Member

Fixed the build.

Member

pocke commented Sep 26, 2016

Fixed the build.

@bbatsov bbatsov merged commit f8b4b75 into rubocop-hq:master Sep 26, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bbatsov

This comment has been minimized.

Show comment
Hide comment
@bbatsov

bbatsov Sep 26, 2016

Collaborator

Down the road it'd be nice to add a rake task for removing a cop as well. A rake task for generating release notes for the changelog would also be quite handy.

Collaborator

bbatsov commented Sep 26, 2016

Down the road it'd be nice to add a rake task for removing a cop as well. A rake task for generating release notes for the changelog would also be quite handy.

@pocke pocke deleted the pocke:generator-for-new-cop branch Sep 26, 2016

@pocke pocke referenced this pull request Sep 27, 2016

Closed

Improve the manual #3246

mikezter added a commit to mikezter/rubocop that referenced this pull request Sep 28, 2016

Merge remote-tracking branch 'bbatsov/master'
* bbatsov/master: (80 commits)
  [Fix rubocop-hq#3540] Make `Style/GuardClause` register offense for instance & singleton methods
  [Fix rubocop-hq#3436] issue related to Rails/SaveBang when returning non-bang call from the parent method
  Allow `#to_yml` to produce single-quoted strings
  Add support for StyleGuideBaseURL and update rules
  Add spec for the existing style guide URL implementation
  Fix the changelog
  Edited regular expression for normal case to fix issues rubocop-hq#3514 and rubocop-hq#3516 (rubocop-hq#3524)
  Add a rake task for generation a new cop (rubocop-hq#3533)
  [Fix rubocop-hq#3510] Various bug fixes for SafeNavigation (rubocop-hq#3517)
  [Fix rubocop-hq#3512] Change error message of `Lint/UnneededSplatExpansion` for array (rubocop-hq#3526)
  Fix false positive in `Lint/AssignmentInCondition` (rubocop-hq#3520) (rubocop-hq#3529)
  Rename a mismatched filename (rubocop-hq#3523)
  Fix a broken changelog entry
  [Fix rubocop-hq#3511] Style/TernaryParentheses false positive (rubocop-hq#3513)
  Fix the release notes for 0.43
  Cut 0.43.0
  [Fix rubocop-hq#3462] Don't flag single-line methods
  Fix false negatives in `Rails/NotNullColumn` cop (rubocop-hq#3508)
  Remove unused doubled methods (rubocop-hq#3509)
  [Fix rubocop-hq#3485] Make OneLineConditional cop ignore empty else (rubocop-hq#3487)
  ...

Neodelf added a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016

Add a rake task for generation a new cop (rubocop-hq#3533)
e.g.

```sh
$ bundle exec rake new_cop[Lint/UnifiedInteger]
created
- lib/rubocop/cop/lint/unified_integer.rb
- spec/rubocop/cop/lint/unified_integer_spec.rb

Do 4 steps
- Add an entry to `New feature` section in CHANGELOG.md
  - e.g. Add new `Lint/UnifiedInteger` cop. ([@your_id][])
- Add `require 'lib/rubocop/cop/lint/unified_integer'` into lib/rubocop.rb
- Add an entry into config/enabled.yml or config/disabled.yml
- Implement a new cop to the generated file!
```

The task generates two ruby files.
And it displays next steps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment