Skip to content

Commit 71d9c6c

Browse files
author
Lorenz Kästle
committed
make golangci-lint happy
1 parent 148b7ec commit 71d9c6c

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

cmd/fileContent.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"bufio"
5+
"errors"
56
"fmt"
67
"os"
78
"path"
@@ -55,6 +56,7 @@ func PathEvaluation(path string, config fileContent.FileContentconfig) (*result.
5556
return nil, err
5657
}
5758

59+
// nolint: nestif
5860
if fileInfo.IsDir() {
5961
// Input path is a directory
6062
// apply conditions for all files inside
@@ -100,7 +102,10 @@ func PathEvaluation(path string, config fileContent.FileContentconfig) (*result.
100102
return EvaluateFile(path, config)
101103
}
102104

103-
func EvaluateFile(path string, config fileContent.FileContentconfig) (*result.PartialResult, error) {
105+
// EvaluateFile receives a path and some evaluation parameters
106+
// and applies the conditions to the file content
107+
// nolint: gocognit,gocyclo
108+
func EvaluateFile(path string, config fileContent.FileContentconfig) (*result.PartialResult, error) { // nolint: gocognit
104109
evaluationResult := result.NewPartialResult()
105110
evaluationResult.SetDefaultState(check.OK)
106111

@@ -109,6 +114,7 @@ func EvaluateFile(path string, config fileContent.FileContentconfig) (*result.Pa
109114

110115
// Evaluation
111116
// -- Pattern matching in file
117+
// nolint: nestif
112118
if (len(config.OKPatterns) != 0) || (len(config.WarningPatterns) != 0) || (len(config.CriticalPatterns) != 0) || config.MetricPattern.IsSet {
113119
// Pattern matching priority:
114120
// if Critical > Warning > OK
@@ -169,7 +175,7 @@ func EvaluateFile(path string, config fileContent.FileContentconfig) (*result.Pa
169175
matchSlice := config.MetricPattern.Regex.FindStringSubmatch(scanner.Text())
170176

171177
if matchSlice == nil {
172-
check.ExitError(fmt.Errorf("Metrix Regex submatch failed somehow"))
178+
check.ExitError(errors.New("metrix regex submatch failed somehow"))
173179
}
174180

175181
metric, err = strconv.ParseFloat(matchSlice[1], 64)
@@ -204,6 +210,7 @@ func EvaluateFile(path string, config fileContent.FileContentconfig) (*result.Pa
204210
// ok we found something
205211
scPattern.SetOutput("Found pattern \"" + patternFound.String() + "\"")
206212

213+
// nolint: gocritic
207214
if foundCriticalPattern {
208215
scPattern.SetState(check.Critical)
209216
} else if foundWarningPattern {

internal/common/status/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package status
33
import (
44
"fmt"
55
"strconv"
6+
67
// "strings"
78

89
"github.com/NETWAYS/go-check"

0 commit comments

Comments
 (0)