Class: WayOfWorking::CodeLinting::Hdi::SupportedLinter
- Inherits:
-
Object
- Object
- WayOfWorking::CodeLinting::Hdi::SupportedLinter
- Defined in:
- lib/way_of_working/code_linting/hdi/supported_linter.rb
Overview
Struct to hold linter data
Constant Summary collapse
- NOT_USED_REASON =
Reasons why certain linters are not used
{ 'CSS_SCSS_LINT' => 'scss-lint recommends using stylelint', 'HTML_DJLINT' => 'Refuses to see config file', 'RUBY_RUBOCOP' => 'RuboCop is used directly' }.freeze
- TLA_LANGUAGES =
Acronyms for languages
%w[ CSS ENV HTML JSON JSX PHP SQL TSX XML YAML ].freeze
- LANGUAGE_MAPPINGS =
Mapping for languages
{ 'Action' => 'GitHub Action', 'Arm' => 'ARM Templates', 'Cloudformation' => 'CloudFormation', 'Coffee' => 'CoffeeScript', 'Editorconfig' => 'EditorConfig', 'Graphql' => 'GraphQL', 'Javascript' => 'JavaScript', 'Latex' => 'LaTeX', 'Protobuf' => 'Protocol Buffers', 'Rst' => 'reStructuredText', 'Spell' => 'Spelling', 'Typescript' => 'TypeScript', 'Visual Basic .Net' => 'VB.Net' }.freeze
Instance Attribute Summary collapse
-
#enabled_linters ⇒ Object
Returns the value of attribute enabled_linters.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sorter ⇒ Object
Returns the value of attribute sorter.
Instance Method Summary collapse
- #constant_name ⇒ Object
- #details ⇒ Object
-
#initialize(language, constant_name, name, link, enabled_linters) ⇒ SupportedLinter
constructor
A new instance of SupportedLinter.
- #language ⇒ Object
Constructor Details
#initialize(language, constant_name, name, link, enabled_linters) ⇒ SupportedLinter
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 46 def initialize(language, constant_name, name, link, enabled_linters) @original_language = language @original_constant_name = constant_name @name = name @link = link @enabled_linters = enabled_linters # Array used for sorting @sorter = [@original_language, @original_constant_name] end |
Instance Attribute Details
#enabled_linters ⇒ Object
Returns the value of attribute enabled_linters.
44 45 46 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 44 def enabled_linters @enabled_linters end |
#link ⇒ Object
Returns the value of attribute link.
44 45 46 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 44 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
44 45 46 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 44 def name @name end |
#sorter ⇒ Object
Returns the value of attribute sorter.
44 45 46 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 44 def sorter @sorter end |
Instance Method Details
#constant_name ⇒ Object
69 70 71 72 73 74 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 69 def constant_name return @original_constant_name if enabled_linters.include?(@original_constant_name) # Strike-through the constant name if the linter is not used "~~#{@original_constant_name}~~" end |
#details ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 76 def details return "[#{name}](#{link})" if enabled_linters.include?(@original_constant_name) details = 'Not Used' # Add reason if available if NOT_USED_REASON.key?(@original_constant_name) details = "#{details} (#{NOT_USED_REASON[@original_constant_name]})" end details end |
#language ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/way_of_working/code_linting/hdi/supported_linter.rb', line 57 def language language = @original_language # Titleize language unless it is an acronym language = language.titleize unless TLA_LANGUAGES.include?(language) # Use mapped language name if available language = LANGUAGE_MAPPINGS[language] if LANGUAGE_MAPPINGS.key?(language) language end |