Class: CukeLinter::ElementWithDuplicateTagsLinter
- Defined in:
- lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb
Overview
A linter that detects taggable Gherkin elements that have duplicate tags
Instance Attribute Summary
Attributes inherited from Linter
Instance Method Summary collapse
-
#configure(options) ⇒ Object
Changes the linting settings on the linter using the provided configuration.
-
#message ⇒ Object
The message used to describe the problem that has been found.
-
#rule(model) ⇒ Object
The rule used to determine if a model has a problem.
Methods inherited from Linter
Constructor Details
This class inherits a constructor from CukeLinter::Linter
Instance Method Details
#configure(options) ⇒ Object
Changes the linting settings on the linter using the provided configuration
7 8 9 |
# File 'lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb', line 7 def configure() @tag_inheritance = ['IncludeInheritedTags'] end |
#message ⇒ Object
The message used to describe the problem that has been found
30 31 32 33 34 |
# File 'lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb', line 30 def class_name = @linted_model_class.name.split('::').last "#{class_name} has duplicate tag '#{@duplicate_tag}'." end |
#rule(model) ⇒ Object
The rule used to determine if a model has a problem
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb', line 12 def rule(model) return false unless relevant_model?(model) @linted_model_class = model.class = if @tag_inheritance model. else model. || [] end tag_names = .map(&:name) @duplicate_tag = tag_names.find { |tag| tag_names.count(tag) > 1 } !@duplicate_tag.nil? end |