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

vet: fix option order when invoking grep #7421

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

atollena
Copy link
Collaborator

@atollena atollena commented Jul 17, 2024

vet.sh is currently calling grep -ev expr. This is being interpreted as "grep pattern 'v' in file 'expr'", instead of the intended "invert grep for pattern 'expr' in standard input". As a result:

  • Most of the time we see a line as follows on standard output:
+ noret_grep '(SA4000)' /tmp/tmp.xKUnikWsnw
+ grep '(SA4000)' /tmp/tmp.xKUnikWsnw
+ not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ [[ 1 == 1 ]]
grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory

and the process continues without error, but doesn't do what we want it to do.

  • Occasionally, this causes a broken pipe on the first grep which results in an error:
+ noret_grep '(SA4000)' /tmp/tmp.BmSCFYnqgE
+ grep '(SA4000)' /tmp/tmp.BmSCFYnqgE
+ not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory
grep: write error: Broken pipe
+ [[ 2 == 1 ]]

RELEASE NOTES: none

Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.32%. Comparing base (b1979b6) to head (43f42b2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7421      +/-   ##
==========================================
- Coverage   81.50%   81.32%   -0.19%     
==========================================
  Files         350      350              
  Lines       26846    26846              
==========================================
- Hits        21882    21832      -50     
- Misses       3778     3810      +32     
- Partials     1186     1204      +18     

see 18 files with indirect coverage changes

vet.sh is currently calling `grep -ev expr`. This is being interpreted as "grep
pattern 'v' in file 'expr'", instead of the intended "invert grep for pattern
'expr' in standard input". As a result:

- Most likely we see a line as follows on standard output:

```
+ noret_grep '(SA4000)' /tmp/tmp.xKUnikWsnw
+ grep '(SA4000)' /tmp/tmp.xKUnikWsnw
+ not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ [[ 1 == 1 ]]
grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory
```

and the process continues without error, but doesn't do what we want it to do.

- Occasionally, this causes a broken pipe on the first grep which results in an error:

```
+ noret_grep '(SA4000)' /tmp/tmp.BmSCFYnqgE
+ grep '(SA4000)' /tmp/tmp.BmSCFYnqgE
+ not grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
+ grep -ev 'crl.go:\d*:\d*: identical expressions on the left and right side of the '\''||'\'' operator (SA4000)'
grep: crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000): No such file or directory
grep: write error: Broken pipe
+ [[ 2 == 1 ]]
```
@atollena atollena force-pushed the vet-no-such-file-or-directory branch from 1b2bae6 to 22a5bf9 Compare July 17, 2024 11:18
@@ -121,7 +121,7 @@ XXXXX PleaseIgnoreUnused'

# Ignore a false positive when operands have side affectes.
# TODO(https://github.com/dominikh/go-tools/issues/54): Remove this once the issue is fixed in staticcheck.
noret_grep "(SA4000)" "${SC_OUT}" | not grep -ev "crl.go:\d*:\d*: identical expressions on the left and right side of the '||' operator (SA4000)"
noret_grep "(SA4000)" "${SC_OUT}" | not grep -v -e "crl.go:[0-9]\+:[0-9]\+: identical expressions on the left and right side of the '||' operator (SA4000)"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting errors with \d because it didn't match the lines, I think this is because GNU grep doesn't support \d by default.

Copy link
Member

@dfawley dfawley Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I pinged this bug in the TODO. It'd be nice to be able to just delete this stuff instead.

Maybe we can simplify this to just not grep -v "crl.go:" ? I don't think the rest of it helps.

@arvindbr8 arvindbr8 assigned atollena and unassigned arvindbr8 Jul 17, 2024
@arvindbr8 arvindbr8 merged commit 61aa949 into grpc:master Jul 17, 2024
13 checks passed
@atollena atollena deleted the vet-no-such-file-or-directory branch July 18, 2024 07:06
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
printchard pushed a commit to printchard/grpc-go that referenced this pull request Jul 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants