Class: Homebrew::RubocopOffense

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cmd/style.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ RubocopOffense

Returns a new instance of RubocopOffense



160
161
162
163
164
165
166
# File 'Library/Homebrew/cmd/style.rb', line 160

def initialize(json)
  @severity = json["severity"]
  @message = json["message"]
  @cop_name = json["cop_name"]
  @corrected = json["corrected"]
  @location = RubocopLineLocation.new(json["location"])
end

Instance Attribute Details

#cop_nameObject (readonly)

Returns the value of attribute cop_name



158
159
160
# File 'Library/Homebrew/cmd/style.rb', line 158

def cop_name
  @cop_name
end

#correctedObject (readonly)

Returns the value of attribute corrected



158
159
160
# File 'Library/Homebrew/cmd/style.rb', line 158

def corrected
  @corrected
end

#locationObject (readonly)

Returns the value of attribute location



158
159
160
# File 'Library/Homebrew/cmd/style.rb', line 158

def location
  @location
end

#messageObject (readonly)

Returns the value of attribute message



158
159
160
# File 'Library/Homebrew/cmd/style.rb', line 158

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity



158
159
160
# File 'Library/Homebrew/cmd/style.rb', line 158

def severity
  @severity
end

Instance Method Details

#severity_codeObject



168
169
170
# File 'Library/Homebrew/cmd/style.rb', line 168

def severity_code
  @severity[0].upcase
end

#to_s(options = {}) ⇒ Object



172
173
174
175
176
177
178
# File 'Library/Homebrew/cmd/style.rb', line 172

def to_s(options = {})
  if options[:display_cop_name]
    "#{severity_code}: #{location.to_short_s}: #{cop_name}: #{message}"
  else
    "#{severity_code}: #{location.to_short_s}: #{message}"
  end
end