Skip to content

Commit 2e42cff

Browse files
blgmonsi
authored andcommitted
chore: fix some CodeQL warnings
CodeQL has flagged some warnings: 1) an interger conversion issue in progress_report.go 2) regexp without anchor in dependencies.go (1) should be fixed by changing the call to ParseInt(), and (2) can be implemented more simply by using substring matching, which will likely make the warning go away.
1 parent 10866d3 commit 2e42cff

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ginkgo/watch/dependencies.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ package watch
22

33
import (
44
"go/build"
5-
"regexp"
5+
"strings"
66
)
77

8-
var ginkgoAndGomegaFilter = regexp.MustCompile(`github\.com/onsi/ginkgo|github\.com/onsi/gomega`)
9-
var ginkgoIntegrationTestFilter = regexp.MustCompile(`github\.com/onsi/ginkgo/integration`) //allow us to integration test this thing
10-
118
type Dependencies struct {
129
deps map[string]int
1310
}
@@ -78,7 +75,7 @@ func (d Dependencies) resolveAndAdd(deps []string, depth int) {
7875
if err != nil {
7976
continue
8077
}
81-
if !pkg.Goroot && (!ginkgoAndGomegaFilter.MatchString(pkg.Dir) || ginkgoIntegrationTestFilter.MatchString(pkg.Dir)) {
78+
if !pkg.Goroot && (!matchesGinkgoOrGomega(pkg.Dir) || matchesGinkgoIntegration(pkg.Dir)) {
8279
d.addDepIfNotPresent(pkg.Dir, depth)
8380
}
8481
}
@@ -90,3 +87,11 @@ func (d Dependencies) addDepIfNotPresent(dep string, depth int) {
9087
d.deps[dep] = depth
9188
}
9289
}
90+
91+
func matchesGinkgoOrGomega(s string) bool {
92+
return strings.Contains(s, "github.com/onsi/ginkgo") || strings.Contains(s, "github.com/onsi/gomega")
93+
}
94+
95+
func matchesGinkgoIntegration(s string) bool {
96+
return strings.Contains(s, "github.com/onsi/ginkgo/integration") // allow us to integration test this thing
97+
}

internal/progress_report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func extractRunningGoroutines() ([]types.Goroutine, error) {
236236
}
237237
functionCall.Filename = line[:delimiterIdx]
238238
line = strings.Split(line[delimiterIdx+1:], " ")[0]
239-
lineNumber, err := strconv.ParseInt(line, 10, 64)
239+
lineNumber, err := strconv.ParseInt(line, 10, 32)
240240
functionCall.Line = int(lineNumber)
241241
if err != nil {
242242
return nil, types.GinkgoErrors.FailedToParseStackTrace(fmt.Sprintf("Invalid function call line number: %s\n%s", line, err.Error()))

0 commit comments

Comments
 (0)