Class: CheckstyleOutputToken

Inherits:
Object
  • Object
show all
Defined in:
lib/checkstyle_output_token.rb

Overview

Data bag to capture fields used to generate suppressions from an offending checkstyle output line

Constant Summary collapse

OFFENSE_CONVERSION =
{
  'noTrailingWhitespace' => 'RegexpSinglelineCheck',
  'noConsecutiveLines' => 'RegexpMultilineCheck',
  'commentFirstSentenceMultiline' => 'RegexpMultilineCheck',
  'commentFirstSentenceSingleline' => 'RegexpSinglelineCheck'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_data) ⇒ CheckstyleOutputToken

Returns a new instance of CheckstyleOutputToken.



14
15
16
17
18
# File 'lib/checkstyle_output_token.rb', line 14

def initialize(token_data)
  @severity = token_data[1]
  @file_name = token_data[2]
  @offense = OFFENSE_CONVERSION[token_data[3]] || token_data[3]
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



5
6
7
# File 'lib/checkstyle_output_token.rb', line 5

def file_name
  @file_name
end

#offenseObject (readonly)

Returns the value of attribute offense.



5
6
7
# File 'lib/checkstyle_output_token.rb', line 5

def offense
  @offense
end

#severityObject (readonly)

Returns the value of attribute severity.



5
6
7
# File 'lib/checkstyle_output_token.rb', line 5

def severity
  @severity
end

Instance Method Details

#to_suppressionObject



20
21
22
# File 'lib/checkstyle_output_token.rb', line 20

def to_suppression
  "  <suppress checks=\"#{offense}\" files=\"#{file_name}\"/>"
end