Class: Goodcheck::Reporters::JSON
- Inherits:
-
Object
- Object
- Goodcheck::Reporters::JSON
- Defined in:
- lib/goodcheck/reporters/json.rb
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #analysis ⇒ Object
- #file(path) ⇒ Object
-
#initialize(stdout:, stderr:) ⇒ JSON
constructor
A new instance of JSON.
- #issue(issue) ⇒ Object
- #rule(rule) ⇒ Object
- #summary ⇒ Object
Constructor Details
#initialize(stdout:, stderr:) ⇒ JSON
Returns a new instance of JSON.
8 9 10 11 12 |
# File 'lib/goodcheck/reporters/json.rb', line 8 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr @issues = [] end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
6 7 8 |
# File 'lib/goodcheck/reporters/json.rb', line 6 def issues @issues end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/goodcheck/reporters/json.rb', line 5 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/goodcheck/reporters/json.rb', line 4 def stdout @stdout end |
Instance Method Details
#analysis ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/goodcheck/reporters/json.rb', line 14 def analysis yield json = issues.map do |issue| location = issue.location { rule_id: issue.rule.id, path: issue.path, location: location && { start_line: location.start_line, start_column: location.start_column, end_line: location.end_line, end_column: location.end_column }, message: issue.rule., justifications: issue.rule.justifications, severity: issue.rule.severity } end stdout.puts ::JSON.dump(json) json end |
#file(path) ⇒ Object
37 38 39 |
# File 'lib/goodcheck/reporters/json.rb', line 37 def file(path) yield end |
#issue(issue) ⇒ Object
45 46 47 |
# File 'lib/goodcheck/reporters/json.rb', line 45 def issue(issue) issues << issue end |
#rule(rule) ⇒ Object
41 42 43 |
# File 'lib/goodcheck/reporters/json.rb', line 41 def rule(rule) yield end |
#summary ⇒ Object
49 50 51 |
# File 'lib/goodcheck/reporters/json.rb', line 49 def summary # noop end |