Skip to content

Commit

Permalink
[ASCII-2077] upgrade golangci-lint to a version that support module p…
Browse files Browse the repository at this point in the history
…lugin (#28022)
  • Loading branch information
GustavoCaso authored Aug 2, 2024
1 parent d82764d commit 1039270
Show file tree
Hide file tree
Showing 562 changed files with 1,583 additions and 1,612 deletions.
18 changes: 9 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
run:
skip-files:
- pkg/util/cloudproviders/cloudfoundry/bbscache_test.go # implements interface from imported package whose method names fail linting
- pkg/util/intern/string.go # TODO: fix govet 'unsafeptr' error
- pkg/serverless/trace/inferredspan/constants.go # TODO: fox revive exported const error
skip-dirs:
- pkg/proto/patches
- tasks/unit_tests/testdata/components_src

issues:
exclude-use-default: false
# Do not limit the number of issues per linter.
max-issues-per-linter: 0

# Do not limit the number of times a same issue is reported.
max-same-issues: 0

exclude-files:
- pkg/util/cloudproviders/cloudfoundry/bbscache_test.go # implements interface from imported package whose method names fail linting
- pkg/util/intern/string.go # TODO: fix govet 'unsafeptr' error
- pkg/serverless/trace/inferredspan/constants.go # TODO: fox revive exported const error

exclude-dirs:
- pkg/proto/patches
- tasks/unit_tests/testdata/components_src

exclude:
- "Error return value of `io.WriteString` is not checked" # 'errcheck' errors in tools/dep_tree_resolver/go_deps.go
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/configcheck/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Aliases: []string{"checkconfig"},
Short: "Print all configurations loaded & resolved of a running agent",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(run,
fx.Supply(cliParams),
fx.Supply(core.BundleParams{
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/configcheck/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"configcheck", "-v"},
run,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(cliParams *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, true, cliParams.verbose)
require.Equal(t, true, secretParams.Enabled)
})
Expand Down
22 changes: 11 additions & 11 deletions cmd/agent/subcommands/diagnose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "diagnose",
Short: "Validate Agent installation, configuration and environment",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(cmdDiagnose,
fx.Supply(cliParams),
fx.Supply(core.BundleParams{
Expand Down Expand Up @@ -131,7 +131,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "show-metadata",
Short: "Print metadata payloads sent by the agent",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
cmd.Help() //nolint:errcheck
os.Exit(0)
return nil
Expand All @@ -143,7 +143,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Short: "[internal] Print the metadata payload for the agent.",
Long: `
This command print the V5 metadata payload for the Agent. This payload is used to populate the infra list and host map in Datadog. It's called 'V5' because it's the same payload sent since Agent V5. This payload is mandatory in order to create a new host in Datadog.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("v5")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -157,7 +157,7 @@ This command print the V5 metadata payload for the Agent. This payload is used t
Short: "[internal] Print the gohai payload for the agent.",
Long: `
This command prints the gohai data sent by the Agent, including current processes running on the machine.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("gohai")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -171,7 +171,7 @@ This command prints the gohai data sent by the Agent, including current processe
Short: "[internal] Print the Inventory agent metadata payload.",
Long: `
This command print the inventory-agent metadata payload. This payload is used by the 'inventories/sql' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("inventory-agent")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -185,7 +185,7 @@ This command print the inventory-agent metadata payload. This payload is used by
Short: "[internal] Print the Inventory host metadata payload.",
Long: `
This command print the inventory-host metadata payload. This payload is used by the 'inventories/sql' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("inventory-host")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -199,7 +199,7 @@ This command print the inventory-host metadata payload. This payload is used by
Short: "Print the Inventory otel metadata payload.",
Long: `
This command print the inventory-otel metadata payload. This payload is used by the 'inventories/sql' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("inventory-otel")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -213,7 +213,7 @@ This command print the inventory-otel metadata payload. This payload is used by
Short: "[internal] Print the Inventory checks metadata payload.",
Long: `
This command print the inventory-checks metadata payload. This payload is used by the 'inventories/sql' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("inventory-checks")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -227,7 +227,7 @@ This command print the inventory-checks metadata payload. This payload is used b
Short: "[internal] Print the Inventory package signing payload.",
Long: `
This command print the package-signing metadata payload. This payload is used by the 'fleet automation' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("package-signing")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -241,7 +241,7 @@ This command print the package-signing metadata payload. This payload is used by
Short: "[internal] Print the inventory systemprobe metadata payload.",
Long: `
This command print the system-probe metadata payload. This payload is used by the 'fleet automation' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("system-probe")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -255,7 +255,7 @@ This command print the system-probe metadata payload. This payload is used by th
Short: "[internal] Print the security-agent process metadata payload.",
Long: `
This command print the security-agent metadata payload. This payload is used by the 'fleet automation' product.`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(printPayload,
fx.Supply(payloadName("security-agent")),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand Down
20 changes: 10 additions & 10 deletions cmd/agent/subcommands/diagnose/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestDiagnoseCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose"},
cmdDiagnose,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(_ *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -31,7 +31,7 @@ func TestShowMetadataV5Command(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "v5"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -41,7 +41,7 @@ func TestShowMetadataGohaiCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "gohai"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -51,7 +51,7 @@ func TestShowMetadataInventoryAgentCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "inventory-agent"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -61,7 +61,7 @@ func TestShowMetadataInventoryHostCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "inventory-host"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -71,7 +71,7 @@ func TestShowMetadataInventoryChecksCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "inventory-checks"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -81,7 +81,7 @@ func TestShowMetadataInventoryOtelCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "inventory-otel"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -91,7 +91,7 @@ func TestShowMetadataPkgSigningCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "package-signing"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -101,7 +101,7 @@ func TestShowMetadataSystemProbeCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "system-probe"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
Expand All @@ -111,7 +111,7 @@ func TestShowMetadataSecurityAgentCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"diagnose", "show-metadata", "security-agent"},
printPayload,
func(coreParams core.BundleParams, secretParams secrets.Params) {
func(_ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
4 changes: 2 additions & 2 deletions cmd/agent/subcommands/dogstatsd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
topCmd := &cobra.Command{
Use: "top",
Short: "Display metrics with most contexts in the aggregator",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(topContexts,
fx.Supply(&topFlags),
fx.Supply(core.BundleParams{
Expand All @@ -66,7 +66,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
c.AddCommand(&cobra.Command{
Use: "dump-contexts",
Short: "Write currently tracked contexts as JSON",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(dumpContexts,
fx.Supply(core.BundleParams{
ConfigParams: cconfig.NewAgentParams(globalParams.ConfFilePath, cconfig.WithExtraConfFiles(globalParams.ExtraConfFilePath)),
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/subcommands/dogstatsdcapture/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "dogstatsd-capture",
Short: "Start a dogstatsd UDS traffic capture",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(dogstatsdCapture,
fx.Supply(cliParams),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -75,7 +75,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}

//nolint:revive // TODO(AML) Fix revive linter
func dogstatsdCapture(log log.Component, config config.Component, cliParams *cliParams) error {
func dogstatsdCapture(_ log.Component, config config.Component, cliParams *cliParams) error {
fmt.Printf("Starting a dogstatsd traffic capture session...\n\n")

ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/dogstatsdcapture/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"dogstatsd-capture", "-d", "10s", "-z"},
dogstatsdCapture,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(cliParams *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, 10*time.Second, cliParams.dsdCaptureDuration)
require.True(t, cliParams.dsdCaptureCompressed)
require.Equal(t, false, secretParams.Enabled)
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/subcommands/dogstatsdreplay/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "dogstatsd-replay",
Short: "Replay dogstatsd traffic",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(dogstatsdReplay,
fx.Supply(cliParams),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -76,7 +76,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}

//nolint:revive // TODO(AML) Fix revive linter
func dogstatsdReplay(log log.Component, config config.Component, cliParams *cliParams) error {
func dogstatsdReplay(_ log.Component, config config.Component, cliParams *cliParams) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/dogstatsdreplay/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"dogstatsd-replay", "-v"},
dogstatsdReplay,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(cliParams *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.True(t, cliParams.dsdVerboseReplay)
require.Equal(t, false, secretParams.Enabled)
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/subcommands/dogstatsdstats/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "dogstatsd-stats",
Short: "Print basic statistics on the metrics processed by dogstatsd",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(requestDogstatsdStats,
fx.Supply(cliParams),
fx.Supply(command.GetDefaultCoreBundleParams(cliParams.GlobalParams)),
Expand All @@ -65,7 +65,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
}

//nolint:revive // TODO(AML) Fix revive linter
func requestDogstatsdStats(log log.Component, config config.Component, cliParams *cliParams) error {
func requestDogstatsdStats(_ log.Component, config config.Component, cliParams *cliParams) error {
fmt.Printf("Getting the dogstatsd stats from the agent.\n\n")
var e error
var s string
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/dogstatsdstats/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"dogstatsd-stats", "--json"},
requestDogstatsdStats,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(cliParams *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.True(t, cliParams.jsonStatus)
require.Equal(t, false, secretParams.Enabled)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "flare [caseID]",
Short: "Collect a flare and send it to Datadog",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
cliParams.args = args
config := config.NewAgentParams(globalParams.ConfFilePath,
config.WithSecurityAgentConfigFilePaths([]string{
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/flare/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (c *commandTestSuite) TestCommand() {
Commands(&command.GlobalParams{}),
[]string{"flare", "1234"},
makeFlare,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(cliParams *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, []string{"1234"}, cliParams.args)
require.Equal(t, true, secretParams.Enabled)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/hostname/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Use: "hostname",
Short: "Print the hostname used by the Agent",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return fxutil.OneShot(getHostname,
fx.Supply(cliParams),
fx.Supply(core.BundleParams{
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/hostname/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestCommand(t *testing.T) {
Commands(&command.GlobalParams{}),
[]string{"hostname"},
getHostname,
func(cliParams *cliParams, coreParams core.BundleParams, secretParams secrets.Params) {
func(_ *cliParams, _ core.BundleParams, secretParams secrets.Params) {
require.Equal(t, false, secretParams.Enabled)
})
}
2 changes: 1 addition & 1 deletion cmd/agent/subcommands/import/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
Short: "Import and convert configuration files from previous versions of the Agent",
Long: ``,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
cliParams.args = args
return fxutil.OneShot(importCmd,
fx.Supply(cliParams),
Expand Down
Loading

0 comments on commit 1039270

Please sign in to comment.