Skip to content

Commit dad11fc

Browse files
committed
Change step with new_cop command for rubocop-rspec
before: ``` Do 4 steps: 1. Modify the description of RSpec/CopName in config/default.yml 2. Implement your new cop in the generated file! 3. Commit your new cop with a message such as e.g. "Add new `RSpec/CopName` cop" 4. Run `bundle exec rake changelog:new` to generate a changelog entry ``` after: ``` Do 4 steps: 1. Modify the description of RSpec/CopName in config/default.yml 2. Implement your new cop in the generated file! 3. Add an entry about new cop to CHANGELOG.md 4. Commit your new cop with a message such as e.g. "Add new `RSpec/CopName` cop" ```
1 parent 6323fe9 commit dad11fc

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ task default: %i[build_config spec
9090
desc 'Generate a new cop template'
9191
task :new_cop, [:cop] do |_task, args|
9292
require 'rubocop'
93+
require_relative 'lib/rubocop/rspec/cop/generator'
9394

9495
cop_name = args.fetch(:cop) do
9596
warn "usage: bundle exec rake 'new_cop[Department/Name]'"
9697
exit!
9798
end
9899

99-
generator = RuboCop::Cop::Generator.new(cop_name)
100+
generator = RuboCop::RSpec::Cop::Generator.new(cop_name)
100101
generator.write_source
101102
generator.write_spec
102103
generator.inject_require(root_file_path: 'lib/rubocop/cop/rspec_cops.rb')

lib/rubocop/rspec/cop/generator.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module RuboCop
4+
module RSpec
5+
module Cop
6+
# Source and spec generator for new cops
7+
#
8+
# This generator will take a cop name and generate a source file
9+
# and spec file when given a valid qualified cop name.
10+
# @api private
11+
class Generator < RuboCop::Cop::Generator
12+
def todo
13+
<<~TODO
14+
Do 4 steps:
15+
1. Modify the description of #{badge} in config/default.yml
16+
2. Implement your new cop in the generated file!
17+
3. Add an entry about new cop to CHANGELOG.md
18+
4. Commit your new cop with a message such as
19+
e.g. "Add new `#{badge}` cop"
20+
TODO
21+
end
22+
end
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)