-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add min-body-length option #135
Conversation
Thanks a lot, @soulseekah ! I won't make it today to review -- hopefully tomorrow. In the meantime, could you please have a look at the CI -- I think you need to fix the commit message to comply to 72 characters width? @Fryuni would you mind reviewing as well, so that at least two pairs of eyes looked at the code? |
Sure, I'll take a look today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got one point of preference in the implementation. Besides that, there are no tests for this.
src/inspection.ts
Outdated
@@ -228,6 +228,14 @@ function checkBody( | |||
return errors; | |||
} | |||
|
|||
// Minimum character body length | |||
if (inputs.minBodyLength && bodyLines.join().length < inputs.minBodyLength) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it could newlines as characters?
The lines are split by \n
, so they are not included in bodyLines
. But calling join()
without any arguments adds a ,
between each line, effectively counting what was originally the line breaks.
I'd prefer join('')
to not count those, but it's definitely not blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the '', good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While writing tests the '' seems counterintuitive. If the message is laid out into one long string shouldn't there be a space when joining?
const message =
'Change SomeClass to OtherClass\n' +
'\n' +
'This replaces the SomeClass with OtherClass in all of the module\n' +
'since Some class was deprecated.';
If we do '' we get 96 characters but the string would become "This replaces the SomeClass with OtherClass in all of the modulesince Some class was deprecated."
Instead of "module since". What would be more intuitive then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both counting and not counting the newlines are equally fine as those are mostly corner cases.
But given how unintuitive it might be then counting would be better. So count newlines the same as counting whitespaces
4d4e1dd
to
2af2219
Compare
2af2219
to
5754d09
Compare
I've added some tests assuming that we join with a space. Happy to agree on whatever you think is better for glueing lines together. Quick question: should I be running |
I think you need to include |
When set an error will be emitted if the body does not contain enough characters. This is useful to require commit bodies with more information, like impact, motivation, approach, testing results, new behavior, etc. Default: no minimum. Suggested: at least 150.
Added another test. So three tests in total:
These assume that the join is with spaces. |
5754d09
to
85936d3
Compare
Thanks again a lot, @soulseekah for the contribution and @Fryuni for the review! |
When set an error will be emitted if the body does not contain enough characters. This is useful to require commit bodies with more information, like impact, motivation, approach, testing results, new behavior, etc.
Default: no minimum. Suggested: at least 150.
Fixes #136.