Skip to content

Commit

Permalink
Warn on use of old option
Browse files Browse the repository at this point in the history
  • Loading branch information
smowton committed Oct 1, 2024
1 parent c9d6c80 commit d689db2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion go/extractor/configurebaseline/configurebaseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type BaselineConfig struct {
func GetConfigBaselineAsJSON(rootDir string) ([]byte, error) {
vendorDirs := make([]string, 0)

if util.IsVendorDirExtractionEnabled() {
extractVendorDirs, _ := util.IsVendorDirExtractionEnabled()
if extractVendorDirs {
// The user wants vendor directories scanned; emit an empty report.
} else {
filepath.WalkDir(rootDir, func(dirPath string, d fs.DirEntry, err error) error {
Expand Down
6 changes: 5 additions & 1 deletion go/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ func ExtractWithFlags(buildFlags []string, patterns []string, extractTests bool)

// If CODEQL_EXTRACTOR_GO_[OPTION_]EXTRACT_VENDOR_DIRS is "true", we extract `vendor` directories;
// otherwise (the default) is to exclude them from extraction
includeVendor := util.IsVendorDirExtractionEnabled()
includeVendor, oldOptionUsed := util.IsVendorDirExtractionEnabled()

if oldOptionUsed {
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.")
}

modeNotifications := make([]string, 0, 2)
if extractTests {
Expand Down
7 changes: 4 additions & 3 deletions go/extractor/util/extractvendordirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"os"
)

func IsVendorDirExtractionEnabled() bool {
return os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS") == "true" ||
os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS") == "true"
func IsVendorDirExtractionEnabled() (bool, bool) {
oldOptionVal := os.Getenv("CODEQL_EXTRACTOR_GO_EXTRACT_VENDOR_DIRS")
return (oldOptionVal == "true" ||
os.Getenv("CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_VENDOR_DIRS") == "true"), oldOptionVal != ""
}

0 comments on commit d689db2

Please sign in to comment.