forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-15268] Check for go:generate parent dir references
Added a check to makefile basic-checks to verify go:generate directives create their mocks in the directory where they are being utilized, and not in their parent directories Change-Id: I1113826d07a63a8c5b985981ace64c24e4bb764f Signed-off-by: Brett Logan <[email protected]>
- Loading branch information
Brett Logan
authored and
Brett Logan
committed
May 10, 2019
1 parent
cfe491c
commit 3b511f4
Showing
5 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
gossip/mocks/security_advisor.go → gossip/api/mocks/security_advisor.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright IBM Corp All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Checks whether any files using go:generate directives make | ||
# references to their parent directories, instead of generating | ||
# the mock into the directory where it is being utilized | ||
echo "Checking for go:generate parent path references" | ||
OUTPUT="$(git ls-files "*.go" | grep -Ev 'vendor' | xargs grep 'go:generate.*\.\.')" | ||
if [[ -n "$OUTPUT" ]]; then | ||
echo "The following files contain references to parent directories in their go:generate directives." | ||
echo "Creating mocks in directories in which they are not used, can create errors that are not" | ||
echo "easily discoverable for code refactors that move the referenced code. It also implies that" | ||
echo "a mock for a remote interface is being defined in some place other that where it is being used" | ||
echo "It is best practice to generate the mock in the directory in which it will be used." | ||
echo "$OUTPUT" | ||
exit 1 | ||
fi |