From 0bfc58280834c898c51218e4bb4b94fe0c7b3e86 Mon Sep 17 00:00:00 2001 From: Fabian Reh Date: Wed, 7 Apr 2021 10:11:17 +0200 Subject: [PATCH] simplify parameters Signed-off-by: Fabian Reh --- cmd/checkmarxExecuteScan.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/checkmarxExecuteScan.go b/cmd/checkmarxExecuteScan.go index d7dcf4ee5..dc67f6ab0 100644 --- a/cmd/checkmarxExecuteScan.go +++ b/cmd/checkmarxExecuteScan.go @@ -35,11 +35,8 @@ type checkmarxExecuteScanUtils interface { PathMatch(pattern, name string) (bool, error) } -type checkmarxExecuteScanUtilsBundle struct{} - -func newCheckmarxExecuteScanUtils() checkmarxExecuteScanUtils { - utils := checkmarxExecuteScanUtilsBundle{} - return &utils +type checkmarxExecuteScanUtilsBundle struct { + workspace string } func (checkmarxExecuteScanUtilsBundle) PathMatch(pattern, name string) (bool, error) { @@ -79,13 +76,14 @@ func checkmarxExecuteScan(config checkmarxExecuteScanOptions, _ *telemetry.Custo log.Entry().WithError(err).Fatalf("Failed to create Checkmarx client talking to URL %v", config.ServerURL) } influx.step_data.fields.checkmarx = false - if err := runScan(config, sys, "./", influx, newCheckmarxExecuteScanUtils()); err != nil { + utils := checkmarxExecuteScanUtilsBundle{workspace: "./"} + if err := runScan(config, sys, influx, utils); err != nil { log.Entry().WithError(err).Fatal("Failed to execute Checkmarx scan.") } influx.step_data.fields.checkmarx = true } -func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, workspace string, influx *checkmarxExecuteScanInflux, utils checkmarxExecuteScanUtils) error { +func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, influx *checkmarxExecuteScanInflux, utils checkmarxExecuteScanUtilsBundle) error { teamID := config.TeamID if len(teamID) == 0 { team, err := loadTeam(sys, config.TeamName) @@ -131,7 +129,7 @@ func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, workspace } } - err = uploadAndScan(config, sys, project, workspace, influx, utils) + err = uploadAndScan(config, sys, project, utils.workspace, influx, utils) if err != nil { return errors.Wrap(err, "failed to run scan and upload result") }