Class: Rubocop::Report::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/report/report.rb

Direct Known Subclasses

PlainText

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Report

Returns a new instance of Report.

Parameters:

  • the (String)

    filename for this report



22
23
24
25
# File 'lib/rubocop/report/report.rb', line 22

def initialize(filename)
  @filename = filename
  @entries = []
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



19
20
21
# File 'lib/rubocop/report/report.rb', line 19

def filename
  @filename
end

Instance Method Details

#<<(cop) ⇒ Object

Appends offences registered by cops to the report.

Parameters:

  • a (Cop)

    cop with something to report



29
30
31
32
33
# File 'lib/rubocop/report/report.rb', line 29

def <<(cop)
  cop.offences.each do |entry|
    @entries << entry
  end
end

#empty?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rubocop/report/report.rb', line 39

def empty?
  entries.empty?
end

#entriesObject



35
36
37
# File 'lib/rubocop/report/report.rb', line 35

def entries
  @entries.sort_by(&:line_number)
end