Skip to content

Commit a2cf640

Browse files
committed
Fix golangci-lint issues in buildinfo.go
- Replace if-else chain with switch statement for artifact type determination (gocritic) - Remove unused buildConfiguration parameter from collectDeployedMavenArtifacts function (unparam) - Update function call to match new signature Resolves golangci-lint warnings while maintaining functionality.
1 parent 196ef2c commit a2cf640

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

maven_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const localRepoSystemProperty = "-Dmaven.repo.local="
4747

4848
var localRepoDir string
4949

50-
5150
func cleanMavenTest(t *testing.T) {
5251
clientTestUtils.UnSetEnvAndAssert(t, coreutils.HomeDir)
5352
deleteFilesFromRepo(t, tests.MvnRepo1)

utils/buildinfo/buildinfo.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func GetMavenBuildInfo(workingDir string, buildConfiguration *buildUtils.BuildCo
164164
len(buildInfo.Modules[0].Dependencies)))
165165

166166
// Now collect artifacts that Maven deployed natively (true native approach)
167-
err = collectDeployedMavenArtifacts(buildInfo, workingDir, buildConfiguration)
167+
err = collectDeployedMavenArtifacts(buildInfo, workingDir)
168168
if err != nil {
169169
log.Warn("Failed to collect deployed Maven artifacts: " + err.Error())
170170
// Continue anyway - dependencies are more important than artifacts
@@ -525,7 +525,7 @@ func collectPoetryBuildInfo(workingDir, buildName, buildNumber string, serverDet
525525
}
526526

527527
// collectDeployedMavenArtifacts collects artifacts that Maven deployed natively
528-
func collectDeployedMavenArtifacts(buildInfo *buildinfo.BuildInfo, workingDir string, buildConfiguration *buildUtils.BuildConfiguration) error {
528+
func collectDeployedMavenArtifacts(buildInfo *buildinfo.BuildInfo, workingDir string) error {
529529
log.Info("Collecting artifacts deployed by native Maven...")
530530

531531
// Look for artifacts in target directory (what Maven built)
@@ -584,17 +584,18 @@ func collectDeployedMavenArtifacts(buildInfo *buildinfo.BuildInfo, workingDir st
584584
continue
585585
}
586586

587-
// Determine artifact type
588-
artifactType := "jar" // Default
589-
if strings.HasSuffix(pattern, ".war") {
590-
artifactType = "war"
591-
} else if strings.HasSuffix(pattern, ".ear") {
592-
artifactType = "ear"
593-
} else if strings.HasSuffix(pattern, "-sources.jar") {
594-
artifactType = "java-source-jar"
595-
} else if strings.HasSuffix(pattern, "-javadoc.jar") {
596-
artifactType = "javadoc"
597-
}
587+
// Determine artifact type
588+
artifactType := "jar" // Default
589+
switch {
590+
case strings.HasSuffix(pattern, ".war"):
591+
artifactType = "war"
592+
case strings.HasSuffix(pattern, ".ear"):
593+
artifactType = "ear"
594+
case strings.HasSuffix(pattern, "-sources.jar"):
595+
artifactType = "java-source-jar"
596+
case strings.HasSuffix(pattern, "-javadoc.jar"):
597+
artifactType = "javadoc"
598+
}
598599

599600
// Create artifact entry with path where Maven deployed it
600601
artifact := buildinfo.Artifact{

0 commit comments

Comments
 (0)