diff --git a/Rakefile b/Rakefile index d4c34f1..49351c9 100644 --- a/Rakefile +++ b/Rakefile @@ -88,13 +88,14 @@ task default: %i[build_config spec desc 'Generate a new cop template' task :new_cop, [:cop] do |_task, args| require 'rubocop' + require_relative 'lib/rubocop/rspec_rails/cop/generator' cop_name = args.fetch(:cop) do warn "usage: bundle exec rake 'new_cop[Department/Name]'" exit! end - generator = RuboCop::Cop::Generator.new(cop_name) + generator = RuboCop::RSpecRails::Cop::Generator.new(cop_name) generator.write_source generator.write_spec generator.inject_require( diff --git a/lib/rubocop/rspec_rails/cop/generator.rb b/lib/rubocop/rspec_rails/cop/generator.rb new file mode 100644 index 0000000..ca8ce76 --- /dev/null +++ b/lib/rubocop/rspec_rails/cop/generator.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module RuboCop + module RSpecRails + module Cop + # Source and spec generator for new cops + # + # This generator will take a cop name and generate a source file + # and spec file when given a valid qualified cop name. + # @api private + class Generator < RuboCop::Cop::Generator + def todo + <<~TODO + Do 4 steps: + 1. Modify the description of #{badge} 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 `#{badge}` cop" + TODO + end + end + end + end +end