An offense represents a style violation detected by RuboCop.
@api public
@!attribute [r] cop_name
@return [String]
a cop class name without namespace. i.e. type of the violation.
@example
'LineLength'
@api public
@!attribute [r] corrected
@return [Boolean]
whether this offense is automatically corrected.
@api public
@!attribute [r] corrected
@return [Boolean]
whether this offense is automatically corrected.
@api public
@!attribute [r] location
@return [Parser::Source::Range]
the location where the violation is detected.
@see rubydoc.info/github/whitequark/parser/Parser/Source/Range
Parser::Source::Range
@api private
# File lib/rubocop/cop/offense.rb, line 65 def initialize(severity, location, message, cop_name, corrected = false) @severity = RuboCop::Cop::Severity.new(severity) @location = location.freeze @line = location.line.freeze @column = location.column.freeze @message = message.freeze @cop_name = cop_name.freeze @corrected = corrected.freeze freeze end
@api public
Returns `-1`, `0` or `+1` if this offense is less than, equal to, or greater than `other`.
@return [Integer]
comparison result
# File lib/rubocop/cop/offense.rb, line 109 def <=>(other) [:line, :column, :cop_name, :message].each do |attribute| result = send(attribute) <=> other.send(attribute) return result unless result == 0 end 0 end
@api public
@return [Boolean]
returns `true` if two offenses contain same attributes
# File lib/rubocop/cop/offense.rb, line 96 def ==(other) severity == other.severity && line == other.line && column == other.column && message == other.message && cop_name == other.cop_name end
Generated with the Darkfish Rdoc Generator 2.