Skip to content

[bug] --globs flag not working with scan #1842

@jorgezreik

Description

@jorgezreik

Please read the FAQ for the bug you encountered.

  • I have read the existing FAQ

⏯ Playground Link

(Not too relevant, as this is a bug with the CLI)

https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6ImphdmFzY3JpcHQiLCJxdWVyeSI6IjxkaXY+JE1BVENIPC9kaXY+IiwicmV3cml0ZSI6IiIsInN0cmljdG5lc3MiOiJzbWFydCIsInNlbGVjdG9yIjoiIiwiY29uZmlnIjoiaWQ6IGNvbnNvbGUtbG9nXG5sYW5ndWFnZTogSmF2YVNjcmlwdFxucnVsZTpcbiAgcGF0dGVybjogY29uc29sZS5sb2ciLCJzb3VyY2UiOiJjb25zb2xlLmxvZyhcIkhlbGxvIFdvcmxkIVwiKSJ9

💻 Code

Command

sg scan --inline-rules '
id: console-log
language: JavaScript
rule:
  pattern: console.log
' --globs 'not-real.js'

Code

// in file1.js
console.log("Hello World")
// in file2.js
console.log("Hello World")

🙁 Actual behavior

Matches in both files are returned. This is incorrect as the glob pattern should not match either file.

🙂 Expected behavior

No matches are returned, as the glob pattern does not match either file.

Additional information about the issue

It is as if the --globs option has no effect on the scan command.

In addition, specifying only one of the two files, or excluding files using globs that begin with ! also don't seem to work.

This is reproducible when passing a rule from a file as well.

Running ast-grep 0.35.0, as returned by sg -V.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions