question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Insufficient functionality for ignoring length of specific body lines

See original GitHub issue

In 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:open
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
scopcommented, Feb 11, 2022

I think the suggested feature would work great for my purposes. Thanks for considering and working on it!

0reactions
scopcommented, Jun 6, 2022

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:

[ignore-output-lines]
regex = ^\d+:\s+B1\s[^:]:[\s"]*https?://.*

…could be used to ignore this:

3: B1 Line exceeds max length (125>80): "https://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

A downside would be dependency on gitlint’s output formatting, but I wouldn’t personally mind that, as long as it’s stable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

commitlint: body's lines must not be longer than 100 ... - GitHub
Ignore body -max-line-length when dependabot is detected ... chore(commitlint): relaxes certain line length requirements
Read more >
Fixing bugs with Outlook specific CSS | by Stig Morten Myre
The solution is to revert mso-line-height-rule back to the default value at-least on any elements where it's causing an issue. Unlike rendering engines ......
Read more >
RFC1341(MIME) : 7 The Multipart content type
A body part that starts with a blank line, therefore, is allowed and is a body part ... All other header fields are...
Read more >
Rules Reference — SQLFluff 1.4.5 documentation
This rule is sqlfluff fix compatible. ignore_comment_clauses : Should comment clauses (e.g. column comments) be ignored when linting line lengths?
Read more >
Structure refinement in PHENIX
Available features at a glance. Coordinate refinement: Restrained or unrestrained individual, in real or reciprocal space; Grouped (rigid body); LBFGS ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found