Skip to content

Commit

Permalink
linter: loading only php files from embedded stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil42Russia authored and Hidanio committed Dec 19, 2024
1 parent 9f0fd73 commit 3234f8f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,30 @@ func LoadEmbeddedStubs(l *linter.Linter, filenames []string) error {
}

func loadEmbeddedStubs(l *linter.Linter) error {
var filenames []string
var stubsFilenames []string
// NOVERIFYDEBUG_LOAD_STUBS is used in golden tests to specify
// the test dependencies that need to be loaded.
if list := os.Getenv("NOVERIFYDEBUG_LOAD_STUBS"); list != "" {
filenames = strings.Split(list, ",")
stubsFilenames = strings.Split(list, ",")
} else {
filenames = stubs.AssetNames()
stubsFilenames = stubs.AssetNames()
}
if len(filenames) == 0 {

if len(stubsFilenames) == 0 {
return fmt.Errorf("empty file list")
}

extensions := l.Config().PhpExtensions
extensions = append(extensions, "php")

var filenames []string
for _, filename := range stubsFilenames {
for _, extension := range extensions {
if strings.HasSuffix(filename, extension) {
filenames = append(filenames, filename)
}
}
}

return LoadEmbeddedStubs(l, filenames)
}

0 comments on commit 3234f8f

Please sign in to comment.