adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.86k stars 273 forks source link

Request for rule on max number of values #616

Open jonzerstyle opened 11 months ago

jonzerstyle commented 11 months ago

This is such a great project. Thank you so much.

This is not an issue. It is a request for a feature that would be nice to have.

In my yaml files there should only be one value per key.

Like so,

KeyA: ValA

Never.

KeyA: ValA ValB

It would be great if there was a rule to set the maximum number of values. Similar to being able to specify the maximum line length. I looked through all the issues and existing rules and could not find such a rule. I apologize if there is one and I missed it.

adrienverge commented 10 months ago

Hello and thanks for this request for a feature.

The goal of yamllint is to lint the form of YAML, not the content or its structure. We could imagine many new rules to check the number of words in a string value (what you propose), or the type of values, or that all strings contain a substring, or that all keys match a regex, etc. But the purpose of yamllint is to be focused on YAML itself, so I'm not favorable to adding such new content-oriented rules.

To achieve what you want, I would suggest writing a simple script.