Class: Homebrew::Style::Offenses Private

Inherits:
Object
  • Object
show all
Extended by:
T::Generic
Includes:
Enumerable
Defined in:
style.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Collection of style offenses.

Constant Summary collapse

Elem =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

type_member(:out) { { fixed: Offense } }

Instance Method Summary collapse

Methods included from Enumerable

#compact_blank, #exclude?

Constructor Details

#initialize(paths) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



418
419
420
421
422
423
424
425
426
# File 'style.rb', line 418

def initialize(paths)
  @offenses = T.let({}, T::Hash[Pathname, T::Array[Offense]])
  paths.each do |f|
    next if f["offenses"].empty?

    path = Pathname(f["path"]).realpath
    @offenses[path] = f["offenses"].map { |x| Offense.new(x) }
  end
end

Instance Method Details

#each(&block) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



442
443
444
# File 'style.rb', line 442

def each(&block)
  @offenses.each(&block)
end

#for_path(path) ⇒ Array<Offense>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



429
430
431
# File 'style.rb', line 429

def for_path(path)
  @offenses.fetch(Pathname(path), [])
end