-
-
Notifications
You must be signed in to change notification settings - Fork 335
Description
Please read the FAQ for the bug you encountered.
- I have read the existing FAQ
⏯ Playground Link
💻 Code
int main() { printf("Hello World\n"); return 0; }
🙁 Actual behavior
Windows is a case-insensitive filesystem but still assigns casing to folders. Paths on Windows are often treated case-insensitively by software as a result, but ast-grep treats the case-sensitively. This is causing problems for my usage, because I cannot effectively use ignores... inconsistent casing on CI/CD machines and other issues mostly beyond my control prevent me from having deterministic behavior of the rules.
I put together a repro, and the above playground link probably doesn't make sense without it.
Using this folder structure:
> coreutils du .
0 .\x\FooBar
0 .\x
0 .\y\foobar
0 .\y
0 .
I placed the same C file into each subfolder.
> echo 'int main() { printf("Hello World\n"); return 0; }' > .\y\foobar\main.c
> echo 'int main() { printf("Hello World\n"); return 0; }' > .\x\FooBar\main.c
Then, I scan with a rule that I expect to ignore both .c files:
> bat .\no_hello_world.yaml
───────┬──────────────────────────────────────────
│ File: .\no_hello_world.yaml
───────┼──────────────────────────────────────────
1 │ id: no_hello_world
2 │ language: c
3 │ message: "No hello worlds allowed!"
4 │ severity: error
5 │ rule:
6 │ kind: string_literal
7 │ regex: "Hello World"
8 │ ignores:
9 │ - "**/foobar/*.c"
───────┴──────────────────────────────────────────
> ast-grep scan --rule .\no_hello_world.yaml .
error[no_hello_world]: No hello worlds allowed!
┌─ x\FooBar\main.c:1:21
│
1 │ int main() { printf("Hello World\n"); return 0; }
│ ^^^^^^^^^^^^^^^
Error: 1 error(s) found in code.
Help: Scan succeeded and found error level diagnostics in the codebase.
🙂 Expected behavior
Expected behavior for most software on windows would be for the ignores rule to be applied case-insensitively. Would be great if this could be changed, and thanks for making ast-grep... we love this tool!
Additional information about the issue
No response