From 562fa527ac6e1b6390b9e317dadc07149cb5c1c2 Mon Sep 17 00:00:00 2001 From: Danil Ovchinnikov Date: Fri, 9 Sep 2022 19:04:12 +0300 Subject: [PATCH] linter: loading only php files from embedded stubs --- src/cmd/main.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cmd/main.go b/src/cmd/main.go index 5bfddd23..cb5356fe 100644 --- a/src/cmd/main.go +++ b/src/cmd/main.go @@ -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) }