Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.24
go-version: 1.25
- uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
uses: golangci/golangci-lint-action@v8.0.0
with:
args: --timeout 3m --verbose --disable revive
version: v1.64.5
args: --timeout 3m --verbose
version: v2.4.0
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
&& sudo cp conftest /usr/local/bin/conftest
- uses: actions/setup-go@v3
with:
go-version: 1.24
go-version: 1.25
- uses: actions/checkout@v3
- run: make test-all
81 changes: 51 additions & 30 deletions .golangci.yml
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes were produced by running golangci-lint migrate. See https://golangci-lint.run/docs/product/migration-guide/#command-migrate for details

Original file line number Diff line number Diff line change
@@ -1,38 +1,59 @@
version: "2"
linters:
enable:
- errcheck
- dogsled
- dupword
- gochecknoinits
# We don't use goconst because it gives false positives in the tests.
# - goconst
- gofmt
# We don't use revive because it gives false positives in the tests.
# - revive
- gosec
- gosimple
- ineffassign
- staticcheck
- typecheck
- interfacebloat
- unconvert
- unused
- vet
- vetshadow
- dogsled
- dupword
- unparam
- interfacebloat
- usestdlibvars
- whitespace
issues:
exclude-rules:
- path: server/legacy/controllers/events/events_controller(.+)test.go
linters:
- dogsled
- path: server/legacy/events/event_parser_test.go
linters:
- dogsled
- path: server/legacy/events/command_runner_test.go
linters:
- dogsled
linters-settings:
interfacebloat:
max: 7
settings:
interfacebloat:
max: 7
staticcheck:
checks:
- all
- -QF1001
- -QF1007
- -QF1008
- -QF1011
- -ST1000
- -ST1003
- -ST1016
- -ST1020
- -ST1021
- -ST1022
- -ST1023
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dogsled
path: server/legacy/controllers/events/events_controller(.+)test.go
- linters:
- dogsled
path: server/legacy/events/event_parser_test.go
- linters:
- dogsled
path: server/legacy/events/command_runner_test.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ lint: ## Run linter locally
golangci-lint run

check-lint: ## Run linter in CI/CD. If running locally use 'lint'
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./bin v1.39.0
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ./bin v2.4.0
./bin/golangci-lint run -j 4 --timeout 5m

check-fmt: ## Fail if not formatted
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/runatlantis/atlantis

go 1.24
go 1.25

replace google.golang.org/grpc => google.golang.org/grpc v1.45.0

Expand Down
4 changes: 2 additions & 2 deletions server/config/parser_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ repos:
act, err := r.ParseGlobalCfg(path, valid.NewGlobalCfg("somedir"))

if c.expErr != "" {
expErr := strings.Replace(c.expErr, "<tmp>", path, -1)
expErr := strings.ReplaceAll(c.expErr, "<tmp>", path)
ErrEquals(t, expErr, err)
return
}
Expand Down Expand Up @@ -1405,7 +1405,7 @@ deployment_workflows:
act, err := r.ParseGlobalCfg(path, valid.NewGlobalCfg("somedir"))

