-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Tests: Add a lint check for trailing whitespace #11300
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
Conversation
|
utACK 258094ae4bdb17a1f2063b9f85955f41945e4611 |
|
Fixed a mis-copied comment in the tab character check which was referring to whitespace again |
contrib/devtools/lint-whitespace.sh
Outdated
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.
This doesn't sound like correct English to me (but I'm not a native speaker myself). Use "instead of spaces" perhaps?
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.
Yeah, I don't think it's technically wrong but it doesn't sound quite right, yours sounds better. Fixed.
.travis.yml
Outdated
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.
This needs to be guarded by TRAVIS_COMMIT_RANGE if you fail on -z $TRAVIS_COMMIT_RANGE, no?
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'm not even sure if I should have changed it to fail, should it just exit quietly if there's no commit range?
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.
Actually this should be fine, as TRAVIS_COMMIT_RANGE should never be empty according to the travis doc. (It is only empty for branches with a single commit, which we don't have)
|
I can't manage to run the script. Am I calling it wrong? I got the commit range from https://travis-ci.org/bitcoin/bitcoin/jobs/272143045 I get the same if I run This works: |
|
@mess110 my guess is that you have a different version of git which doesn't assume all files to be included if only excludes are given, but I've updated the commit to (hopefully) fix it for you |
|
Thanks, that was it indeed. ACK b8c0cfa |
|
utACK b8c0cfae6d6f39fe38dcfec229f3824a5af44b29 |
1 similar comment
|
utACK b8c0cfae6d6f39fe38dcfec229f3824a5af44b29 |
jnewbery
left a comment
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.
Tested ACK. I've tested locally that both checks work, and that the src/leveldb/ exclusion also works.
It'd be helpful to also print out the @@ line showing the line number where the whitespace was introduced. Something like:
diff --git a/contrib/devtools/lint-whitespace.sh b/contrib/devtools/lint-whitespace.sh
index 5bea86a..8a065fe 100755
--- a/contrib/devtools/lint-whitespace.sh
+++ b/contrib/devtools/lint-whitespace.sh
@@ -40,0 +41,2 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
+ elif [[ "$line" =~ ^@@ ]]; then
+ LINENUMBER="$line"
@@ -46,0 +49 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
+ echo "$LINENUMBER"
@@ -51 +54 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
- done < <(showdiff | grep -E '^(diff --git |\+.*\s+$)')
+ done < <(showdiff | grep -E '^(diff --git |@@|\+.*\s+$)')
@@ -64,0 +68,2 @@ if showcodediff | grep -P -q '^\+.*\t'; then
+ elif [[ "$line" =~ ^@@ ]]; then
+ LINENUMBER="$line"
@@ -70,0 +76 @@ if showcodediff | grep -P -q '^\+.*\t'; then
+ echo "$LINENUMBER"
@@ -75 +81 @@ if showcodediff | grep -P -q '^\+.*\t'; then
- done < <(showcodediff | grep -P '^(diff --git |\+.*\t)')
+ done < <(showcodediff | grep -P '^(diff --git |@@|\+.*\t)')
should do it. This only prints out the line number for the first match in each file, but I think that's ok.
contrib/devtools/lint-whitespace.sh
Outdated
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.
Perhaps add help text here explaining how to run locally:
echo "To run locally, use:"
echo "TRAVIS_COMMIT_RANGE='<commit range>' .lint-whitespace.sh"
echo "eg:"
echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh"This adds a new CHECK_DOC check that looks for newly introduced trailing whitespace. Existing trailing whitespace (of which there is plenty!) will not trigger an error. This is written in a generic way so that new lint-*.sh scripts can be added to contrib/devtools/, as I'd like to contribute additional lint checks in the future.
|
Rebased on master to fix merge conflict and addressed @jnewbery's comments, thanks! |
|
re-utACK 1f379b1 |
1f379b1 Add tab char lint check and exclude imported dependencies (MeshCollider) dd36561 Add a lint check for trailing whitespace. (Evan Klitzke) Pull request description: This is a new attempt at #11005 Addressed nits, excluded imported dependencies, squashed the original commits, and added a test for tab characters in the *.cpp *.h *.md *.py *.sh files too as per @practicalswift suggestion Tree-SHA512: d2dfbedc8469026f39b0c63d9a71d8b8e2ed3815d69fecaabad10304d977d6345728c4c865ec7600ed539b1f7cabaa826b50312f4d2eef0a1583d4ff9024c36d
…*dash* no travis *DASH* doesn't implement this check into travis 1f379b1 Add tab char lint check and exclude imported dependencies (MeshCollider) dd36561 Add a lint check for trailing whitespace. (Evan Klitzke) Pull request description: This is a new attempt at bitcoin#11005 Addressed nits, excluded imported dependencies, squashed the original commits, and added a test for tab characters in the *.cpp *.h *.md *.py *.sh files too as per @practicalswift suggestion Tree-SHA512: d2dfbedc8469026f39b0c63d9a71d8b8e2ed3815d69fecaabad10304d977d6345728c4c865ec7600ed539b1f7cabaa826b50312f4d2eef0a1583d4ff9024c36d
Backport useful lints from upstream Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6892 - bitcoin/bitcoin#11151 - bitcoin/bitcoin#11300 - bitcoin/bitcoin@96d91b7 - bitcoin/bitcoin#12097 - bitcoin/bitcoin#12098 - bitcoin/bitcoin#12442 - bitcoin/bitcoin#12572 - bitcoin/bitcoin#12757 - bitcoin/bitcoin#11878 - bitcoin/bitcoin#12933 - bitcoin/bitcoin#12871 - bitcoin/bitcoin#12972 - bitcoin/bitcoin#13281 - bitcoin/bitcoin#13385 - bitcoin/bitcoin#13041 - bitcoin/bitcoin#13454 - bitcoin/bitcoin#13448 - bitcoin/bitcoin#13510 - bitcoin/bitcoin#13851 - bitcoin/bitcoin#13863 - bitcoin/bitcoin#14115 - bitcoin/bitcoin#14831 - bitcoin/bitcoin#15164 - bitcoin/bitcoin#15170 - bitcoin/bitcoin#15166 - bitcoin/bitcoin#16036 - bitcoin/bitcoin#16768 Several of the lints fail for our current codebase; these will be addressed in a subsequent PR.
Backport useful lints from upstream Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6892 - bitcoin/bitcoin#11151 - bitcoin/bitcoin#11300 - bitcoin/bitcoin@96d91b7 - bitcoin/bitcoin#12097 - bitcoin/bitcoin#12098 - bitcoin/bitcoin#12442 - bitcoin/bitcoin#12572 - bitcoin/bitcoin#12757 - bitcoin/bitcoin#11878 - bitcoin/bitcoin#12933 - bitcoin/bitcoin#12871 - bitcoin/bitcoin#12972 - bitcoin/bitcoin#13281 - bitcoin/bitcoin#13385 - bitcoin/bitcoin#13041 - bitcoin/bitcoin#13454 - bitcoin/bitcoin#13448 - bitcoin/bitcoin#13510 - bitcoin/bitcoin#13851 - bitcoin/bitcoin#13863 - bitcoin/bitcoin#14115 - bitcoin/bitcoin#14831 - bitcoin/bitcoin#15164 - bitcoin/bitcoin#15170 - bitcoin/bitcoin#15166 - bitcoin/bitcoin#16036 - bitcoin/bitcoin#16768 - bitcoin/bitcoin#13494 Several of the lints fail for our current codebase; these will be addressed in a subsequent PR.
This is a new attempt at #11005
Addressed nits, excluded imported dependencies, squashed the original commits, and added a test for tab characters in the *.cpp *.h *.md *.py *.sh files too as per @practicalswift suggestion