Skip to content

Commit

Permalink
GROUNDWORK-4166: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSenkevich committed Jan 30, 2025
1 parent db1d51b commit 2a1d7df
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
with:
go-version: 1.23
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.59.1
version: v1.61.0

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --timeout=5m --disable depguard
args: --config .golangci.yaml --timeout=10m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
Expand Down
32 changes: 16 additions & 16 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
run:
go: '1.23'
skip-dirs:
- vendor
- bin
- var
- tmp
- gotocjson
- libtransit
- deprecated
- connectors/nsca
skip-files:
- \.pb\.go$
modules-download-mode: readonly
build-tags:
- codeanalysis

govet:
enable:
Expand All @@ -34,11 +24,8 @@ linters:
- staticcheck
- stylecheck
- unconvert
# TODO: - unparam
- unused
- whitespace
# TODO: - gocognit
# TODO: - gocyclo
disable:
- depguard
- gochecknoglobals
Expand All @@ -50,8 +37,21 @@ linters:
- gosimple
- gosec
- funlen

- typecheck
issues:
exclude-dirs:
- vendor
- bin
- var
- tmp
- gotocjson
- libtransit
- deprecated
- connectors/nsca
- connector/nsca/nsca
exclude-files:
- \.pb\.go$
- connector/nsca/nsca/nsca.go
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *GWConnection) UnmarshalYAML(unmarshal func(interface{}) error) error {
return fmt.Errorf("unmarshaler error: %s SecKeyEnv is empty", SecVerPrefix)
}
var encrypted []byte
fmt.Sscanf(c.Password, SecVerPrefix+"%x", &encrypted)
fmt.Sscanf(c.Password, SecVerPrefix+"%x", &encrypted) //nolint:errcheck
decrypted, err := Decrypt(encrypted, []byte(s))
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions connectors/checker/checker.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package checker

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/checker/checker_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package checker

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/checker/cmd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package checker

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/nsca/cmd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package nsca

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/nsca/nsca.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package nsca

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/nsca/nsca/nsca.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package nsca

import (
Expand Down
2 changes: 2 additions & 0 deletions connectors/nsca/parser/parser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package parser

import (
Expand Down
4 changes: 3 additions & 1 deletion connectors/nsca/parser/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package parser

import (
Expand Down Expand Up @@ -85,7 +87,7 @@ S;1628530909;awips-demo-2;example-service-7;0;OK - example-service-7 (2021-08-09

func TestBronxParser2(t *testing.T) {
data := []byte(
`H;1628546296;awips-demo-2;0;UP - awips-demo-2 (2021-08-09 21:58:16 :: 1628546296) | result=21ms;;;0;
`H;1628546296;awips-demo-2;0;UP - awips-demo-2 (2021-08-09 21:58:16 :: 1628546296) | result=21ms;;;0;
S;1628546296;awips-demo-2;example-service;0;OK - example-service (2021-08-09 21:58:16 :: 1628546296) | result=168ms;;;0;
S;1628546296;awips-demo-2;example-service-1;0;OK - example-service-1 (2021-08-09 21:58:16 :: 1628546296) | result=168ms;;;0;
S;1628546296;awips-demo-2;example-service-2;0;OK - example-service-2 (2021-08-09 21:58:16 :: 1628546296) | result=84ms;;;0;
Expand Down
6 changes: 5 additions & 1 deletion connectors/snmp/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ func (device *DeviceExt) retrieveMonitoredServices(metricDefinitions map[string]
mService.LastPluginOutput = "Interface Operational and Administrative states are UNKNOWN"
}
if thresholdMessage != "" {
mService.LastPluginOutput += fmt.Sprintf(" | %s", thresholdMessage)
if mService.LastPluginOutput != "" {
mService.LastPluginOutput += fmt.Sprintf(" | %s", thresholdMessage)
} else {
mService.LastPluginOutput = thresholdMessage
}
}
mServices = append(mServices, *mService)
}
Expand Down
1 change: 0 additions & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func BenchmarkE2E(b *testing.B) {
}
}
})

}

func resources(countHst, countSvc int) []transit.MonitoredResource {
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !codeanalysis

package main

import (
Expand Down
2 changes: 0 additions & 2 deletions services/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ func (service *AgentService) startTransport() error {
service.Connector.AppType == traceOnDemandAppType ||
len(service.Connector.AgentID) == 0 ||
len(service.Connector.AppType) == 0 {

err := fmt.Errorf("connector is not configured: AppType/AgentID: %v/%v",
service.Connector.AppType, service.Connector.AgentID)
log.Err(err).Msg("could not start")
Expand Down Expand Up @@ -619,7 +618,6 @@ func (service *AgentService) fixTracerContext(payloadJSON []byte) []byte {
service.Connector.AppType == traceOnDemandAppType ||
len(service.Connector.AgentID) == 0 ||
len(service.Connector.AppType) == 0 {

err := fmt.Errorf("connector is not configured: AppType/AgentID: %v/%v",
service.Connector.AppType, service.Connector.AgentID)
log.Err(err).Msg("could not fixTracerContext")
Expand Down

0 comments on commit 2a1d7df

Please sign in to comment.