Skip to content

Commit

Permalink
bugfix: Remove wacky broken conditional in AbcCheck.
Browse files Browse the repository at this point in the history
Fixes square#33.
  • Loading branch information
xaviershay committed Sep 1, 2012
1 parent 1c7376c commit 5859a31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cane/abc_check.rb
Expand Up @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion spec/abc_check_spec.rb
Expand Up @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 5859a31

Please sign in to comment.