cuke_linter icon indicating copy to clipboard operation
cuke_linter copied to clipboard

More linters needed

Open enkessler opened this issue 4 years ago • 5 comments

While the fundamental linting, reporting, and API portion of the gem is complete, there are still a lot of linters left to add. The sky is the limit, really. Initially, however, I would like to port over the existing linters from several other popular (but defunct) Gherkin/Cucumber linting gems.

https://github.com/funkwerk/gherkin_lint https://github.com/r-cochran/cuke_sniffer

From GherkinLint

  • [x] avoid outline for single example
  • [x] avoid period
  • [ ] avoid scripting
  • [ ] be declarative
  • [x] background does more than setup
  • [x] background requires scenario
  • [x] bad scenario name
  • [x] file name differs feature name
  • [x] invalid file name
  • [x] invalid step flow
  • [x] missing example name
  • [x] missing feature description
  • [x] missing feature name
  • [x] missing scenario name
  • [x] missing test action
  • [x] missing verification
  • [ ] required tag starts with
  • [x] same tag for all scenarios
  • [x] tag used multiple times
  • [ ] too clumsy
  • [x] too long step
  • [x] too many different tags
  • [x] too many steps
  • [x] too many tags
  • [ ] unique scenario names
  • [ ] unknown variable
  • [x] use background
  • [ ] ~~use outline~~ too fuzzy to bother?

From CukeSniffer (many of these may need to be broken into multiple linters for simplicity or made non-default due to their highly opinionated nature)

Feature And Scenario

  • [ ] ~~Comment comes between tag and properly executing line. This feature file cannot run!~~ If a feature file cannot be parsed, it cannot be linted
  • [ ] {class} has no description.
  • [ ] {class} has numbers in the description.
  • [ ] There are commas in the description, creating possible multirunning scenarios or features.
  • [ ] {class} has a commented out tag
  • [ ] {class} has too many tags.
  • [ ] {class} has a long description.

Feature Only

  • [ ] Feature with no scenarios.
  • [ ] Feature file has no content.
  • [ ] Feature has a background with no scenarios.
  • [ ] Feature has a background with one scenario.
  • [ ] Same tag appears on both Feature and Scenario
  • [ ] Tag appears on all scenarios.
  • [ ] Feature with too many scenarios.

Background And Scenario

  • [ ] Commented step.
  • [ ] No steps in Scenario.
  • [ ] Step that is only one word long.
  • [ ] {class} with too many steps.
  • [ ] Invalid first step. Began with And/But.
  • [ ] Step includes a * instead of Given/When/Then/And/But.
  • [ ] Given/When/Then used multiple times in the same {class}.
  • [ ] Implementation word used: {word}.
  • [ ] Date used.

Background Only

  • [ ] ~~There is a background with a tag. This feature file cannot run!~~ If a feature file cannot be parsed, it cannot be linted

Scenario Only

  • [ ] Scenario Outline with no examples.
  • [ ] Scenario Outline with no examples table.
  • [ ] Commented example.
  • [ ] Scenario steps out of Given/When/Then order.
  • [ ] Scenario Outline with only one example.
  • [ ] Scenario Outline with too many examples.

~~Hook and step definition rules~~ The scope of CukeLinter is Gherkin. Implementation language specific files are not linted.

Feel free to comment on this issue if you would like to claim some of the needed linters so that duplicate effort is avoided. Even making just one linter is fine.

enkessler avatar Oct 04 '19 06:10 enkessler

This looks quite interesting and a good learning exercise to implement. I can make a start on this unless there's already something you have done ?

anuj-ssharma avatar Oct 07 '19 21:10 anuj-ssharma

Go for it! Anything unchecked should be fair game, although some of the CukeSniffer stuff may have overlap with the GherkinLint stuff.

enkessler avatar Oct 08 '19 00:10 enkessler

Hi, one suggestion to the list. There is a 'StepWithTooManyCharactersLinter' rule, would be grate to have same thing for Scenario names if possible.

PKuravskyi avatar Feb 25 '22 15:02 PKuravskyi

That should be doable. Would you like to take a crack at it @PKuravskyi ?

enkessler avatar Feb 26 '22 01:02 enkessler

@enkessler PR is ready for review

PavloKura avatar Feb 26 '22 10:02 PavloKura