Class: CukeLinter::ElementWithTooManyTagsLinter
- Defined in:
- lib/cuke_linter/linters/element_with_too_many_tags_linter.rb
Overview
A linter that detects taggable Gherkin elements that have too many tags
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
8 9 10 11 |
# File 'lib/cuke_linter/linters/element_with_too_many_tags_linter.rb', line 8 def configure() @tag_threshold = ['TagCountThreshold'] @tag_inheritance = ['CountInheritedTags'] end |
#message ⇒ Object
The message used to describe the problem that has been found
34 35 36 37 38 |
# File 'lib/cuke_linter/linters/element_with_too_many_tags_linter.rb', line 34 def class_name = @linted_model_class.name.split('::').last "#{class_name} has too many tags. #{@linted_tag_count} tags found (max #{@linted_tag_threshold})." end |
#rule(model) ⇒ Object
The rule used to determine if a model has a problem
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cuke_linter/linters/element_with_too_many_tags_linter.rb', line 14 def rule(model) return false unless model.is_a?(CukeModeler::Feature) || model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline) || model.is_a?(CukeModeler::Example) @linted_model_class = model.class @linted_tag_threshold = @tag_threshold || 5 if @tag_inheritance @linted_tag_count = model..count else @linted_tag_count = model..nil? ? 0 : model..count end @linted_tag_count > @linted_tag_threshold end |