Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Remove new-from-rev parameter from golangci-lint #21266

Merged
merged 38 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c985ed0
Revive linter placeholders for Agent Shared Components
KSerrania Dec 1, 2023
0e780cb
Revive linter placeholders for Agent Metrics Logs
KSerrania Dec 2, 2023
0c5bd43
Unused, gosimple linter placeholders for Agent Metrics Logs
KSerrania Dec 2, 2023
d7a69f9
Revive linter placeholders for Container App
KSerrania Dec 2, 2023
3dde5d7
Revive linter placeholders for Processes
KSerrania Dec 2, 2023
12e6b52
Revive linter placeholders for Container Integrations
KSerrania Dec 2, 2023
c175ee0
Gosimple, staticcheck, govet linter placeholders for Container Integr…
KSerrania Dec 2, 2023
092919b
Revive linter placeholders for Universal Service Monitoring
KSerrania Dec 2, 2023
e4f533a
Gosimple, unused linter placeholders for Universal Service Monitoring
KSerrania Dec 2, 2023
de6af98
Revive linter placeholders for APM
KSerrania Dec 2, 2023
89fc3c9
Revive linter placeholders for Serverless
KSerrania Dec 2, 2023
164e898
Gosimple linter placeholders for Serverless
KSerrania Dec 5, 2023
8ec8b38
Revive linter placeholders for Database Monitoring
KSerrania Dec 2, 2023
cf925ba
Revive linter placeholders for Security Agent
KSerrania Dec 2, 2023
0eea3ab
Unused, gosimple linter placeholders for Security Agent
KSerrania Dec 2, 2023
6278bd1
Revive linter placeholders for eBPF Platform
KSerrania Dec 2, 2023
6a1567d
Staticcheck, unused linter placeholders for eBPF Platform
KSerrania Dec 2, 2023
3493cc4
Revive linter placeholders for Network Device Monitoring
KSerrania Dec 2, 2023
393bbd4
Unused linter placeholders for Network Device Monitoring
KSerrania Dec 2, 2023
858ab3e
Revive linter placeholders for Platform Integrations
KSerrania Dec 2, 2023
255f7cf
Revive linter placeholders for Remote Config
KSerrania Dec 2, 2023
255a3f5
Revive linter placeholders for Telemetry and Analytics
KSerrania Dec 2, 2023
a6ffdd8
Errcheck linter placeholders for Telemetry and Analytics
KSerrania Dec 2, 2023
341bb1e
Revive linter placeholders for CSPM
KSerrania Dec 2, 2023
baee062
Revive linter placeholders for Networks
KSerrania Dec 2, 2023
ad784f0
Staticcheck, unused, ineffassign, gosimple linter placeholders for Ne…
KSerrania Dec 2, 2023
5540a5a
Revive linter placeholders for ASM
KSerrania Dec 2, 2023
4f827ba
Unused linter placeholders for ASM
KSerrania Dec 2, 2023
1f2da44
Revive linter placeholders for OpenTelemetry
KSerrania Dec 2, 2023
96aac29
Revive linter placeholders for Windows Agent
KSerrania Dec 2, 2023
5c2f355
Gosimple linter placeholders for Windows Agent
KSerrania Dec 2, 2023
e075a05
Revive linter placeholders for Debugger
KSerrania Dec 2, 2023
3ae84e3
Revive linter placeholders for Agent Platform
KSerrania Dec 2, 2023
63cd5fb
Revive linter placeholders for Windows Kernel Integrations
KSerrania Dec 2, 2023
32c2e83
Gosimple linter placeholders for Windows Kernel Integrations
KSerrania Dec 2, 2023
3965e66
Revive linter placeholders for Agent Integrations
KSerrania Dec 2, 2023
5ac9526
Unused linter placeholders for Agent Integrations
KSerrania Dec 5, 2023
ce06c74
Remove new-from-rev parameter from golangci-lint config
KSerrania Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ issues:
- text: "Temporary has been deprecated since Go 1.18"
linters: [staticcheck]

# We're enabling the revive and the gosimple linters on the whole codebase
# TODO [After 7.48.0 freeze removal]: Remove the new-from-rev key
# TODO [After 7.48.0 freeze removal]: Tweak the KUBERNETES_MEMORY_LIMIT in .tests_linux_ebpf for runners not to fail running on the whole codebase (and not just the small diff induced by new-from-rev).
new-from-rev: f40667d3841c6339be0d00d53e54a4a63f43f11e

linters:
disable-all: true
enable:
Expand Down
8 changes: 8 additions & 0 deletions cmd/agent/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type serverSecure struct {
capture dsdReplay.Component
}

