Skip to content

Commit

Permalink
Fix linting tool
Browse files Browse the repository at this point in the history
Signed-off-by: thepetk <[email protected]>
  • Loading branch information
thepetk committed Jan 22, 2025
1 parent c3a5e4a commit fbf4cde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ lint: ## Run golangci-lint linter tool

.PHONY: lint_install
lint_install: ## Install golangci-lint linter tool
@# TODO(rm3l): recent versions of golangci-lint require Go >= 1.20. Update when we start using Go 1.20+
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
8 changes: 4 additions & 4 deletions test/apis/component_recognizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func TestPortDetectionFlaskStringValue(t *testing.T) {
func TestComponentDetectionNoResult(t *testing.T) {
components := getComponentsFromTestProject(t, "simple")
if len(components) > 0 {
t.Errorf("Expected 0 components but found " + strconv.Itoa(len(components)))
t.Errorf("Expected 0 components but found %v", strconv.Itoa(len(components)))
}
}

Expand Down Expand Up @@ -395,7 +395,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) {
components := getComponentsFromFiles(t, files, settings)

if len(components) != 1 {
t.Errorf("Expected 1 components but found " + strconv.Itoa(len(components)))
t.Errorf("Expected 1 components but found %v", strconv.Itoa(len(components)))
}

//now add a gitIgnore with a rule to exclude the only component found
Expand All @@ -413,15 +413,15 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) {
os.Remove(gitIgnorePath)

if len(componentsWithUpdatedGitIgnore) != 0 {
t.Errorf("Expected 0 components but found " + strconv.Itoa(len(componentsWithUpdatedGitIgnore)))
t.Errorf("Expected 0 components but found %v", strconv.Itoa(len(componentsWithUpdatedGitIgnore)))
}
}

func TestComponentDetectionMultiProjects(t *testing.T) {
components := getComponentsFromTestProject(t, "")
nComps := 70
if len(components) != nComps {
t.Errorf("Expected " + strconv.Itoa(nComps) + " components but found " + strconv.Itoa(len(components)))
t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/apis/language_recognizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func isLanguageInProject(t *testing.T, project string, wantedLanguage string, wa
}

if !hasWantedLanguage(languages, wantedLanguage, wantedTools, wantedFrameworks) {
t.Errorf("Project does not use " + wantedLanguage + " language")
t.Errorf("Project does not use %v language", wantedLanguage)
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/apis/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ func verifyComponents(t *testing.T, components []model.Component, expectedNumber
if hasComponents {
isExpectedComponent := strings.EqualFold(expectedLanguage, components[0].Languages[0].Name)
if !isExpectedComponent {
t.Errorf("Project does not use " + expectedLanguage + " language")
t.Errorf("Project does not use %v language ", expectedLanguage)
}
if expectedProjectName != "" {
isExpectedProjectName := strings.EqualFold(expectedProjectName, components[0].Name)
if !isExpectedProjectName {
t.Errorf("Main component has a different project name. Expected " + expectedProjectName + " but it was " + components[0].Name)
t.Errorf("Main component has a different project name. Expected %v but it was %v", expectedProjectName, components[0].Name)
}
}
} else {
t.Errorf("Expected " + strconv.Itoa(expectedNumber) + " of components but it was " + strconv.Itoa(len(components)))
t.Errorf("Expected %v of components but it was %v", strconv.Itoa(expectedNumber), strconv.Itoa(len(components)))
}
}

Expand All @@ -94,7 +94,7 @@ func testPortDetectionInProject(t *testing.T, project string, ports []int) {
}
}
if !found {
t.Errorf("Port " + strconv.Itoa(port) + " have not been detected")
t.Errorf("Port %v have not been detected", strconv.Itoa(port))
}
found = false
}
Expand Down

0 comments on commit fbf4cde

Please sign in to comment.