fix linting

This commit is contained in:
Cody Lee
2025-12-03 11:40:21 -06:00
parent bc37996775
commit 6f4384c18d
14 changed files with 41 additions and 24 deletions

View File

@@ -48,4 +48,4 @@ jobs:
uses: golangci/golangci-lint-action@v9
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v2.0
version: v2.6

View File

@@ -5,7 +5,7 @@ linters:
- revive
- tagalign
- testpackage
- wsl
- wsl_v5
exclusions:
generated: lax
presets:
@@ -17,6 +17,11 @@ linters:
- third_party$
- builtin$
- examples$
settings:
wsl_v5:
allow-first-in-block: true
allow-whole-block: false
branch-max-lines: 2
issues:
max-issues-per-linter: 0
max-same-issues: 0

View File

@@ -246,6 +246,7 @@ func TestDataDogUnifiIntegration(t *testing.T) {
require.NoError(t, err)
var testExpectationsData testExpectations
err = yaml.Unmarshal(yamlFile, &testExpectationsData)
require.NoError(t, err)
@@ -277,6 +278,7 @@ func TestDataDogUnifiIntegration(t *testing.T) {
u.Collector = testRig.Collector
u.Collect(time.Minute)
mockCapture.RLock()
defer mockCapture.RUnlock()

View File

@@ -346,7 +346,6 @@ func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Repor
// Make a new Influx Points Batcher.
r.bp, err = influxV1.NewBatchPoints(influxV1.BatchPointsConfig{Database: u.DB})
if err != nil {
return nil, fmt.Errorf("influx.NewBatchPoint: %w", err)
}

View File

@@ -161,6 +161,7 @@ func TestInfluxV1Integration(t *testing.T) {
require.NoError(t, err)
var testExpectationsData testExpectations
err = yaml.Unmarshal(yamlFile, &testExpectationsData)
require.NoError(t, err)

View File

@@ -63,6 +63,7 @@ func (r *Report) done() {
func (r *Report) send(m *metric) {
r.wg.Add(1)
r.ch <- m
}

View File

@@ -87,6 +87,7 @@ func (u *InputUnifi) collectController(c *Controller) (*poller.Metrics, error) {
func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) {
u.RLock()
defer u.RUnlock()
u.LogDebugf("Polling controller: %s (%s)", c.URL, c.ID)
// Get the sites we care about.

View File

@@ -185,6 +185,7 @@ FIRST:
continue FIRST
}
}
u.LogErrorf("Configured site not found on controller %s: %v", c.URL, s)
}

View File

@@ -182,6 +182,7 @@ func (l *Loki) ProcessEvents(report *Report, events *poller.Events) error {
logs := report.ProcessEventLogs(events)
if len(logs.Streams) == 0 {
l.LogDebugf("No new events to send to Loki.")
return nil
}

View File

@@ -58,6 +58,7 @@ func (u *UnifiPoller) PrintPasswordHash() (err error) {
func (u *UnifiPoller) DebugIO() error {
inputSync.RLock()
defer inputSync.RUnlock()
outputSync.RLock()
defer outputSync.RUnlock()

View File

@@ -81,12 +81,14 @@ func (u *UnifiPoller) InitializeInputs() error {
if err := input.Initialize(u); err != nil {
u.LogDebugf("error initializing input ... %s", input.Name)
errChan <- err
return
}
u.LogDebugf("input successfully initialized ... %s", input.Name)
errChan <- nil
}(input)
}
@@ -142,7 +144,6 @@ func collectEvents(filter *Filter, inputs []*InputPlugin) (*Events, error) {
}
e, err := input.Events(filter)
if err != nil {
resultChan <- eventInputResult{err: err}

View File

@@ -323,6 +323,7 @@ func (u *promUnifi) collect(ch chan<- prometheus.Metric, filter *poller.Filter)
// Pass Report interface into our collecting and reporting methods.
go u.exportMetrics(r, ch, r.ch)
u.loopExports(r)
}

View File

@@ -38,6 +38,7 @@ func (r *Report) done() {
func (r *Report) send(m []*metric) {
r.wg.Add(1) // notlint: gomnd
r.ch <- m
}
@@ -71,7 +72,7 @@ func (r *Report) error(ch chan<- prometheus.Metric, d *prometheus.Desc, v any) {
r.Errors++
if r.ReportErrors {
ch <- prometheus.NewInvalidMetric(d, fmt.Errorf("error: %v", v)) // nolint: goerr113
ch <- prometheus.NewInvalidMetric(d, fmt.Errorf("error: %v", v)) // nolint
}
}

View File

@@ -202,12 +202,14 @@ func (w *webPlugins) newOutputEvent(plugin, id string, event *Event) {
func (w *webPlugins) newInput(config *Input) {
w.Lock()
defer w.Unlock()
w.inputs = append(w.inputs, config)
}
func (w *webPlugins) newOutput(config *Output) {
w.Lock()
defer w.Unlock()
w.outputs = append(w.outputs, config)
}