Skip to content

Commit 35c6b60

Browse files
Bump golangci/golangci-lint-action from 6.5.2 to 7.0.0 (home-assistant#228)
* Bump golangci/golangci-lint-action from 6.5.2 to 7.0.0 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.5.2 to 7.0.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v6.5.2...v7.0.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Migrate .golangci.yaml config * Address new linter errors --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Stefan Agner <stefan@agner.ch>
1 parent c73b192 commit 35c6b60

File tree

9 files changed

+69
-27
lines changed

9 files changed

+69
-27
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4.2.2
1313
- name: golangci-lint
14-
uses: golangci/golangci-lint-action@v6.5.2
14+
uses: golangci/golangci-lint-action@v7.0.0
1515
with:
1616
version: latest

.golangci.yaml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,48 @@
1+
version: "2"
12
linters:
2-
presets:
3-
- bugs
43
enable:
5-
- gosimple
6-
- ineffassign
7-
- unused
4+
- asasalint
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- contextcheck
9+
- durationcheck
10+
- errchkjson
11+
- errorlint
12+
- exhaustive
13+
- gocheckcompilerdirectives
14+
- gochecksumtype
15+
- gosec
16+
- gosmopolitan
17+
- loggercheck
18+
- makezero
19+
- musttag
20+
- nilerr
21+
- nilnesserr
22+
- noctx
23+
- protogetter
24+
- reassign
25+
- recvcheck
26+
- rowserrcheck
27+
- spancheck
28+
- sqlclosecheck
29+
- testifylint
30+
- zerologlint
31+
exclusions:
32+
generated: lax
33+
presets:
34+
- comments
35+
- common-false-positives
36+
- legacy
37+
- std-error-handling
38+
paths:
39+
- third_party$
40+
- builtin$
41+
- examples$
42+
formatters:
43+
exclusions:
44+
generated: lax
45+
paths:
46+
- third_party$
47+
- builtin$
48+
- examples$

apparmor/apparmor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (d apparmor) LoadProfile(profilePath string, cachePath string) (bool, *dbus
4747
cmd := exec.Command(appArmorParserCmd, "--replace", "--write-cache", "--cache-loc", cachePath, profilePath)
4848
out, err := cmd.CombinedOutput()
4949
if err != nil {
50-
return false, dbus.MakeFailedError(fmt.Errorf("Can't load profile '%s': %w", profilePath, err))
50+
return false, dbus.MakeFailedError(fmt.Errorf("can't load profile '%s': %w", profilePath, err))
5151
}
5252

5353
logging.Info.Printf("Load profile '%s': %s", profilePath, out)
@@ -61,7 +61,7 @@ func (d apparmor) UnloadProfile(profilePath string, cachePath string) (bool, *db
6161

6262
out, err := cmd.CombinedOutput()
6363
if err != nil {
64-
return false, dbus.MakeFailedError(fmt.Errorf("Can't unload profile '%s': %w", profilePath, err))
64+
return false, dbus.MakeFailedError(fmt.Errorf("can't unload profile '%s': %w", profilePath, err))
6565
}
6666

6767
logging.Info.Printf("Unload profile '%s': %s", profilePath, out)

boards/boards.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ func InitializeDBus(conn *dbus.Conn, board string) {
6969
logging.Info.Printf("Exposing object %s with interface %s ...", objectPath, ifaceName)
7070

7171
// Initialize the board
72-
if board == "Yellow" {
72+
switch board {
73+
case "Yellow":
7374
yellow.InitializeDBus(conn)
74-
} else if board == "Green" {
75+
case "Green":
7576
green.InitializeDBus(conn)
76-
} else if board == "Supervised" {
77+
case "Supervised":
7778
supervised.InitializeDBus(conn)
78-
} else {
79+
default:
7980
logging.Info.Printf("No specific Board features for %s", board)
8081
}
8182
}

cgroup/cgroup.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
3939
permissions := []string{permission}
4040
resources, err := CreateDeviceUpdateResources(permissions)
4141
if err != nil {
42-
error := fmt.Errorf("Error creating device resources for '%s': %w", containerID, err)
42+
error := fmt.Errorf("creating device resources for '%s' failed: %w", containerID, err)
4343
logging.Error.Printf("%s", error)
4444
return false, dbus.MakeFailedError(error)
4545
}
@@ -49,22 +49,22 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
4949
// Pass resources as OCI LinuxResources JSON object
5050
stdin, err := cmd.StdinPipe()
5151
if err != nil {
52-
error := fmt.Errorf("Error creating stdin pipe for '%s': %w", containerID, err)
52+
error := fmt.Errorf("creating stdin pipe for '%s' failed: %w", containerID, err)
5353
logging.Error.Printf("%s", error)
5454
return false, dbus.MakeFailedError(error)
5555
}
5656
enc := json.NewEncoder(stdin)
5757
err = enc.Encode(resources)
5858
if err != nil {
59-
error := fmt.Errorf("Error encoding JSON for '%s': %w", containerID, err)
59+
error := fmt.Errorf("encoding JSON for '%s' failed: %w", containerID, err)
6060
logging.Error.Printf("%s", error)
6161
return false, dbus.MakeFailedError(error)
6262
}
6363
stdin.Close()
6464

6565
stdoutStderr, err := cmd.CombinedOutput()
6666
if err != nil {
67-
error := fmt.Errorf("Error calling runc for '%s': %w, output %s", containerID, err, stdoutStderr)
67+
error := fmt.Errorf("calling runc for '%s' failed: %w, output %s", containerID, err, stdoutStderr)
6868
logging.Error.Printf("%s", error)
6969
return false, dbus.MakeFailedError(error)
7070
} else {
@@ -77,25 +77,25 @@ func (d cgroup) AddDevicesAllowed(containerID string, permission string) (bool,
7777
// Make sure path is relative to cgroupFSDockerDevices
7878
allowedFile, err := securejoin.SecureJoin(cgroupFSDockerDevices, containerID+string(filepath.Separator)+"devices.allow")
7979
if err != nil {
80-
return false, dbus.MakeFailedError(fmt.Errorf("Security issues with '%s': %w", containerID, err))
80+
return false, dbus.MakeFailedError(fmt.Errorf("security issues with '%s': %w", containerID, err))
8181
}
8282

8383
// Check if file/container exists
8484
_, err = os.Stat(allowedFile)
8585
if os.IsNotExist(err) {
86-
return false, dbus.MakeFailedError(fmt.Errorf("Can't find Container '%s' for adjust CGroup devices.", containerID))
86+
return false, dbus.MakeFailedError(fmt.Errorf("can't find Container '%s' for adjust CGroup devices", containerID))
8787
}
8888

8989
// Write permission adjustments
9090
file, err := os.Create(allowedFile)
9191
if err != nil {
92-
return false, dbus.MakeFailedError(fmt.Errorf("Can't open CGroup devices '%s': %w", allowedFile, err))
92+
return false, dbus.MakeFailedError(fmt.Errorf("can't open CGroup devices '%s': %w", allowedFile, err))
9393
}
9494
defer file.Close()
9595

9696
_, err = file.WriteString(permission + "\n")
9797
if err != nil {
98-
return false, dbus.MakeFailedError(fmt.Errorf("Can't write CGroup permission '%s': %w", permission, err))
98+
return false, dbus.MakeFailedError(fmt.Errorf("can't write CGroup permission '%s': %w", permission, err))
9999
}
100100

101101
logging.Info.Printf("Permission '%s', granted for Container '%s' via CGroup devices.allow", permission, containerID)

datadisk/datadisk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func GetDataMount() (*mountinfo.Mountinfo, error) {
3232
return &info, nil
3333
}
3434
}
35-
return nil, errors.New("Can't find a data mount!")
35+
return nil, errors.New("can't find a data mount")
3636
}
3737

3838
type datadisk struct {
@@ -66,7 +66,7 @@ func (d datadisk) ChangeDevice(newDevice string) (bool, *dbus.Error) {
6666

6767
logging.Info.Printf("Data partition is currently on device %s.", *dataDevice)
6868
if *dataDevice == newDevice {
69-
return false, dbus.MakeFailedError(fmt.Errorf("Current data device \"%s\" the same as target device. Aborting.", *dataDevice))
69+
return false, dbus.MakeFailedError(fmt.Errorf("current data device \"%s\" the same as target device", *dataDevice))
7070
}
7171

7272
err = udisks2helper.PartitionDeviceWithSinglePartition(newDevice, linuxDataPartitionUUID, "hassos-data-external")
@@ -101,7 +101,7 @@ func InitializeDBus(conn *dbus.Conn) {
101101

102102
// Try to read the current data mount point
103103
mountInfo, err := GetDataMount()
104-
var currentDisk string = ""
104+
var currentDisk = ""
105105
if err != nil {
106106
logging.Warning.Print(err)
107107
} else {

udisks2/apiutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (m *Manager) ResolveDeviceFromLabel(label string) (*dbus.ObjectPath, error)
4444
return nil, err
4545
}
4646
if len(blockObjects) != 1 {
47-
return nil, fmt.Errorf("Expected single block device with file system label \"%s\", found %d", label, len(blockObjects))
47+
return nil, fmt.Errorf("expected single block device with file system label \"%s\", found %d", label, len(blockObjects))
4848
}
4949

5050
/* Get Partition object of the data partition */

udisks2/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (u UDisks2Helper) FormatPartitionFromDevicePath(devicePath string, fsType s
7575
return err
7676
}
7777
if len(blockObjects) != 1 {
78-
return fmt.Errorf("Expected single block device with device path \"%s\", found %d", devicePath, len(blockObjects))
78+
return fmt.Errorf("expected single block device with device path \"%s\", found %d", devicePath, len(blockObjects))
7979
}
8080

8181
logging.Info.Printf("Formatting block device %s with file system \"%s\".", devicePath, fsType)
@@ -99,7 +99,7 @@ func (u UDisks2Helper) PartitionDeviceWithSinglePartition(devicePath string, uui
9999
return err
100100
}
101101
if len(blockObjects) != 1 {
102-
return fmt.Errorf("Expected single block device with device path \"%s\", found %d", devicePath, len(blockObjects))
102+
return fmt.Errorf("expected single block device with device path \"%s\", found %d", devicePath, len(blockObjects))
103103
}
104104

105105
blockObjectPath := blockObjects[0]

utils/bootfile/editor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (e Editor) SetOption(optionName string, value string) error {
7878
fileScanner.Split(bufio.ScanLines)
7979

8080
var outLines []string
81-
var found bool = false
81+
var found = false
8282
for fileScanner.Scan() {
8383
line := fileScanner.Text()
8484
if strings.HasPrefix(line, optionName) || strings.HasPrefix(line, "#"+optionName) {

0 commit comments

Comments
 (0)