Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Nov 27, 2023
1 parent fb1797b commit d1dc764
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cmd/crowdsec-cli/item_suggest.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
)

const MaxDistance = 7
// suggestNearestMessage returns a message with the most similar item name, if one is found
func suggestNearestMessage(hub *cwhub.Hub, itemType string, itemName string) string {
const maxDistance = 7

// SuggestNearestMessage returns a message with the most similar item name, if one is found
func SuggestNearestMessage(hub *cwhub.Hub, itemType string, itemName string) string {
score := 100
nearest := ""

Expand All @@ -29,7 +29,7 @@ func SuggestNearestMessage(hub *cwhub.Hub, itemType string, itemName string) str

msg := fmt.Sprintf("can't find '%s' in %s", itemName, itemType)

if score < MaxDistance {
if score < maxDistance {
msg += fmt.Sprintf(", did you mean '%s'?", nearest)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec-cli/itemcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func itemsInstallRunner(it hubItemType) func(cmd *cobra.Command, args []string)
for _, name := range args {
item := hub.GetItem(it.name, name)
if item == nil {
msg := SuggestNearestMessage(hub, it.name, name)
msg := suggestNearestMessage(hub, it.name, name)
if !ignoreError {
return fmt.Errorf(msg)
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/crowdsec-cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import (
)

func printHelp(cmd *cobra.Command) {
err := cmd.Help()
if err != nil {
if err := cmd.Help(); err != nil {
log.Fatalf("unable to print help(): %s", err)
}
}

func manageCliDecisionAlerts(ip *string, ipRange *string, scope *string, value *string) error {

/*if a range is provided, change the scope*/
if *ipRange != "" {
_, _, err := net.ParseCIDR(*ipRange)
Expand Down Expand Up @@ -50,7 +48,6 @@ func manageCliDecisionAlerts(ip *string, ipRange *string, scope *string, value *
}

func getDBClient() (*database.Client, error) {
var err error
if err := csConfig.LoadAPIServer(); err != nil || csConfig.DisableAPI {
return nil, err
}
Expand Down

0 comments on commit d1dc764

Please sign in to comment.