cuke_linter icon indicating copy to clipboard operation
cuke_linter copied to clipboard

Linter to validate specific tags

Open pauloantunes001 opened this issue 3 years ago • 1 comments

Hello,

I would like to give you an idea, I think it would be a great feature if we can pass a regex param to validate specific tags, for example:

RequiredDocumentationTags:
  pattern:
    - @squad_
    - @tribe_
AllowJustOneTagEachScenario:
  pattern:
    - @squad_
    - @tribe_

So we can validate if this tags pattern exists in all our scenarios and limit to have just once. Are you planning to implement something like this?

pauloantunes001 avatar Aug 18 '20 13:08 pauloantunes001

Because this gem is about coding style, I've mostly been concerned about being an 'enabler' by providing a decent linting tool that is easy to use and expand upon. The actual creation of the multitude of 'rules' is something that I had hoped would be driven more by community contributions rather than me just coming up with (or lovingly stealing) a bunch of arbitrary things to check for.

That being said, if you or someone else has a good idea for a linter that would be generally useful but doesn't have the time/interest/skill/etc. to implement and PR it themselves, then I don't mind doing it myself.

For the two linters that you have suggested, they certainly seem to qualify as 'generally useful', so now it's just a matter of figuring out the details. How about something like

# Detects taggable elements that do not have certain tags
ElementRequiresTags:
  - type: Feature     # The model type that this configuration applies to. Multiple entries could have the same type in order to create more complex rules.
    pattern:          # Strings that will be converted into regular expressions for matching
      - squad_
      - tribe_
    all: true         # Element must have all of the configured tags
  - type: Example
    exact:            # Strings that will be must match exactly
      - '2019'
      - '2020'
    any: true         # Element must have at least one of the configured tags
    inherited: false  # The tags will still count if they come from the outline/feature/etc. level. 'true' should probably be the default.

# Detects taggable elements that have more than the configured amount of certain tags
ElementLimitsTags:
  - type:         # As above
    pattern:      # As above
    exact:        # As above
    inherited:    # As above
    count: 1      # How many of the configured tag can the element have before it is considered a problem

enkessler avatar Aug 18 '20 22:08 enkessler