Skip to content

Commit ada0c90

Browse files
Addressing lint warnings
1 parent 6b1305a commit ada0c90

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

utils/stats/stats.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,18 @@ func (rw *GenericResultsWriter) printJson() error {
238238
switch rw.data.(type) {
239239
case *ArtifactoryInfo:
240240
msg = "Artifacts: No Artifacts Available"
241-
break
242241
case *[]RepositoryDetails:
243242
msg = "Repositories: No Repository Available"
244-
break
245243
case *[]XrayPolicy:
246244
msg = "Policies: No Xray Policy Available"
247-
break
248245
case *[]XrayWatch:
249246
msg = "Watches: No Xray Watch Available"
250-
break
251247
case *[]Project:
252248
msg = "Projects: No Project Available"
253-
break
254249
case *[]JPD:
255250
msg = "JPDs: No JPD Available"
256-
break
257251
case *ReleaseBundleResponse:
258252
msg = "Release Bundles: No Release Bundle Info Available"
259-
break
260253
}
261254
jsonBytes, err = json.MarshalIndent(msg, "", " ")
262255
if err != nil {
@@ -296,7 +289,7 @@ func (rw *GenericResultsWriter) printTable() error {
296289
if apiErr, ok := v.(*clientStats.APIError); ok {
297290
printErrorTable(t, apiErr)
298291
} else {
299-
t.AppendRow(table.Row{"An unexpected error occurred: " + v.(error).Error()})
292+
log.Warn("Table format is not supported for this unknown data type.")
300293
}
301294
}
302295
t.Render()
@@ -386,7 +379,11 @@ func (rw *GenericResultsWriter) printSimple() error {
386379
case *[]RepositoryDetails:
387380
printRepositoriesSimple(v)
388381
default:
389-
printErrorMessage(rw.data.(*clientStats.APIError))
382+
if apiErr, ok := rw.data.(*clientStats.APIError); ok {
383+
printErrorMessage(apiErr)
384+
} else {
385+
log.Warn("An unexpected data type was received and cannot be printed as a detailed error.")
386+
}
390387
}
391388

392389
return nil
@@ -466,7 +463,6 @@ func printXrayPoliciesStats(policies *[]XrayPolicy) {
466463
log.Output("No Xray Policies Available")
467464
}
468465
log.Output()
469-
return
470466
}
471467

472468
func printXrayWatchesStats(watches *[]XrayWatch) {
@@ -478,7 +474,6 @@ func printXrayWatchesStats(watches *[]XrayWatch) {
478474
log.Output("No Xray Watches Available")
479475
}
480476
log.Output()
481-
return
482477
}
483478

484479
func printProjectsStats(projects *[]Project) {
@@ -490,7 +485,6 @@ func printProjectsStats(projects *[]Project) {
490485
log.Output("No Projects Available")
491486
}
492487
log.Output()
493-
return
494488
}
495489

496490
func printJPDsStats(jpdList *[]JPD) {
@@ -502,7 +496,6 @@ func printJPDsStats(jpdList *[]JPD) {
502496
log.Output("No JPDs Info Available")
503497
}
504498
log.Output()
505-
return
506499
}
507500

508501
func printErrorMessage(apiError *clientStats.APIError) {

0 commit comments

Comments
 (0)