diff --git a/.golangci.yaml b/.golangci.yaml index f5473b2b9..6861d253d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -11,3 +11,5 @@ linters: exclusions: paths: - pkg/paths + - tests/cmd/ + diff --git a/cmd/aa/main.go b/cmd/aa/main.go index 5f7dd6396..5d32e9331 100644 --- a/cmd/aa/main.go +++ b/cmd/aa/main.go @@ -111,7 +111,7 @@ func formatFile(kind kind, profile string) (string, error) { for idx, rules := range rulesByParagraph { aa.IndentationLevel = getIndentationLevel(paragraphs[idx]) rules = rules.Merge().Sort().Format() - profile = strings.Replace(profile, paragraphs[idx], rules.String()+"\n", -1) + profile = strings.ReplaceAll(profile, paragraphs[idx], rules.String()+"\n") } return profile, nil } diff --git a/pkg/aa/file.go b/pkg/aa/file.go index a43c56a4a..091f9436f 100644 --- a/pkg/aa/file.go +++ b/pkg/aa/file.go @@ -212,7 +212,7 @@ func (r *File) addLine(other Rule) bool { letterJ := getLetterIn(fileAlphabet, other.(*File).Path) groupI, ok1 := fileAlphabetGroups[letterI] groupJ, ok2 := fileAlphabetGroups[letterJ] - return letterI != letterJ && !(ok1 && ok2 && groupI == groupJ) + return letterI != letterJ && (!ok1 || !ok2 || groupI != groupJ) } type Link struct { diff --git a/pkg/aa/parse.go b/pkg/aa/parse.go index baf1a3718..e01696d74 100644 --- a/pkg/aa/parse.go +++ b/pkg/aa/parse.go @@ -286,10 +286,7 @@ func parseRule(str string) rule { res := make(rule, 0, len(str)/2) tokens := tokenizeRule(str) - inAare := false - if len(tokens) > 0 && (isAARE(tokens[0]) || tokens[0] == tokOWNER) { - inAare = true - } + inAare := len(tokens) > 0 && (isAARE(tokens[0]) || tokens[0] == tokOWNER) for idx, token := range tokens { switch { case token == tokEQUAL, token == tokPLUS+tokEQUAL, token == tokLESS+tokEQUAL: // Variable & Rlimit