Skip to content

Commit

Permalink
fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
BenAlvo1 committed Nov 21, 2024
1 parent fd7ac2a commit 4248dcc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions internal/services/asca.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ func findASCAPort() (int, error) {
return 0, err
}
viper.Set(params.ASCAPortKey, port)
err = configuration.WriteSingleConfigKey(params.ASCAPortKey, port)
if err != nil {
logger.PrintfIfVerbose("Error writing ASCA port to config file: %v", err)
}
configuration.WriteSingleConfigKey(params.ASCAPortKey, port)
return port, nil
}

Expand Down
14 changes: 8 additions & 6 deletions internal/wrappers/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/user"
"strings"

"github.com/checkmarx/ast-cli/internal/logger"
"github.com/checkmarx/ast-cli/internal/params"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -129,28 +130,29 @@ func LoadConfiguration() {
_ = viper.ReadInConfig()
}

func WriteSingleConfigKey(key string, value int) error {
func WriteSingleConfigKey(key string, value int) {
// Get the configuration file path
fullPath, err := getConfigFilePath()
if err != nil {
return fmt.Errorf("failed to get config file path: %w", err)
logger.PrintfIfVerbose("failed to get config file path: %w", err)

Check failure on line 137 in internal/wrappers/configuration/configuration.go

View workflow job for this annotation

GitHub Actions / lint

printf: github.com/checkmarx/ast-cli/internal/logger.PrintfIfVerbose does not support error-wrapping directive %w (govet)
return
}

// Load existing configuration or initialize a new one
config, err := loadConfig(fullPath)
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
logger.PrintfIfVerbose("failed to load config: %w", err)

Check failure on line 144 in internal/wrappers/configuration/configuration.go

View workflow job for this annotation

GitHub Actions / lint

printf: github.com/checkmarx/ast-cli/internal/logger.PrintfIfVerbose does not support error-wrapping directive %w (govet)
return
}

// Update the configuration key
config[key] = value

// Save the updated configuration back to the file
if err := saveConfig(fullPath, config); err != nil {
return fmt.Errorf("failed to save config: %w", err)
logger.PrintfIfVerbose("failed to save config: %w", err)

Check failure on line 153 in internal/wrappers/configuration/configuration.go

View workflow job for this annotation

GitHub Actions / lint

printf: github.com/checkmarx/ast-cli/internal/logger.PrintfIfVerbose does not support error-wrapping directive %w (govet)
return
}

return nil
}

// loadConfig loads the configuration from a file. If the file does not exist, it returns an empty map.
Expand Down

0 comments on commit 4248dcc

Please sign in to comment.