diff --git a/config/cops.yml b/config/cops.yml new file mode 100644 index 00000000..c712267e --- /dev/null +++ b/config/cops.yml @@ -0,0 +1 @@ +Metrics/ClassLength: 400_000 diff --git a/lib/cc/engine/rubocop.rb b/lib/cc/engine/rubocop.rb index 0e9d82b6..ad4f7864 100644 --- a/lib/cc/engine/rubocop.rb +++ b/lib/cc/engine/rubocop.rb @@ -11,6 +11,8 @@ module CC module Engine class Rubocop + DEFAULT_REMEDIATION_POINTS = 200_000 + def initialize(code, engine_config, io) @code = code @engine_config = engine_config || {} @@ -101,7 +103,7 @@ def violation_json(violation, local_path) check_name: "Rubocop/#{violation.cop_name}", description: violation.message, categories: [category(violation.cop_name)], - remediation_points: 50_000, + remediation_points: remediation_points_for(violation.cop_name), location: { path: local_path, positions: violation_positions(violation.location), @@ -128,6 +130,22 @@ def cops RuboCop::Cop::Cop.non_rails end end + + def remediation_points_for(cop_name) + cop_list.fetch(cop_name, DEFAULT_REMEDIATION_POINTS) + end + + def cop_list + return @cop_list if @cop_list + + cops_path = File.expand_path( + File.join(File.dirname(__FILE__), "../../../config/cops.yml") + ) + + File.open(cops_path, "r") do |file| + @cop_list = YAML.load(file.read) + end + end end end end