Skip to content

Commit

Permalink
Merge pull request #16 from jonas054/bugfix2
Browse files Browse the repository at this point in the history
The first argument to Cop#add_offence shall be "severity".
  • Loading branch information
bbatsov committed Jan 16, 2013
2 parents cb21e14 + 276bcac commit aab4f65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/cop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def has_report?
!@offences.empty?
end

def add_offence(file, line_number, message)
def add_offence(severity, line_number, message)
if self.class.enabled != false
@offences << Offence.new(file, line_number, message)
@offences << Offence.new(severity, line_number, message)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cops/align_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ module Cop

it 'can handle a correctly aligned string literal as first argument' do
inspect_source(align, '',
['add_offence("", x,',
['add_offence(:convention, x,',
' a)'])
align.offences.map(&:message).should == []
end

it 'can handle a string literal as other argument' do
inspect_source(align, '',
['add_offence(x,',
['add_offence(:convention,',
' "", a)'])
align.offences.map(&:message).should == []
end
Expand Down
4 changes: 2 additions & 2 deletions spec/rubocop/cops/cop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ module Cop
end

it 'keeps track of offences' do
cop.add_offence('file', 1, 'message')
cop.add_offence(:convention, 1, 'message')

cop.offences.size.should == 1
end

it 'will report registered offences' do
cop.add_offence('file', 1, 'message')
cop.add_offence(:convention, 1, 'message')

cop.has_report?.should be_true
end
Expand Down

0 comments on commit aab4f65

Please sign in to comment.