chore: apply some linter recommendations.

This commit is contained in:
Alexandre Pujol 2025-04-04 23:45:24 +02:00
parent 3b6b50cf63
commit 984cf28e61
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
37 changed files with 125 additions and 126 deletions

View file

@ -40,7 +40,7 @@ func init() {
func (s Stack) Apply(opt *Option, profile string) (string, error) {
if len(opt.ArgList) == 0 {
return "", fmt.Errorf("No profile to stack")
return "", fmt.Errorf("no profile to stack")
}
t := opt.ArgList[0]
if t != "X" {
@ -58,7 +58,7 @@ func (s Stack) Apply(opt *Option, profile string) (string, error) {
stackedProfile := prebuild.RootApparmord.Join(name).MustReadFileAsString()
m := regRules.FindStringSubmatch(stackedProfile)
if len(m) < 2 {
return "", fmt.Errorf("No profile found in %s", name)
return "", fmt.Errorf("no profile found in %s", name)
}
stackedRules := m[1]
stackedRules = regCleanStakedRules.Replace(stackedRules)
@ -68,9 +68,9 @@ func (s Stack) Apply(opt *Option, profile string) (string, error) {
// Insert the stacked profile at the end of the current profile, remove the stack directive
m := regEndOfRules.FindStringSubmatch(profile)
if len(m) <= 1 {
return "", fmt.Errorf("No end of rules found in %s", opt.File)
return "", fmt.Errorf("no end of rules found in %s", opt.File)
}
profile = strings.Replace(profile, m[0], res+m[0], -1)
profile = strings.Replace(profile, opt.Raw, "", -1)
profile = strings.ReplaceAll(profile, m[0], res+m[0])
profile = strings.ReplaceAll(profile, opt.Raw, "")
return profile, nil
}