Class: AdLint::Report

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg_fpath, met_fpath, log_fpath, verbose, &block) ⇒ Report

Returns a new instance of Report.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/adlint/report.rb', line 40

def initialize(msg_fpath, met_fpath, log_fpath, verbose, &block)
  @msg_fpath     = msg_fpath
  @msg_file      = open_msg_file(msg_fpath)
  @met_fpath     = met_fpath
  @met_file      = open_met_file(met_fpath)
  @log_fpath     = log_fpath
  @verbose       = verbose
  @unique_msgs   = Set.new
  @deferred_msgs = []

  yield(self)
ensure
  @msg_file.close if @msg_file
  @met_file.close if @met_file
end

Instance Attribute Details

#log_fpathObject (readonly)

Returns the value of attribute log_fpath.



58
59
60
# File 'lib/adlint/report.rb', line 58

def log_fpath
  @log_fpath
end

#met_fpathObject (readonly)

Returns the value of attribute met_fpath.



57
58
59
# File 'lib/adlint/report.rb', line 57

def met_fpath
  @met_fpath
end

#msg_fpathObject (readonly)

Returns the value of attribute msg_fpath.



56
57
58
# File 'lib/adlint/report.rb', line 56

def msg_fpath
  @msg_fpath
end

Instance Method Details

#flush_deferred_messages(suppressors) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/adlint/report.rb', line 81

def flush_deferred_messages(suppressors)
  @deferred_msgs.each do |msg|
    rawrite_message(msg) unless suppressors.suppress?(msg)
  end
  @deferred_msgs.clear
  self
end

#write_code_metric(code_metric) ⇒ Object

DESCRIPTION

Writes a code quality metric on this report.

PARAMETER

code_metric

CodeMetric – Code metric information to be written.

RETURN VALUE

Report – Self.



110
111
112
113
# File 'lib/adlint/report.rb', line 110

def write_code_metric(code_metric)
  code_metric.print_as_csv(@met_file)
  self
end

#write_code_struct(code_struct) ⇒ Object

DESCRIPTION

Writes a code structure information on this report.

PARAMETER

code_struct

CodeStructure – Code structure info to be written.

RETURN VALUE

Report – Self.



97
98
99
100
# File 'lib/adlint/report.rb', line 97

def write_code_struct(code_struct)
  code_struct.print_as_csv(@met_file)
  self
end

#write_message(msg, suppressors = nil) ⇒ Object

DESCRIPTION

Writes a message on this report.

PARAMETER

message

Message – Message to be written.

RETURN VALUE

Report – Self.



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/adlint/report.rb', line 68

def write_message(msg, suppressors = nil)
  if suppressors.nil? || !suppressors.suppress?(msg)
    unless msg.must_be_unique? && !@unique_msgs.add?(msg)
      if msg.must_be_deferred?
        @deferred_msgs.push(msg)
      else
        rawrite_message(msg)
      end
    end
  end
  self
end