From 5859a310365ca9af7f5c35be64dd34f7375fab20 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Sat, 1 Sep 2012 11:10:37 +1000 Subject: [PATCH] bugfix: Remove wacky broken conditional in AbcCheck. Fixes #33. --- lib/cane/abc_check.rb | 2 +- spec/abc_check_spec.rb | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/cane/abc_check.rb b/lib/cane/abc_check.rb index d70fa3f..c448958 100644 --- a/lib/cane/abc_check.rb +++ b/lib/cane/abc_check.rb @@ -33,7 +33,7 @@ def self.options end def violations - return [] if opts[:no_abc] == false + return [] if opts[:no_abc] order worker.map(file_names) {|file_name| find_violations(file_name) diff --git a/spec/abc_check_spec.rb b/spec/abc_check_spec.rb index 3faccb5..c1cebea 100644 --- a/spec/abc_check_spec.rb +++ b/spec/abc_check_spec.rb @@ -7,6 +7,20 @@ def check(file_name, opts = {}) described_class.new(opts.merge(abc_glob: file_name)) end + it 'does not create violations when no_abc flag is set' do + file_name = make_file(<<-RUBY) + class Harness + def complex_method(a) + b = a + return b if b > 3 + end + end + RUBY + + violations = check(file_name, abc_max: 1, no_abc: true).violations + violations.should be_empty + end + it 'creates an AbcMaxViolation for each method above the threshold' do file_name = make_file(<<-RUBY) class Harness @@ -21,7 +35,7 @@ def complex_method(a) end RUBY - violations = check(file_name, abc_max: 1).violations + violations = check(file_name, abc_max: 1, no_abc: false).violations violations.length.should == 1 violations[0].values_at(:file, :label, :value).should == [file_name, "Harness#complex_method", 2]