Class: CukeLinter::StepWithTooManyCharactersLinter

Inherits:
Linter
  • Object
show all
Defined in:
lib/cuke_linter/linters/step_with_too_many_characters_linter.rb

Overview

A linter that detects steps that are too long

Constant Summary collapse

DEFAULT_STEP_LENGTH_THRESHOLD =

The threshold used if not otherwise configured

80

Instance Attribute Summary

Attributes inherited from Linter

#name

Instance Method Summary collapse

Methods inherited from Linter

#initialize, #lint

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



10
11
12
# File 'lib/cuke_linter/linters/step_with_too_many_characters_linter.rb', line 10

def configure(options)
  @step_length_threshold = options['StepLengthThreshold'] if options['StepLengthThreshold']
end

#messageObject

The message used to describe the problem that has been found



24
25
26
# File 'lib/cuke_linter/linters/step_with_too_many_characters_linter.rb', line 24

def message
  "Step is too long. #{@linted_step_length} characters found (max #{step_length_threshold})"
end

#rule(model) ⇒ Object

The rule used to determine if a model has a problem



15
16
17
18
19
20
21
# File 'lib/cuke_linter/linters/step_with_too_many_characters_linter.rb', line 15

def rule(model)
  return false unless model.is_a?(CukeModeler::Step)

  @linted_step_length = model.text.nil? ? 0 : model.text.length

  @linted_step_length > step_length_threshold
end