Insufficient functionality for ignoring length of specific body lines
See original GitHub issueIn a nutshell, my use case is avoiding triggering line too long errors for certain lines in the commit body. I can accomplish that, but not in a way that it would not cause other problems. Some simplified examples follow, using lines starting with https://
as the example one I’d like to exempt from line length checks.
Try 1: ignore-body-lines
$ cat test-msg
Title goes here
More info:
https://github.com/jorisroovers/gitlint/commit/3c017995633f602125f7caaa91e96bb767ca5953
$ cat .gitlint
[ignore-body-lines]
regex = ^https://
$ cat test-msg | gitlint
3: B5 Body message is too short (10<20): "More info:"
This is an instance of the problem documented with ignore-body-lines
(it mentions line number confusion only though which is much less problematic than resulting in the B5 false positive IMHO). Anyway, for this reason, ignore-body-lines
does not fit the bill.
Try 2: ignore-body
$ cat test-msg
Title goes here
More info:
https://github.com/jorisroovers/gitlint/commit/3c017995633f602125f7caaa91e96bb767ca5953
This is a very very very very very very very very very very very very very very very very long line whose line I do _not_ want to ignore.
$ cat .gitlint
[ignore-by-body]
regex = ^https://
ignore = body-max-line-length,body-min-length
$ cat test-msg | gitlint
# (no output)
To overcome the problem with ignore-body-lines
line matches being entirely ignored and causing at least the B5 false positive, here’s an approach using ignore-by-body
with body-min-length
in ignore
. This sidesteps that problem, but causes another one: body-max-line-length
must be in ignore
in order for the line I want to be exempt for that check, but it causes line length checks to be skipped for all lines in the body. I’d like the “This is a very very …” line to be flagged as too long (but I can see why it is currently not).
Did I miss something?
I’m wondering if I missed something that could be used to accomplish what I’m looking for without side effects.
Appendix
Aside, perhaps body lines without whitespace should be exempt for the line length checks by default. This would not help with my problem completely as it has a few more variables, but would make sense I think.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (7 by maintainers)
I think the suggested feature would work great for my purposes. Thanks for considering and working on it!
Sorry for taking ages to get back to this. I tried out the
issues/255
branch briefly, and did not manage to find any problems with it 👍But it just occurred to me that a general purpose “ignore output matching a given regex” would work for this purpose just fine, and I guess (100% unverified) it could be less intrusive to implement. It wouldn’t be as elegant as more targeted approaches, but would serve as a brutally efficient last resort – not only for this particular one, but for any message one wants to ignore for whatever reason.
So a given regex in this rule, say
[ignore-output-lines]
would be matched against the entire output of gitlint, and filtered out + no effect on the exit status. So for example, this config:…could be used to ignore this:
A downside would be dependency on gitlint’s output formatting, but I wouldn’t personally mind that, as long as it’s stable.