Class: CukeLinter::Linter
- Inherits:
-
Object
- Object
- CukeLinter::Linter
- Defined in:
- lib/cuke_linter/linters/linter.rb
Overview
A generic linter that can be used to make arbitrary linting rules
Direct Known Subclasses
BackgroundDoesMoreThanSetupLinter, ElementWithCommonTagsLinter, ElementWithDuplicateTagsLinter, ElementWithTooManyTagsLinter, ExampleWithoutNameLinter, FeatureFileWithInvalidNameLinter, FeatureFileWithMismatchedNameLinter, FeatureWithTooManyDifferentTagsLinter, FeatureWithoutDescriptionLinter, FeatureWithoutNameLinter, FeatureWithoutScenariosLinter, OutlineWithSingleExampleRowLinter, SingleTestBackgroundLinter, StepWithEndPeriodLinter, StepWithTooManyCharactersLinter, TestNameWithTooManyCharactersLinter, TestShouldUseBackgroundLinter, TestWithActionStepAsFinalStepLinter, TestWithBadNameLinter, TestWithNoActionStepLinter, TestWithNoNameLinter, TestWithNoVerificationStepLinter, TestWithSetupStepAfterActionStepLinter, TestWithSetupStepAfterVerificationStepLinter, TestWithSetupStepAsFinalStepLinter, TestWithTooManyStepsLinter
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the name of the linter.
Instance Method Summary collapse
-
#initialize(name: nil, message: nil, rule: nil) ⇒ Linter
constructor
Creates a new linter object.
-
#lint(model) ⇒ Object
Lints the given model and returns linting data about said model.
Constructor Details
#initialize(name: nil, message: nil, rule: nil) ⇒ Linter
Creates a new linter object
10 11 12 13 14 |
# File 'lib/cuke_linter/linters/linter.rb', line 10 def initialize(name: nil, message: nil, rule: nil) @name = name || self.class.name.split('::').last @message = || "#{self.name} problem detected" @rule = rule end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the name of the linter
7 8 9 |
# File 'lib/cuke_linter/linters/linter.rb', line 7 def name @name end |
Instance Method Details
#lint(model) ⇒ Object
Lints the given model and returns linting data about said model
17 18 19 20 21 22 23 24 25 |
# File 'lib/cuke_linter/linters/linter.rb', line 17 def lint(model) raise 'No linting rule provided!' unless @rule || respond_to?(:rule) problem_found = respond_to?(:rule) ? rule(model) : @rule.call(model) return nil unless problem_found build_problem(model) end |