Class: MetadataCop::Cop::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/metadatacop/cop/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cops, options = {}) ⇒ Team

Returns a new instance of Team.



6
7
8
9
# File 'lib/metadatacop/cop/team.rb', line 6

def initialize(cops, options = {})
  @cops = cops
  @options = options
end

Instance Attribute Details

#copsObject (readonly)

Returns the value of attribute cops.



4
5
6
# File 'lib/metadatacop/cop/team.rb', line 4

def cops
  @cops
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/metadatacop/cop/team.rb', line 4

def options
  @options
end

Instance Method Details

#inspect_file(file) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/metadatacop/cop/team.rb', line 11

def inspect_file(file)
  linters, others = @cops.partition(&:lint?)

  result = run_cops(linters, file)

  # if the linters failed, no reason to run the others
  result += run_cops(others, file) if result.empty?

  result
end

#run_cops(cops, file) ⇒ Object



22
23
24
25
26
# File 'lib/metadatacop/cop/team.rb', line 22

def run_cops(cops, file)
  cops.inject([]) do |offenses, cop|
    offenses + cop.investigate(file)
  end
end