adrienverge / yamllint

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

Error with line-length rule #522

Closed PabloAlexis611 closed 1 year ago

PabloAlexis611 commented 1 year ago

Hello there! I'm new to yamllint. I've read the documentation in regards to the line-length rule. Funny enough, I was adding some comments to my own .yamllint in regards to the line-length rule itself.

This was my .yamllint configuration:

---
# Extend from default yamllint configuration.
# See: https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
extends: default

# Customized yamllint rules.
rules:
  # See: https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.line_length
  line-length:
    allow-non-breakable-words: true
    allow-non-breakable-inline-mappings: true

I originally expected this to pass. But line #3 and #8 throw the error that lines are too long (since I'm using the default for that). Looking back to the examples provided here, I notice that for the allow-non-breakable-words and allow-non-breakable-inline-mappings examples, the documentation has an example like this instead:

# https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.line_length

So, I fixed the error by removing the "See: " portion in my YAML comments. But my question is, is this intended? Shouldn't non-breakable stuff like URLs there be ignored in the line-length context when having those rules set?

If not, then maybe a simple documentation update with an example that fails would be helpful

andrewimeson commented 1 year ago

The reasoning is that in that case you actually can break the line down further. You could put a comment on one line # see: and then the URL on the next line.

Do you want to a make PR to update the documentation with an example of a line with a long unbreakable string (like a URL) that needs to be broken down further?

adrienverge commented 1 year ago

Thanks @andrewimeson, I couldn't say it better :) +1 if you want to make the documentation clearer.

adrienverge commented 1 year ago

In the meantime I'll close this issue, since this is the expected behavior.