Skip to content

Commit d689db2

Browse files
committed
Warn on use of old option
1 parent c9d6c80 commit d689db2

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

go/extractor/configurebaseline/configurebaseline.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ type BaselineConfig struct {
2828
func GetConfigBaselineAsJSON(rootDir string) ([]byte, error) {
2929
vendorDirs := make([]string, 0)
3030

31-
if util.IsVendorDirExtractionEnabled() {
31+
extractVendorDirs, _ := util.IsVendorDirExtractionEnabled()
32+
if extractVendorDirs {
3233
// The user wants vendor directories scanned; emit an empty report.
3334
} else {
3435
filepath.WalkDir(rootDir, func(dirPath string, d fs.DirEntry, err error) error {

go/extractor/extractor.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)
8383

8484
// If CODEQL_EXTRACTOR_GO_[OPTION_]EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
8585
// otherwise (the default) is to exclude them from extraction
86-
includeVendor := util.IsVendorDirExtractionEnabled()
86+
includeVendor, oldOptionUsed := util.IsVendorDirExtractionEnabled()
87+
88+
if oldOptionUsed {
89+
log.Println("Warning: obsolete option \"CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS\" was set. Use \"CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS\" or pass `--extractor-option extract_vendor_dirs=true` instead.")
90+
}
8791

8892
modeNotifications := make([]string, 0, 2)
8993
if extractTests {

go/extractor/util/extractvendordirs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import (
44
"os"
55
)
66

7-
func IsVendorDirExtractionEnabled() bool {
8-
return os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS") == "true" ||
9-
os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS") == "true"
7+
func IsVendorDirExtractionEnabled() (bool, bool) {
8+
oldOptionVal := os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS")
9+
return (oldOptionVal == "true" ||
10+
os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS") == "true"), oldOptionVal != ""
1011
}

0 commit comments

Comments
 (0)