Class: RuboCop::Cop::MessageAnnotator
- Inherits:
-
Object
- Object
- RuboCop::Cop::MessageAnnotator
- Defined in:
- lib/rubocop/cop/message_annotator.rb
Overview
Message Annotator class annotates a basic offense message based on params passed into initializer.
#=> 'Cop/CopName: message (http://example.org/styleguide)'
Class Attribute Summary collapse
-
.style_guide_urls ⇒ Object
readonly
Returns the value of attribute style_guide_urls.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#cop_config ⇒ Object
readonly
Returns the value of attribute cop_config.
-
#cop_name ⇒ Object
readonly
Returns the value of attribute cop_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#annotate(message) ⇒ String
Returns the annotated message, based on params passed into initializer.
-
#initialize(config, cop_name, cop_config, options) ⇒ MessageAnnotator
constructor
A new instance of MessageAnnotator.
- #urls ⇒ Object
Constructor Details
#initialize(config, cop_name, cop_config, options) ⇒ MessageAnnotator
Returns a new instance of MessageAnnotator.
47 48 49 50 51 52 |
# File 'lib/rubocop/cop/message_annotator.rb', line 47 def initialize(config, cop_name, cop_config, ) @config = config @cop_name = cop_name @cop_config = cop_config || {} @options = end |
Class Attribute Details
.style_guide_urls ⇒ Object (readonly)
Returns the value of attribute style_guide_urls.
21 22 23 |
# File 'lib/rubocop/cop/message_annotator.rb', line 21 def style_guide_urls @style_guide_urls end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/rubocop/cop/message_annotator.rb', line 16 def config @config end |
#cop_config ⇒ Object (readonly)
Returns the value of attribute cop_config.
16 17 18 |
# File 'lib/rubocop/cop/message_annotator.rb', line 16 def cop_config @cop_config end |
#cop_name ⇒ Object (readonly)
Returns the value of attribute cop_name.
16 17 18 |
# File 'lib/rubocop/cop/message_annotator.rb', line 16 def cop_name @cop_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/rubocop/cop/message_annotator.rb', line 16 def @options end |
Instance Method Details
#annotate(message) ⇒ String
Returns the annotated message, based on params passed into initializer
58 59 60 61 62 63 64 65 66 |
# File 'lib/rubocop/cop/message_annotator.rb', line 58 def annotate() = "#{cop_name}: #{}" if display_cop_names? += " #{details}" if extra_details? && details if display_style_guide? links = urls.join(', ') = "#{} (#{links})" end end |
#urls ⇒ Object
68 69 70 |
# File 'lib/rubocop/cop/message_annotator.rb', line 68 def urls [style_guide_url, *reference_urls].compact end |