lint: enalble linter "wastedassign" (#2772)
This commit is contained in:
parent
4b8e6cd780
commit
f75cdeb239
7 changed files with 10 additions and 21 deletions
|
@ -295,10 +295,6 @@ issues:
|
|||
- nosprintfhostport
|
||||
text: "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf"
|
||||
|
||||
- linters:
|
||||
- wastedassign
|
||||
text: "assigned to .*, but reassigned without using the value"
|
||||
|
||||
# https://github.com/timakin/bodyclose
|
||||
- linters:
|
||||
- bodyclose
|
||||
|
|
|
@ -71,8 +71,7 @@ func SourceFromAlert(alert *models.Alert) string {
|
|||
|
||||
//try to compose a human friendly version
|
||||
if *alert.Source.Value != "" && *alert.Source.Scope != "" {
|
||||
scope := ""
|
||||
scope = fmt.Sprintf("%s:%s", *alert.Source.Scope, *alert.Source.Value)
|
||||
scope := fmt.Sprintf("%s:%s", *alert.Source.Scope, *alert.Source.Value)
|
||||
extra := ""
|
||||
if alert.Source.Cn != "" {
|
||||
extra = alert.Source.Cn
|
||||
|
|
|
@ -188,10 +188,9 @@ func (cli cliExplain) run(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
}()
|
||||
tmpFile := ""
|
||||
// we create a temporary log file if a log line/stdin has been provided
|
||||
if logLine != "" || logFile == "-" {
|
||||
tmpFile = filepath.Join(dir, "cscli_test_tmp.log")
|
||||
tmpFile := filepath.Join(dir, "cscli_test_tmp.log")
|
||||
f, err = os.Create(tmpFile)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -179,11 +179,9 @@ func (r *AppsecRunner) AccumulateTxToEvent(evt *types.Event, req *appsec.ParsedR
|
|||
|
||||
req.Tx.Variables().All(func(v variables.RuleVariable, col collection.Collection) bool {
|
||||
for _, variable := range col.FindAll() {
|
||||
key := ""
|
||||
if variable.Key() == "" {
|
||||
key = variable.Variable().Name()
|
||||
} else {
|
||||
key = variable.Variable().Name() + "." + variable.Key()
|
||||
key := variable.Variable().Name()
|
||||
if variable.Key() != "" {
|
||||
key += "." + variable.Key()
|
||||
}
|
||||
if variable.Value() == "" {
|
||||
continue
|
||||
|
@ -214,7 +212,7 @@ func (r *AppsecRunner) AccumulateTxToEvent(evt *types.Event, req *appsec.ParsedR
|
|||
evt.Appsec.HasOutBandMatches = true
|
||||
}
|
||||
|
||||
name := ""
|
||||
var name string
|
||||
version := ""
|
||||
hash := ""
|
||||
ruleNameProm := fmt.Sprintf("%d", rule.Rule().ID())
|
||||
|
|
|
@ -77,14 +77,11 @@ func formatAlertSource(alert *models.Alert) string {
|
|||
func formatAlertAsString(machineID string, alert *models.Alert) []string {
|
||||
src := formatAlertSource(alert)
|
||||
|
||||
/**/
|
||||
msg := ""
|
||||
msg := "empty scenario"
|
||||
if alert.Scenario != nil && *alert.Scenario != "" {
|
||||
msg = *alert.Scenario
|
||||
} else if alert.Message != nil && *alert.Message != "" {
|
||||
msg = *alert.Message
|
||||
} else {
|
||||
msg = "empty scenario"
|
||||
}
|
||||
|
||||
reason := fmt.Sprintf("%s by %s", msg, src)
|
||||
|
@ -116,7 +113,7 @@ func formatAlertAsString(machineID string, alert *models.Alert) []string {
|
|||
reason = fmt.Sprintf("%s for %d/%d decisions", msg, i+1, len(alert.Decisions))
|
||||
}
|
||||
|
||||
machineIDOrigin := ""
|
||||
var machineIDOrigin string
|
||||
if machineID == "" {
|
||||
machineIDOrigin = *decisionItem.Origin
|
||||
} else {
|
||||
|
|
|
@ -107,7 +107,7 @@ func (p *ParserAssert) AssertFile(testFile string) error {
|
|||
}
|
||||
|
||||
match := variableRE.FindStringSubmatch(scanner.Text())
|
||||
variable := ""
|
||||
var variable string
|
||||
|
||||
if len(match) == 0 {
|
||||
log.Infof("Couldn't get variable of line '%s'", scanner.Text())
|
||||
|
|
|
@ -319,7 +319,7 @@ func Parse(ctx UnixParserCtx, xp types.Event, nodes []Node) (types.Event, error)
|
|||
}
|
||||
clog.Tracef("node (%s) ret : %v", node.rn, ret)
|
||||
if ParseDump {
|
||||
parserIdxInStage := 0
|
||||
var parserIdxInStage int
|
||||
StageParseMutex.Lock()
|
||||
if len(StageParseCache[stage][node.Name]) == 0 {
|
||||
StageParseCache[stage][node.Name] = make([]dumps.ParserResult, 0)
|
||||
|
|
Loading…
Reference in a new issue