Class: Reek::CodeClimate::CodeClimateFormatter
- Inherits:
-
Object
- Object
- Reek::CodeClimate::CodeClimateFormatter
- Defined in:
- lib/reek/code_climate/code_climate_formatter.rb
Overview
Generates a hash in the structure specified by the Code Climate engine spec
Instance Attribute Summary collapse
-
#warning ⇒ Object
readonly
private
Returns the value of attribute warning.
Instance Method Summary collapse
- #categories ⇒ Object private
- #check_name ⇒ Object private
- #configuration ⇒ Object private
- #content ⇒ Object private
- #description ⇒ Object private
- #fingerprint ⇒ Object private
-
#initialize(warning) ⇒ CodeClimateFormatter
constructor
A new instance of CodeClimateFormatter.
- #location ⇒ Object private
- #remediation_points ⇒ Object private
- #render ⇒ Object
Constructor Details
#initialize(warning) ⇒ CodeClimateFormatter
Returns a new instance of CodeClimateFormatter.
10 11 12 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 10 def initialize(warning) @warning = warning end |
Instance Attribute Details
#warning ⇒ Object (readonly, private)
Returns the value of attribute warning.
26 27 28 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 26 def warning @warning end |
Instance Method Details
#categories ⇒ Object (private)
36 37 38 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 36 def categories ['Complexity'] end |
#check_name ⇒ Object (private)
32 33 34 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 32 def check_name warning.smell_type end |
#configuration ⇒ Object (private)
59 60 61 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 59 def configuration @configuration ||= CodeClimateConfiguration.load end |
#content ⇒ Object (private)
55 56 57 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 55 def content configuration[warning.smell_type].fetch('content') end |
#description ⇒ Object (private)
28 29 30 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 28 def description [warning.context, warning.].join(' ') end |
#fingerprint ⇒ Object (private)
51 52 53 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 51 def fingerprint CodeClimateFingerprint.new(warning).compute end |
#location ⇒ Object (private)
40 41 42 43 44 45 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 40 def location warning_lines = warning.lines CCEngine::Location::LineRange.new( path: warning.source, line_range: warning_lines.first..warning_lines.last) end |
#remediation_points ⇒ Object (private)
47 48 49 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 47 def remediation_points configuration[warning.smell_type].fetch('remediation_points') end |
#render ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/reek/code_climate/code_climate_formatter.rb', line 14 def render CCEngine::Issue.new(check_name: check_name, description: description, categories: categories, location: location, remediation_points: remediation_points, fingerprint: fingerprint, content: content).render end |