Skip to content

Commit

Permalink
Correct the output path of rake new_cop. Fixes #160
Browse files Browse the repository at this point in the history
  • Loading branch information
thomthom committed Mar 20, 2023
1 parent 98b84df commit 7f65afa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ task ci: %i[

desc 'Generate a new cop template'
task :new_cop, [:cop] do |_task, args|
require 'rubocop'
require_relative 'lib/rubocop/sketchup/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::SketchUp::Generator.new(cop_name)

generator.write_source
generator.write_spec
Expand Down
21 changes: 21 additions & 0 deletions lib/rubocop/sketchup/generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rubocop'

module RuboCop
module SketchUp
class Generator < RuboCop::Cop::Generator
def source_path
department = snake_case(badge.department.to_s).gsub(/^sketchup_/, '')
File.join(
'lib',
'rubocop',
'sketchup', # We have our cops nested one extra level.
'cop',
department,
"#{snake_case(badge.cop_name.to_s)}.rb"
)
end
end
end
end

0 comments on commit 7f65afa

Please sign in to comment.