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

Fix rake new_cop problem that doesn't add require line #4722

Merged
merged 2 commits into from
Sep 12, 2017

Conversation

koic
Copy link
Member

@koic koic commented Sep 11, 2017

This PR fixes the following problem of rake new_cop.

For example use rake new_cop to add a new Style/TheEndOfStyle cop.

Expected Behaviour

The following two files are generated.

Files created:
  - lib/rubocop/cop/style/the_end_of_style.rb
  - spec/rubocop/cop/style/the_end_of_style_spec.rb

And a new require line is added to lib/rubocop.rb.

(snip)

require 'rubocop/cop/style/file_name'
require 'rubocop/cop/style/flip_flop'
require 'rubocop/cop/style/the_end_of_style' # New line

require 'rubocop/cop/rails/action_filter'

Actual Behaviour

A new requrie line is not added to lib/rubocop.rb.

(snip)

require 'rubocop/cop/style/file_name'
require 'rubocop/cop/style/flip_flop'

require 'rubocop/cop/rails/action_filter'

This is because there was a problem when adding to the end of existing department.


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(rake spec) are passing.
  • The new code doesn't generate RuboCop offenses that are checked by rake internal_investigation.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Updated cop documentation with rake generate_cops_documentation (required only when you've added a new cop or changed the configuration/documentation of an existing cop).

@@ -194,6 +194,65 @@ def on_send(node)
end
end

context 'when a cops of style department already exists' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

a cop

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops! I fixed it 💦

@bbatsov bbatsov merged commit eb42226 into rubocop:master Sep 12, 2017
@koic koic deleted the fix_new_cop_generator branch September 12, 2017 08:12
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.

2 participants