Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to skip/ignore rules/linting on specific lines #83

Open
tomasbackman opened this issue Jul 9, 2021 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@tomasbackman
Copy link

Is your proposal related to a problem?

Yes

The linting can fail on certain complex lines, like for example our (valid) usage of mail command for bareos backups in a template file:
"/usr/lib/bareos/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r"
Taken from: https://docs.bareos.org/Configuration/Messages.html#config-Dir_Messages_MailCommand

Describe the solution you’d like

Im not sure how to format the line above (or even if it is possible) so that the linter accepts it..
but I do know that the template and command works..
So I would like the possibility to skip this linting.
Just skipping the/a line, not skipping it for the whole 200+ lines file as linting still is good here.
Either skipping curlylint completely or just this rule.

For example with a # noqa ... line above the one you want to skip or something similar.

@tomasbackman
Copy link
Author

Actually it is the parsing of the file that fails, not any linting rule..

151:75	Parse error: expected one of '[:a-zA-Z]', 'animate', 'animateMotion', 'animateTransform', 'area', 'base', 'br', 'circle', 'col', 'ellipse', 'embed', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpotLight', 'feTile', 'feTurbulence', 'hr', 'image', 'img', 'input', 'line', 'link', 'meta', 'mpath', 'param', 'path', 'polygon', 'polyline', 'rect', 'script', 'set', 'source', 'stop', 'style', 'track', 'use', 'wbr', '{#', '{%', '{{' at 151:75	parse_error

But if the line could be skipped completely from even that it would be great!
Also some more exact error description could be nice as well.. but skipping is more important =)

@thibaudcolas
Copy link
Owner

Hey @tomasbackman, thank you for reporting this!

What you’re asking sounds a lot like #36.

Could you share more from your template? Just with this line alone I’m not entirely sure I understand what the parser might be failing on.

@tomasbackman
Copy link
Author

@thibaudcolas sorry for late reply, I just checked curlylint again (using version 13.0 on macos Big Sur 11.6)
And parsing fails for file containing below (a snippet of a .j2 template file for bareos configuration we are pushing out with ansible)

...
# Message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard
  Mail Command = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r"
  Operator Command = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: Intervention needed for %j\" %r"
  Mail = admin@example.com = all, !skipped
  Operator = admin@example.com = mount
  Console = all, !skipped, !saved
  Append = "/var/log/bareos/bareos.log" = all, !skipped
  Catalog = all
}
...

The snippet above is valid config and in production use in our bareos backup servers.

I think it is the Mail and Operator Command lines that makes curlylint fail (due to the repeated escapes and quotes maybe?). I tried to rewrite the lines a few times so that both the linting and the config worked but did not succeed in that.. :/.
What I have done is to turn of the linting of the whole file.. which I do not like, as Im a proponent for liniting and similar quality checks. So just ignoring a specific line (like adding #noqa in the end like in ansible-lint) with a mention would work nicely here I think.
Or if the linter/parsing became able to handle the line, but linting that can handle all different script syntax is pretty complex is my guess.. so my suggestion would be to first add ignore capabilities =)

@tomasbackman
Copy link
Author

Output fromm command (above snippet in a file)

$ curlylint curly-lint-test.txt
curly-lint-test.txt
5:64	Parse error: expected one of '[:a-zA-Z]', 'animate', 'animateMotion', 'animateTransform', 'area', 'base', 'br', 'circle', 'col', 'ellipse', 'embed', 'feBlend', 'feColorMatrix', 'feComposite', 'feConvolveMatrix', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpotLight', 'feTile', 'feTurbulence', 'hr', 'image', 'img', 'input', 'line', 'link', 'meta', 'mpath', 'param', 'path', 'polygon', 'polyline', 'rect', 'script', 'set', 'source', 'stop', 'style', 'track', 'use', 'wbr', '{#', '{%', '{{' at 5:64	parse_error

Oh no! 💥 💔 💥
1 error reported

@tomasbackman
Copy link
Author

We also have other occurrences in our code base where curlylint fails with similar problems in various template files (shell commands with mixes of quotes and backslashes etc.
Our code base is quite large and we have introduced linting to enhance the quality of it.. but linting not working, and especially not being able to turn off on case-by-case(line-by-line) basis is not helping us. Even if it does much other good for the files without problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants