Skip to content

Fixing and enabling more linters #529

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

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ linters:
- nestif
- nlreturn
- noctx # might be worth fixing
- nolintlint
- nonamedreturns
- paralleltest
- protogetter
Expand Down Expand Up @@ -98,17 +97,12 @@ linters-settings:
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- sloppyReassign
- uncheckedInlineErr # Experimental rule with high false positive rate.

# Broken with Go 1.18 feature (https://github.com/golangci/golangci-lint/issues/2649):
- hugeParam
- rangeValCopy
- typeDefFirst
- paramTypeCombine
gocyclo:
min-complexity: 15
govet:
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func New(ctx context.Context, opts ...ConfigOption) (*App, error) {
return app, nil
}

func parseDurationTimeout(l *zap.SugaredLogger, flag string, deprecatedFlag string) (time.Duration, bool, error) {
func parseDurationTimeout(l *zap.SugaredLogger, flag, deprecatedFlag string) (time.Duration, bool, error) {
if strValue, ok := os.LookupEnv(flag); ok {
d, err := time.ParseDuration(strValue)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions e2e-testing/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestEndToEnd(t *testing.T) {
assert.True(t, strings.Contains(mockAPMServerLog, testUUID))
}

func runTestWithTimer(l *zap.SugaredLogger, path string, serviceName string, serverURL string, buildFlag bool, lambdaFuncTimeout int, resultsChan chan string) string {
func runTestWithTimer(l *zap.SugaredLogger, path, serviceName, serverURL string, buildFlag bool, lambdaFuncTimeout int, resultsChan chan string) string {
timer := time.NewTimer(time.Duration(lambdaFuncTimeout) * time.Second * 2)
defer timer.Stop()
go runTest(l, path, serviceName, serverURL, buildFlag, lambdaFuncTimeout, resultsChan)
Expand All @@ -122,7 +122,7 @@ func buildExtensionBinaries(l *zap.SugaredLogger) {
RunCommandInDir(l, "make", []string{}, "..")
}

func runTest(l *zap.SugaredLogger, path string, serviceName string, serverURL string, buildFlag bool, lambdaFuncTimeout int, resultsChan chan string) {
func runTest(l *zap.SugaredLogger, path, serviceName, serverURL string, buildFlag bool, lambdaFuncTimeout int, resultsChan chan string) {
l.Infof("Starting to test %s", serviceName)

if !FolderExists(filepath.Join(path, ".aws-sam")) || buildFlag {
Expand All @@ -144,7 +144,7 @@ func runTest(l *zap.SugaredLogger, path string, serviceName string, serverURL st
resultsChan <- uuidWithHyphen
}

func retrieveJavaAgent(l *zap.SugaredLogger, samJavaPath string, version string) {
func retrieveJavaAgent(l *zap.SugaredLogger, samJavaPath, version string) {
agentFolderPath := filepath.Join(samJavaPath, "agent")
agentArchivePath := filepath.Join(samJavaPath, "agent.zip")

Expand Down Expand Up @@ -172,7 +172,7 @@ func changeJavaAgentPermissions(l *zap.SugaredLogger, samJavaPath string) {
agentFiles, err := os.ReadDir(agentFolderPath)
ProcessError(l, err)
for _, f := range agentFiles {
if err = os.Chmod(filepath.Join(agentFolderPath, f.Name()), 0755); err != nil {
if err = os.Chmod(filepath.Join(agentFolderPath, f.Name()), 0o755); err != nil {
l.Errorf("Could not change java agent permissions : %v", err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions e2e-testing/e2e_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

// GetEnvVarValueOrSetDefault retrieves the environment variable envVarName.
// If the desired variable is not defined, defaultVal is returned.
func GetEnvVarValueOrSetDefault(envVarName string, defaultVal string) string {
func GetEnvVarValueOrSetDefault(envVarName, defaultVal string) string {
val := os.Getenv(envVarName)
if val == "" {
return defaultVal
Expand Down Expand Up @@ -83,13 +83,13 @@ func ProcessError(l *zap.SugaredLogger, err error) {
}

// Unzip is a utility function that unzips a specified zip archive to a specified destination.
func Unzip(l *zap.SugaredLogger, archivePath string, destinationFolderPath string) {
func Unzip(l *zap.SugaredLogger, archivePath, destinationFolderPath string) {
openedArchive, err := zip.OpenReader(archivePath)
ProcessError(l, err)
defer openedArchive.Close()

// Permissions setup
err = os.MkdirAll(destinationFolderPath, 0755)
err = os.MkdirAll(destinationFolderPath, 0o755)
if err != nil {
l.Errorf("Could not create folders required to unzip, %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion logsapi/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// specific language governing permissions and limitations
// under the License.

//nolint:dupl
package logsapi

import (
Expand Down
2 changes: 1 addition & 1 deletion logsapi/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (lc *Client) startHTTPServer() (string, error) {
return addr, nil
}

func (lc *Client) subscribe(types []SubscriptionType, extensionID string, uri string) error {
func (lc *Client) subscribe(types []SubscriptionType, extensionID, uri string) error {
data, err := json.Marshal(&SubscribeRequest{
SchemaVersion: SchemaVersionLatest,
LogTypes: types,
Expand Down
Loading