-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: warn when it looks like you're using ignore instead of exclude …
…directive (#1955) **What type of PR is this?** Feature **What package or component does this PR mostly affect?** all **What does this PR do? Why is it needed?** `ignore` and `exclude` are somewhat confusing directive names, and are easily mixed up. Show a warning when using the `gazelle:ignore` directive with an argument. I've seen many places where people do something like `# gazelle:ignore testdata` and accidentally disable gazelle for the entire directory and subdirectories. This can be seen in [many public github repos](https://github.com/search?q=%2F%23+gazelle%3Aignore+.%2F+language%3AStarlark&type=code&l=Starlark). **Other notes for review** Add a new generated test directory to assert that the warning is shown correctly.
- Loading branch information
1 parent
8bbeae7
commit 186dedd
Showing
10 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
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 @@ | ||
# Gazelle warns on invalid directive use |
Empty file.
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,2 @@ | ||
-lang | ||
nolang |
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 @@ | ||
0 |
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 @@ | ||
gazelle: the ignore directive does not take any arguments. Did you mean to use gazelle:exclude instead? in //ignore_directive '# gazelle:ignore *.go' |
4 changes: 4 additions & 0 deletions
4
tests/warns_on_invalid_directive_use/ignore_directive/BUILD.in
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,4 @@ | ||
# gazelle:ignore *.go | ||
|
||
# valid use, but trailing whitespace should not warn | ||
# gazelle:ignore |
4 changes: 4 additions & 0 deletions
4
tests/warns_on_invalid_directive_use/ignore_directive/BUILD.out
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,4 @@ | ||
# gazelle:ignore *.go | ||
|
||
# valid use, but trailing whitespace should not warn | ||
# gazelle:ignore |
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