Class: Homebrew::Style::RubocopResults

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

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ RubocopResults

Returns a new instance of RubocopResults



132
133
134
135
136
137
138
139
140
141
# File 'brew/Library/Homebrew/style.rb', line 132

def initialize(json)
  @metadata = json["metadata"]
  @file_offenses = {}
  json["files"].each do |f|
    next if f["offenses"].empty?

    file = File.realpath(f["path"])
    @file_offenses[file] = f["offenses"].map { |x| RubocopOffense.new(x) }
  end
end

Instance Method Details

#file_offenses(path) ⇒ Object



143
144
145
# File 'brew/Library/Homebrew/style.rb', line 143

def file_offenses(path)
  @file_offenses.fetch(path.to_s, [])
end