Fix more golangci-lint warnings and update its config, bump required version of go compiler to 1.24.2
This commit is contained in:
@@ -11,11 +11,11 @@ import (
|
||||
// UpdateBatteryInfo updates info about battery charge.
|
||||
func (c *MyConfig) UpdateBatteryInfo() {
|
||||
var (
|
||||
ch int
|
||||
status string
|
||||
Batts string
|
||||
InitialDelay time.Duration = 100 * time.Millisecond
|
||||
LoopIterationDelay time.Duration = 5 * time.Second
|
||||
ch int
|
||||
status string
|
||||
Batts string
|
||||
InitialDelay = 100 * time.Millisecond
|
||||
LoopIterationDelay = 5 * time.Second
|
||||
)
|
||||
|
||||
Delay := InitialDelay
|
||||
@@ -30,7 +30,7 @@ func (c *MyConfig) UpdateBatteryInfo() {
|
||||
batteries, _ := battery.GetAll()
|
||||
// In theory, this module should give for each entry its separate err, but in practice it gives
|
||||
// one single err for all entries, so we cannot detemine whist exatly entry errored.
|
||||
|
||||
|
||||
var (
|
||||
battsInfo string
|
||||
chStr string
|
||||
|
||||
@@ -252,7 +252,7 @@ type MyConfig struct {
|
||||
|
||||
// readConf reads and validates config if config does not exist, it puts default config to the same dir where i3 config
|
||||
// is located.
|
||||
func ReadConf(DefaultConfig []byte) (*MyConfig, error) {
|
||||
func ReadConf(defaultConfig []byte) (*MyConfig, error) {
|
||||
var (
|
||||
path string
|
||||
config *MyConfig
|
||||
@@ -272,7 +272,7 @@ func ReadConf(DefaultConfig []byte) (*MyConfig, error) {
|
||||
// about it for now.
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
buf = DefaultConfig
|
||||
buf = defaultConfig
|
||||
|
||||
if err := os.WriteFile(path, buf, 0644); err != nil {
|
||||
return config, err
|
||||
@@ -283,7 +283,7 @@ func ReadConf(DefaultConfig []byte) (*MyConfig, error) {
|
||||
} else {
|
||||
// Config file looks too long for config...
|
||||
if fileInfo.Size() > 65535 {
|
||||
err := fmt.Errorf("config file %s is too long for config", path) //nolint: goerr113
|
||||
err := fmt.Errorf("config file %s is too long for config", path) //nolint: err113
|
||||
|
||||
return config, err
|
||||
}
|
||||
@@ -1530,13 +1530,11 @@ func ReadConf(DefaultConfig []byte) (*MyConfig, error) {
|
||||
for num, app := range sampleConfig.Apps {
|
||||
// app.Instance can be missing.
|
||||
// app.Class can be missing.
|
||||
|
||||
if app.Name == "" {
|
||||
app.Name = fmt.Sprintf("app%d", num)
|
||||
}
|
||||
|
||||
// app.Args can be empty slice. In that case command will be run without aruments.
|
||||
|
||||
if app.Cmd == "" {
|
||||
app.Cmd = "true"
|
||||
}
|
||||
@@ -1557,12 +1555,11 @@ func ReadConf(DefaultConfig []byte) (*MyConfig, error) {
|
||||
app.BorderActive = sampleConfig.Color
|
||||
}
|
||||
|
||||
// app.Separator can be omitted, in that case it is false
|
||||
// app.SeparatorBlockWidth can be missing
|
||||
if app.FullText == "" {
|
||||
app.FullText = fmt.Sprintf(" %d ", num)
|
||||
}
|
||||
|
||||
// app.Separator can be omitted, in that case it is false
|
||||
// app.SeparatorBlockWidth can be missing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,10 +152,10 @@ func HasWindows(className string, instanceName string) bool {
|
||||
func FindWindowInstance(regexpStr string) bool {
|
||||
var found = false
|
||||
|
||||
f := func(key interface{}, value interface{}) bool {
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
re, err := regexp.Compile(regexpStr) //nolint:nolintlint, gocritic, we do not want shit our pants and panic on
|
||||
re, err := regexp.Compile(regexpStr) // we do not want shit our pants and panic on
|
||||
// erroneous regexp, we want log it to stderr, that it.
|
||||
|
||||
if err != nil {
|
||||
@@ -183,10 +183,10 @@ func FindWindowInstance(regexpStr string) bool {
|
||||
func FindWindowClass(regexpStr string) bool {
|
||||
var found = false
|
||||
|
||||
f := func(key interface{}, value interface{}) bool {
|
||||
f := func(key any, value any) bool { //nolint: revive
|
||||
keyStr := reflect.ValueOf(key).String()
|
||||
|
||||
re, err := regexp.Compile(regexpStr) //nolint:nolintlint, gocritic, we do not want shit our pants and panic on
|
||||
re, err := regexp.Compile(regexpStr) // we do not want shit our pants and panic on
|
||||
// erroneous regexp, we want log it to stderr, that it.
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -135,7 +135,7 @@ func (c *MyConfig) PaReinit() error {
|
||||
}
|
||||
|
||||
if cnt >= 5 {
|
||||
return errors.New("timeout waiting pulseaudio to exit") //nolint: goerr113
|
||||
return errors.New("timeout waiting pulseaudio to exit") //nolint: err113
|
||||
}
|
||||
|
||||
log.Print("Waiting for pulseaudio to exit")
|
||||
|
||||
@@ -69,6 +69,7 @@ func (c *MyConfig) VPNTCPCheck() bool {
|
||||
|
||||
if err == nil {
|
||||
_ = conn.Close()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user