From 46b43d79463a7ed03dffcf50114fa3ba57d20624 Mon Sep 17 00:00:00 2001 From: Obfuscoder Date: Fri, 5 Feb 2016 21:27:05 +0100 Subject: [PATCH] Require reek with version 3.0.0 or later Close #272 --- Gemfile | 2 -- lib/metric_fu/metrics/reek/generator.rb | 6 +++--- metric_fu.gemspec | 2 +- spec/metric_fu/metrics/reek/generator_spec.rb | 9 ++++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index e56c8580a..960c2e327 100644 --- a/Gemfile +++ b/Gemfile @@ -4,8 +4,6 @@ source "https://rubygems.org" if RUBY_VERSION == "1.9.2" # because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec gem "activesupport", "~> 3.2" - # because of https://github.com/troessner/reek/issues/334 - gem "reek", "~> 1.4.0" # rbp -> as -> i18n gem 'i18n', '0.6.11' gem "parallel", "= 1.3.3" # 1.3.4 disallows 1.9.2 diff --git a/lib/metric_fu/metrics/reek/generator.rb b/lib/metric_fu/metrics/reek/generator.rb index 61d931ff9..cfdf4c720 100644 --- a/lib/metric_fu/metrics/reek/generator.rb +++ b/lib/metric_fu/metrics/reek/generator.rb @@ -14,12 +14,12 @@ def emit end end - def run!(files, config_files) - examiner.new(files, config_files) + def run!(files, _config_files) + files.map { |file| examiner.new(Pathname.new(file), []) } end def analyze - @matches = @output.smells.group_by(&:source).collect do |file_path, smells| + @matches = @output.map(&:smells).flatten.group_by(&:source).collect do |file_path, smells| { file_path: file_path, code_smells: analyze_smells(smells) } end diff --git a/metric_fu.gemspec b/metric_fu.gemspec index e7e160951..1855560fb 100644 --- a/metric_fu.gemspec +++ b/metric_fu.gemspec @@ -45,7 +45,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency "flay", [">= 2.0.1", "~> 2.1"] s.add_runtime_dependency "churn", ["~> 0.0.35"] s.add_runtime_dependency "flog", [">= 4.1.1", "~> 4.1"] - s.add_runtime_dependency "reek", [">= 1.3.4", "< 3.0"] + s.add_runtime_dependency "reek", [">= 3.0.0"] s.add_runtime_dependency "cane", [">= 2.5.2", "~> 2.5"] s.add_runtime_dependency "rails_best_practices", [">= 1.14.3", "~> 1.14"] s.add_runtime_dependency "metric_fu-Saikuro", [">= 1.1.3", "~> 1.1"] diff --git a/spec/metric_fu/metrics/reek/generator_spec.rb b/spec/metric_fu/metrics/reek/generator_spec.rb index c95b8fb0b..467e672a8 100644 --- a/spec/metric_fu/metrics/reek/generator_spec.rb +++ b/spec/metric_fu/metrics/reek/generator_spec.rb @@ -100,7 +100,8 @@ lines: [6, 9]) ] @lines = instance_double(@examiner, smells: @smells) - @reek.instance_variable_set(:@output, @lines) + @output = [@lines] + @reek.instance_variable_set(:@output, @output) @matches = @reek.analyze end @@ -144,7 +145,8 @@ lines: [2, 4]), ] @lines = instance_double(@examiner, smells: @smells) - @reek.instance_variable_set(:@output, @lines) + @output = [@lines] + @reek.instance_variable_set(:@output, @output) @matches = @reek.analyze end @@ -157,7 +159,8 @@ context "without reek warnings" do before :each do @lines = instance_double(@examiner, smells: []) - @reek.instance_variable_set(:@output, @lines) + @output = [@lines] + @reek.instance_variable_set(:@output, @output) @matches = @reek.analyze end