if c.expErr != "" {
expErr := strings.Replace(c.expErr, "<tmp>", path, -1)
expErr := strings.ReplaceAll(c.expErr, "<tmp>", path)
ErrEquals(t, expErr, err)
return
}
Expand Down
2 changes: 1 addition & 1 deletion server/config/raw/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (p Project) ToValid(defaultWorkflowModeType valid.WorkflowModeType) valid.P
// support any characters that must be url escaped *except* for '/' because
// users like to name their projects to match the directory it's in.
func validProjectName(name string) bool {
nameWithoutSlashes := strings.Replace(name, "/", "-", -1)
nameWithoutSlashes := strings.ReplaceAll(name, "/", "-")
return nameWithoutSlashes == url.QueryEscape(nameWithoutSlashes)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request {
},
)
// Replace sha with expected sha.
requestJSONStr := strings.Replace(pullRequestOpenedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1)
requestJSONStr := strings.ReplaceAll(pullRequestOpenedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA)
req, err := http.NewRequest(http.MethodPost, "/events", bytes.NewBuffer([]byte(requestJSONStr)))
Ok(t, err)
req.Header.Set("Content-Type", "application/json")
Expand Down Expand Up @@ -820,7 +820,7 @@ func GitHubPullRequestReviewedEvent(t *testing.T, headSHA string) *http.Request
},
)
// Replace sha with expected sha.
requestJSONStr := strings.Replace(pullRequestReviewedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1)
requestJSONStr := strings.ReplaceAll(pullRequestReviewedJSON, "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA)
req, err := http.NewRequest(http.MethodPost, "/events", bytes.NewBuffer([]byte(requestJSONStr)))
Ok(t, err)
req.Header.Set("Content-Type", "application/json")
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/controllers/events/handlers/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (h *PullRequestEvent) Handle(ctx context.Context, request *http.BufferedReq
eventType := event.EventType

if !h.RepoAllowlistChecker.IsAllowlisted(baseRepo.FullName, baseRepo.VCSHost.Hostname) {
return fmt.Errorf("Pull request event from non-allowlisted repo \"%s/%s\"", baseRepo.VCSHost.Hostname, baseRepo.FullName)
return fmt.Errorf("Pull request event from non-allowlisted repo \"%s/%s\"", baseRepo.VCSHost.Hostname, baseRepo.FullName) // nolint:staticcheck
}

switch eventType {
Expand Down
3 changes: 2 additions & 1 deletion server/legacy/controllers/websocket/instrumented_mux.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package websocket

import (
"github.com/uber-go/tally/v4"
"net/http"

"github.com/uber-go/tally/v4"
)

type InstrumentedMultiplexor struct {
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/core/runtime/apply_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (a *ApplyStepRunner) remotePlanChanged(planfileContents string, applyOut st
// Strip plan output after the prompt to execute the plan.
planEndIdx := strings.Index(output, "Do you want to perform these actions in workspace \"")
if planEndIdx < 0 {
return fmt.Errorf("Couldn't find plan end when parsing apply output:\n%q", applyOut)
return fmt.Errorf("Couldn't find plan end when parsing apply output:\n%q", applyOut) // nolint:staticcheck
}
currPlan := strings.TrimSpace(output[:planEndIdx])

Expand Down
2 changes: 1 addition & 1 deletion server/legacy/core/runtime/policy/conftest_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *ConfTestExecutor) buildTitle(policySetNames []string) string {
}

func (c *ConfTestExecutor) sanitizeOutput(inputFile string, output string) string {
return strings.Replace(output, inputFile, "<redacted plan file>", -1)
return strings.ReplaceAll(output, inputFile, "<redacted plan file>")
}

func (c *ConfTestExecutor) processOutput(output string, policySet valid.PolicySet, err error) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestPreWorkflowHookRunner_Run(t *testing.T) {
// Replace $DIR in the exp with the actual temp dir. We do this
// here because when constructing the cases we don't yet know the
// temp dir.
expOut := strings.Replace(c.ExpOut, "$DIR", tmpDir, -1)
expOut := strings.ReplaceAll(c.ExpOut, "$DIR", tmpDir)
Equals(t, expOut, out)
})
}
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/core/runtime/run_step_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestRunStepRunner_Run(t *testing.T) {
// Replace $DIR in the exp with the actual temp dir. We do this
// here because when constructing the cases we don't yet know the
// temp dir.
expOut := strings.Replace(c.ExpOut, "$DIR", tmpDir, -1)
expOut := strings.ReplaceAll(c.ExpOut, "$DIR", tmpDir)
Equals(t, expOut, out)

terraform.VerifyWasCalledOnce().EnsureVersion(logger, projVersion)
Expand Down
4 changes: 2 additions & 2 deletions server/legacy/core/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func GetPlanFilename(workspace string, projName string) string {
if projName == "" {
return fmt.Sprintf("%s.tfplan", workspace)
}
projName = strings.Replace(projName, "/", planfileSlashReplace, -1)
projName = strings.ReplaceAll(projName, "/", planfileSlashReplace)
return fmt.Sprintf("%s-%s.tfplan", projName, workspace)
}

Expand All @@ -115,5 +115,5 @@ func ProjectNameFromPlanfile(workspace string, filename string) (string, error)
return "", nil
}
rawProjName := projMatch[0][1]
return strings.Replace(rawProjName, planfileSlashReplace, "/", -1), nil
return strings.ReplaceAll(rawProjName, planfileSlashReplace, "/"), nil
}
2 changes: 1 addition & 1 deletion server/legacy/events/command/project_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (p ProjectContext) GetShowResultFileName() string {
if p.ProjectName == "" {
return fmt.Sprintf("%s.json", p.Workspace)
}
projName := strings.Replace(p.ProjectName, "/", planfileSlashReplace, -1)
projName := strings.ReplaceAll(p.ProjectName, "/", planfileSlashReplace)
return fmt.Sprintf("%s-%s.json", projName, p.Workspace)
}

Expand Down
3 changes: 1 addition & 2 deletions server/legacy/events/command_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
lockingmocks "github.com/runatlantis/atlantis/server/legacy/core/locking/mocks"
"github.com/runatlantis/atlantis/server/legacy/events"
"github.com/runatlantis/atlantis/server/legacy/events/mocks"
eventmocks "github.com/runatlantis/atlantis/server/legacy/events/mocks"
"github.com/runatlantis/atlantis/server/legacy/events/mocks/matchers"
vcsmocks "github.com/runatlantis/atlantis/server/legacy/events/vcs/mocks"
"github.com/runatlantis/atlantis/server/models"
Expand Down Expand Up @@ -85,7 +84,7 @@ func setup(t *testing.T) *vcsmocks.MockClient {
Ok(t, err)

drainer = &events.Drainer{}
deleteLockCommand = eventmocks.NewMockDeleteLockCommand()
deleteLockCommand = mocks.NewMockDeleteLockCommand()
applyLockChecker = lockingmocks.NewMockApplyLockChecker()

dbUpdater = &events.DBUpdater{
Expand Down
3 changes: 2 additions & 1 deletion server/legacy/events/matchers/logging_logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/legacy/events/matchers/models_pullrequest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/legacy/events/matchers/models_repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions server/legacy/events/mock_workingdir_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/legacy/events/pending_plan_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestPendingPlanFinder_Find(t *testing.T) {
// Replace the actual dir with ??? to allow for comparison.
var actPlansComparable []events.PendingPlan
for _, p := range actPlans {
p.RepoDir = strings.Replace(p.RepoDir, tmpDir, "???", -1)
p.RepoDir = strings.ReplaceAll(p.RepoDir, tmpDir, "???")
actPlansComparable = append(actPlansComparable, p)
}
Equals(t, c.expPlans, actPlansComparable)
Expand Down
2 changes: 1 addition & 1 deletion server/legacy/events/project_command_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ projects:
"main.tf": fmt.Sprintf(baseVersionConfig, exactSymbols[0]),
},
"project2": map[string]interface{}{
"main.tf": strings.Replace(fmt.Sprintf(baseVersionConfig, exactSymbols[0]), "0.12.8", "0.12.9", -1),
"main.tf": strings.ReplaceAll(fmt.Sprintf(baseVersionConfig, exactSymbols[0]), "0.12.8", "0.12.9"),
},
},
ModifiedFiles: []string{"project1/main.tf", "project2/main.tf"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (b *SizeLimitedProjectCommandBuilder) CheckAgainstLimit(projects []command.
}

if b.Limit != InfiniteProjectsPerPR && len(planCommands) > b.Limit {
// nolint:staticcheck
return fmt.Errorf(
"Number of projects cannot exceed %d. This can either be caused by:\n"+
"1) GH failure in recognizing the diff\n"+
Expand Down
4 changes: 2 additions & 2 deletions server/legacy/events/vcs/fixtures/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func validateGithubToken(tokenString string) error {
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
// Don't forget to validate the alg is what you expect:
if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
err := fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
err := fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) // nolint:staticcheck

return nil, err
}
Expand All @@ -347,7 +347,7 @@ func validateGithubToken(tokenString string) error {
}

if claims, ok := token.Claims.(jwt.MapClaims); !ok || !token.Valid || claims["iss"] != "1" {
return fmt.Errorf("Invalid token")
return fmt.Errorf("Invalid token") // nolint:staticcheck
}
return nil
}
Expand Down
10 changes: 4 additions & 6 deletions server/legacy/events/vcs/github_client_lyft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,12 @@ func TestLyftGithubClient_PullisMergeable_BlockedStatus(t *testing.T) {
w.Write([]byte(pullResponse)) // nolint: errcheck
return
case "/api/v3/repos/owner/repo/commits/2/status?per_page=100":
_, _ = w.Write([]byte(
fmt.Sprintf(combinedStatusJSON, strings.Join(c.statuses, ",")),
)) // nolint: errcheck
_, _ = fmt.Fprintf(w,
combinedStatusJSON, strings.Join(c.statuses, ",")) // nolint: errcheck
return
case "/api/v3/repos/owner/repo/commits/2/check-runs?per_page=100":
_, _ = w.Write([]byte(
fmt.Sprintf(combinedChecksJSON, strings.Join(c.checks, ",")),
))
_, _ = fmt.Fprintf(w,
combinedChecksJSON, strings.Join(c.checks, ","))
return
default:
t.Errorf("got unexpected request at %q", r.RequestURI)
Expand Down
Loading