//nolint:revive // TODO(ASC) Fix revive linter
func (s *server) GetHostname(ctx context.Context, in *pb.HostnameRequest) (*pb.HostnameReply, error) {
h, err := hostname.Get(ctx)
if err != nil {
Expand All @@ -58,6 +59,8 @@ func (s *server) GetHostname(ctx context.Context, in *pb.HostnameRequest) (*pb.H
// override of the AuthFunc registered with the unary interceptor.
//
// see: https://godoc.org/github.com/grpc-ecosystem/go-grpc-middleware/auth#ServiceAuthFuncOverride
//
//nolint:revive // TODO(ASC) Fix revive linter
func (s *server) AuthFuncOverride(ctx context.Context, fullMethodName string) (context.Context, error) {
return ctx, nil
}
Expand All @@ -73,6 +76,8 @@ func (s *serverSecure) TaggerFetchEntity(ctx context.Context, req *pb.FetchEntit
// DogstatsdCaptureTrigger triggers a dogstatsd traffic capture for the
// duration specified in the request. If a capture is already in progress,
// an error response is sent back.
//
//nolint:revive // TODO(ASC) Fix revive linter
func (s *serverSecure) DogstatsdCaptureTrigger(ctx context.Context, req *pb.CaptureTriggerRequest) (*pb.CaptureTriggerResponse, error) {
d, err := time.ParseDuration(req.GetDuration())
if err != nil {
Expand All @@ -91,6 +96,8 @@ func (s *serverSecure) DogstatsdCaptureTrigger(ctx context.Context, req *pb.Capt
// Tagger facilities. This endpoint is used when traffic replays are in
// progress. An empty state or nil request will result in the Tagger
// capture state being reset to nil.
//
//nolint:revive // TODO(ASC) Fix revive linter
func (s *serverSecure) DogstatsdSetTaggerState(ctx context.Context, req *pb.TaggerState) (*pb.TaggerStateResponse, error) {
// Reset and return if no state pushed
if req == nil || req.State == nil {
Expand Down Expand Up @@ -126,6 +133,7 @@ func (s *serverSecure) ClientGetConfigs(ctx context.Context, in *pb.ClientGetCon
return s.configService.ClientGetConfigs(ctx, in)
}

//nolint:revive // TODO(ASC) Fix revive linter
func (s *serverSecure) GetConfigState(ctx context.Context, e *emptypb.Empty) (*pb.GetStateConfigResponse, error) {
if s.configService == nil {
log.Debug(rcNotInitializedErr.Error())
Expand Down
5 changes: 5 additions & 0 deletions cmd/agent/api/internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func setJSONError(w http.ResponseWriter, err error, errorCode int) {
http.Error(w, string(body), errorCode)
}

//nolint:revive // TODO(ASC) Fix revive linter
func stopAgent(w http.ResponseWriter, r *http.Request) {
signals.Stopper <- true
w.Header().Set("Content-Type", "application/json")
Expand Down Expand Up @@ -360,6 +361,7 @@ func getFormattedStatus(w http.ResponseWriter, _ *http.Request, invAgent invento
w.Write(s)
}

//nolint:revive // TODO(ASC) Fix revive linter
func getHealth(w http.ResponseWriter, r *http.Request) {
h := health.GetReady()

Expand All @@ -377,10 +379,12 @@ func getHealth(w http.ResponseWriter, r *http.Request) {
w.Write(jsonHealth)
}

//nolint:revive // TODO(ASC) Fix revive linter
func getCSRFToken(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(gui.CsrfToken))
}

//nolint:revive // TODO(ASC) Fix revive linter
func getConfigCheck(w http.ResponseWriter, r *http.Request) {
var response response.ConfigCheckResponse

Expand Down Expand Up @@ -408,6 +412,7 @@ func getConfigCheck(w http.ResponseWriter, r *http.Request) {
w.Write(jsonConfig)
}

//nolint:revive // TODO(ASC) Fix revive linter
func getTaggerList(w http.ResponseWriter, r *http.Request) {
// query at the highest cardinality between checks and dogstatsd cardinalities
cardinality := collectors.TagCardinality(max(int(tagger.ChecksCardinality), int(tagger.DogstatsdCardinality)))
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/api/internal/agent/agent_nojmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import (

const noJMXErrorString = "jmx is not compiled in this agent"

//nolint:revive // TODO(ASC) Fix revive linter
func getJMXConfigs(w http.ResponseWriter, r *http.Request) {
log.Error(noJMXErrorString)
http.Error(w, noJMXErrorString, 500)
}

//nolint:revive // TODO(ASC) Fix revive linter
func setJMXStatus(w http.ResponseWriter, r *http.Request) {
log.Error(noJMXErrorString)
http.Error(w, noJMXErrorString, 500)
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/api/internal/agent/python_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/log"
)

//nolint:revive // TODO(ASC) Fix revive linter
func getPythonStatus(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
pyStats, err := python.GetPythonInterpreterMemoryUsage()
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/api/internal/agent/python_status_nopython.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"net/http"
)

//nolint:revive // TODO(ASC) Fix revive linter
func getPythonStatus(w http.ResponseWriter, r *http.Request) {
// nothing here when python disabled
}
2 changes: 2 additions & 0 deletions cmd/agent/common/autodiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ func (sf schedulerFunc) Schedule(configs []integration.Config) {
}

// Unschedule implements scheduler.Scheduler#Unschedule.
//
//nolint:revive // TODO(ASC) Fix revive linter
func (sf schedulerFunc) Unschedule(configs []integration.Config) {
// (do nothing)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func GetPythonPaths() []string {
}

// GetVersion returns the version of the agent in a http response json
//
//nolint:revive // TODO(ASC) Fix revive linter
func GetVersion(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
av, _ := version.Agent()
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/common/common_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
)

// Name of the Windows Service the agent runs as
//
//nolint:revive // TODO(ASC) Fix revive linter
const ServiceName = "DatadogAgent"

func init() {
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/dogstatsd/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(ASC) Fix revive linter
package dogstatsd

import (
Expand Down
7 changes: 7 additions & 0 deletions cmd/agent/gui/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(ASC) Fix revive linter
package gui

import (
Expand Down Expand Up @@ -45,6 +46,8 @@ func agentHandler(r *mux.Router, flare flare.Component, invAgent inventoryagent.
}

// Sends a simple reply (for checking connection to server)
//
//nolint:revive // TODO(ASC) Fix revive linter
func ping(w http.ResponseWriter, r *http.Request) {
elapsed := time.Now().Unix() - startTimestamp
w.Write([]byte(strconv.FormatInt(elapsed, 10)))
Expand Down Expand Up @@ -175,6 +178,8 @@ func makeFlare(w http.ResponseWriter, r *http.Request, flare flare.Component) {
}

// Restarts the agent using the appropriate (platform-specific) restart function
//
//nolint:revive // TODO(ASC) Fix revive linter
func restartAgent(w http.ResponseWriter, r *http.Request) {
log.Infof("got restart function")
e := restart()
Expand Down Expand Up @@ -207,6 +212,8 @@ func getConfigSetting(w http.ResponseWriter, r *http.Request) {
}

// Sends the configuration (aka datadog.yaml) file
//
//nolint:revive // TODO(ASC) Fix revive linter
func getConfigFile(w http.ResponseWriter, r *http.Request) {
path := config.Datadog.ConfigFileUsed()
settings, e := os.ReadFile(path)
Expand Down
8 changes: 8 additions & 0 deletions cmd/agent/gui/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func checkHandler(r *mux.Router) {
}

// Sends a list of all the current running checks
//
//nolint:revive // TODO(ASC) Fix revive linter
func sendRunningChecks(w http.ResponseWriter, r *http.Request) {
html, e := renderRunningChecks()
if e != nil {
Expand All @@ -73,6 +75,8 @@ func sendRunningChecks(w http.ResponseWriter, r *http.Request) {
}

// Schedules a specific check
//
//nolint:revive // TODO(ASC) Fix revive linter
func runCheck(w http.ResponseWriter, r *http.Request) {
// Fetch the desired check
name := mux.Vars(r)["name"]
Expand Down Expand Up @@ -338,6 +342,8 @@ func getWheelsChecks() ([]string, error) {
}

// Sends a list containing the names of all the checks
//
//nolint:revive // TODO(ASC) Fix revive linter
func listChecks(w http.ResponseWriter, r *http.Request) {
integrations := []string{}
for _, path := range checkPaths {
Expand Down Expand Up @@ -417,6 +423,8 @@ func getConfigsInPath(path string) ([]string, error) {
}

// Sends a list containing the names of all the config files
//
//nolint:revive // TODO(ASC) Fix revive linter
func listConfigs(w http.ResponseWriter, r *http.Request) {
filenames := []string{}
for _, path := range configPaths {
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func createCSRFToken() error {
return nil
}

//nolint:revive // TODO(ASC) Fix revive linter
func generateIndex(w http.ResponseWriter, r *http.Request) {
data, err := viewsFS.ReadFile("views/templates/index.tmpl")
if err != nil {
Expand All @@ -139,6 +140,7 @@ func generateIndex(w http.ResponseWriter, r *http.Request) {
}
}

//nolint:revive // TODO(ASC) Fix revive linter
func generateAuthEndpoint(w http.ResponseWriter, r *http.Request) {
data, err := viewsFS.ReadFile("views/templates/auth.tmpl")
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/configcheck/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{configCheckCommand}
}

//nolint:revive // TODO(ASC) Fix revive linter
func run(config config.Component, cliParams *cliParams) error {
var b bytes.Buffer
color.Output = &b
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/controlsvc/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
)

// Commands returns a slice of subcommands for the 'agent' command.
//
//nolint:revive // TODO(WINA) Fix revive linter
func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{
{
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/diagnose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func cmdDiagnose(cliParams *cliParams, senderManager diagnosesendermanager.Compo
}

// NOTE: This and related will be moved to separate "agent telemetry" command in future
//
//nolint:revive // TODO(ASC) Fix revive linter
func printPayload(name payloadName, _ log.Component, config config.Component) error {
if err := util.SetAuthToken(); err != nil {
fmt.Println(err)
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/dogstatsdcapture/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{dogstatsdCaptureCmd}
}

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

Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/dogstatsdreplay/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{dogstatsdReplayCmd}
}

//nolint:revive // TODO(AML) Fix revive linter
func dogstatsdReplay(log log.Component, config config.Component, cliParams *cliParams) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/dogstatsdstats/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{dogstatsdStatsCmd}
}

//nolint:revive // TODO(AML) Fix revive linter
func requestDogstatsdStats(log log.Component, config config.Component, cliParams *cliParams) error {
fmt.Printf("Getting the dogstatsd stats from the agent.\n\n")
var e error
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/flare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/metadata/inventoryagent"
"github.com/DataDog/datadog-agent/pkg/api/util"
//nolint:revive // TODO(ASC) Fix revive linter
apiutil "github.com/DataDog/datadog-agent/pkg/api/util"
pkgconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/config/settings"
Expand Down Expand Up @@ -207,6 +208,7 @@ func readProfileData(seconds int) (flare.ProfileData, error) {
return pdata, errs
}

//nolint:revive // TODO(ASC) Fix revive linter
func makeFlare(flareComp flare.Component, log log.Component, config config.Component, sysprobeconfig sysprobeconfig.Component, cliParams *cliParams) error {
var (
profile flare.ProfileData
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/flare/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
//nolint:revive // TODO(ASC) Fix revive linter
assert "github.com/stretchr/testify/require"

"github.com/DataDog/datadog-agent/cmd/agent/command"
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/hostname/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{getHostnameCommand}
}

//nolint:revive // TODO(ASC) Fix revive linter
func getHostname(log log.Component, config config.Component, cliParams *cliParams) error {
hname, err := hostname.Get(context.TODO())
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
)

//nolint:revive // TODO(ASC) Fix revive linter
func validateUser(allowRoot bool) error {
if os.Geteuid() != 0 {
return fmt.Errorf("please run this tool with the root user")
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/integrations/integrations_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ func getRelChecksPath(cliParams *cliParams) (string, error) {
return filepath.Join(fmt.Sprintf("embedded%s", cliParams.pythonMajorVersion), "Lib", "site-packages", "datadog_checks"), nil
}

//nolint:revive // TODO(ASC) Fix revive linter
func validateUser(allowRoot bool) error {
elevated, _ := winutil.IsProcessElevated()
if !elevated {
//nolint:revive // TODO(ASC) Fix revive linter
return fmt.Errorf("Operation is not possible for unelevated process.")
}
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/agent/subcommands/launchgui/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{launchCmd}
}

//nolint:revive // TODO(ASC) Fix revive linter
func launchGui(config config.Component, cliParams *cliParams) error {
guiPort := pkgconfig.Datadog.GetString("GUI_port")
if guiPort == "-1" {
Expand Down
2 changes: 2 additions & 0 deletions cmd/agent/subcommands/remoteconfig/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
return []*cobra.Command{remoteConfigCmd}
}

//nolint:revive // TODO(RC) Fix revive linter
func state(cliParams *cliParams, config config.Component) error {
if !pkgconfig.IsRemoteConfigEnabled(config) {
return fmt.Errorf("Remote configuration is not enabled")
Expand All @@ -65,6 +66,7 @@ func state(cliParams *cliParams, config config.Component) error {
if err != nil {
return fmt.Errorf("Couldn't get auth token: %v", err)
}
//nolint:revive // TODO(RC) Fix revive linter
ctx, close := context.WithCancel(context.Background())
defer close()
md := metadata.MD{
Expand Down
Loading
Loading