chore(deps): update dependency golangci/golangci-lint to v2.6.0 (#2246)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
renovate[bot]
2025-11-02 19:41:27 +01:00
committed by GitHub
parent a523ef69fd
commit 3d0587d28c
14 changed files with 31 additions and 42 deletions

View File

@@ -91,5 +91,5 @@ jobs:
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
# renovate: github=golangci/golangci-lint
version: v2.5.0
version: v2.6.0
args: "--max-same-issues=0"

View File

@@ -775,6 +775,7 @@ func (c *Collector) workerBitlocker(ctx context.Context, initErrCh chan<- error)
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {

View File

@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"reflect"
"regexp"
"slices"
@@ -184,7 +185,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
return reflect.StructField{
Name: strings.ToUpper(sanitizeMetricName(name)),
Type: reflect.TypeOf(float64(0)),
Type: reflect.TypeFor[float64](),
Tag: reflect.StructTag(fmt.Sprintf(`perfdata:"%s"`, name)),
}, nil
}(counter.Name)
@@ -200,13 +201,13 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
if object.Instances != nil {
fields = append(fields, reflect.StructField{
Name: "Name",
Type: reflect.TypeOf(""),
Type: reflect.TypeFor[string](),
})
}
fields = append(fields, reflect.StructField{
Name: "MetricType",
Type: reflect.TypeOf(prometheus.ValueType(0)),
Type: reflect.TypeFor[prometheus.ValueType](),
})
valueType := reflect.StructOf(fields)
@@ -321,7 +322,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
continue
}
if field.Kind() != reflect.TypeOf(prometheus.ValueType(0)).Kind() {
if field.Kind() != reflect.TypeFor[prometheus.ValueType]().Kind() {
errs = append(errs, fmt.Errorf("failed to cast MetricType for %s to prometheus.ValueType", counter.Name))
continue
@@ -351,9 +352,7 @@ func (c *Collector) collectObject(ch chan<- prometheus.Metric, perfDataObject Ob
}
}
for key, value := range counter.Labels {
labels[key] = value
}
maps.Copy(labels, counter.Labels)
switch counter.Type {
case "counter":

View File

@@ -248,6 +248,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
@@ -256,6 +257,7 @@ func getScheduledTasks() (ScheduledTasks, error) {
return nil, err
}
}
defer ole.CoUninitialize()
schedClassID, err := ole.ClassIDFrom(SCHEDULED_TASK_PROGRAM_ID)

View File

@@ -25,6 +25,7 @@ import (
"os"
"path/filepath"
"reflect"
"slices"
"sort"
"strings"
"time"
@@ -183,17 +184,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
}
for k := range allLabelNames {
present := false
for _, name := range names {
if k == name {
present = true
break
}
}
if !present {
if !slices.Contains(names, k) {
names = append(names, k)
values = append(values, "")
}

View File

@@ -64,6 +64,7 @@ func TestMultipleDirectories(t *testing.T) {
err := val.Write(&metric)
require.NoError(t, err)
//nolint:modernize,perfsprint
got += metric.String()
}
@@ -102,6 +103,7 @@ func TestDuplicateFileName(t *testing.T) {
err := val.Write(&metric)
require.NoError(t, err)
//nolint:perfsprint
got += metric.String()
}

View File

@@ -176,6 +176,7 @@ func (c *Collector) scheduleUpdateStatus(ctx context.Context, logger *slog.Logge
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {

View File

@@ -96,12 +96,12 @@ func Parse(app *kingpin.Application, args []string) error {
// ParseConfigFile manually parses the configuration file from the command line arguments.
func ParseConfigFile(args []string) string {
for i, cliFlag := range args {
if strings.HasPrefix(cliFlag, "--config.file=") {
return strings.TrimPrefix(cliFlag, "--config.file=")
if configFile, ok := strings.CutPrefix(cliFlag, "--config.file="); ok {
return configFile
}
if strings.HasPrefix(cliFlag, "-config.file=") {
return strings.TrimPrefix(cliFlag, "-config.file=")
if configFile, ok := strings.CutPrefix(cliFlag, "-config.file="); ok {
return configFile
}
if strings.HasSuffix(cliFlag, "-config.file") {
@@ -148,7 +148,7 @@ func NewConfigFileResolver(filePath string) (*Resolver, error) {
return nil, fmt.Errorf("failed to rewind file: %w", err)
}
var rawValues map[string]interface{}
var rawValues map[string]any
decoder = yaml.NewDecoder(file)
if err = decoder.Decode(&rawValues); err != nil {

View File

@@ -36,7 +36,7 @@ func TestConfigFlattening(t *testing.T) {
log:
level: debug`)
var data map[string]interface{}
var data map[string]any
err := yaml.Unmarshal(goodYamlConfig, &data)
if err != nil {

View File

@@ -46,7 +46,7 @@ type Properties struct {
type ProcessDetails struct {
ProcessId int32 `json:"ProcessId,omitempty"`
ImageName string `json:"ImageName,omitempty"`
CreateTimestamp time.Time `json:"CreateTimestamp,omitempty"`
CreateTimestamp time.Time `json:"CreateTimestamp"`
UserTime100ns int32 `json:"UserTime100ns,omitempty"`
KernelTime100ns int32 `json:"KernelTime100ns,omitempty"`
MemoryCommitBytes int32 `json:"MemoryCommitBytes,omitempty"`
@@ -55,8 +55,8 @@ type ProcessDetails struct {
}
type Statistics struct {
Timestamp time.Time `json:"Timestamp,omitempty"`
ContainerStartTime time.Time `json:"ContainerStartTime,omitempty"`
Timestamp time.Time `json:"Timestamp"`
ContainerStartTime time.Time `json:"ContainerStartTime"`
Uptime100ns uint64 `json:"Uptime100ns,omitempty"`
Processor *ProcessorStats `json:"Processor,omitempty"`
Memory *MemoryStats `json:"Memory,omitempty"`

View File

@@ -42,6 +42,7 @@ func (s *ScheduleService) Connect() error {
// Otherwise, attempting to initialize and run parallel queries across
// goroutines will result in protected memory errors.
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {

View File

@@ -110,7 +110,7 @@ func NewCollectorWithReflection(logger *slog.Logger, resultType CounterType, obj
}
if f, ok := valueType.FieldByName("MetricType"); ok {
if f.Type.Kind() == reflect.TypeOf(prometheus.ValueType(0)).Kind() {
if f.Type.Kind() == reflect.TypeFor[prometheus.ValueType]().Kind() {
collector.metricsTypeIndexValue = f.Index[0]
}
}

View File

@@ -53,9 +53,7 @@ func NewCollector[T any](object string, _ []string) (*Collector, error) {
counters: make(map[string]Counter),
}
var values [0]T
valueType := reflect.TypeOf(values).Elem()
valueType := reflect.TypeFor[T]().Elem()
if f, ok := valueType.FieldByName("Name"); ok {
if f.Type.Kind() == reflect.String {
@@ -81,9 +79,7 @@ func NewCollector[T any](object string, _ []string) (*Collector, error) {
}
}
if strings.HasSuffix(counterName, ",secondvalue") {
counterName = strings.TrimSuffix(counterName, ",secondvalue")
if counterName, ok = strings.CutSuffix(counterName, ",secondvalue"); ok {
counter.FieldIndexSecondValue = f.Index[0]
} else {
counter.FieldIndexValue = f.Index[0]

View File

@@ -64,7 +64,7 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co
}
}
func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*V) C, conf *V) {
func TestCollector[C collector.Collector, V any](t *testing.T, fn func(*V) C, conf *V) {
t.Helper()
var (
@@ -89,15 +89,11 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
})
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for metric := range ch {
metrics = append(metrics, metric)
}
}()
})
err = c.Build(logger, miSession)