diff --git a/.golangci.yml b/.golangci.yml
index 63732fc9ac..b4c6d83c26 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -7,22 +7,26 @@ linters-settings:
ignore-words:
# for gitlab notes api
- noteable
+ revive:
+ rules:
+ - name: dot-imports
+ disabled: true
linters:
enable:
- - errcheck
- - gochecknoinits
- - gofmt
- - gosec
- - gosimple
- - ineffassign
- - misspell
- - revive
- - staticcheck
- - typecheck
- - unconvert
- - unused
- - vet
- - vetshadow
+ - errcheck
+ - gochecknoinits
+ - gofmt
+ - gosec
+ - gosimple
+ - ineffassign
+ - misspell
+ - revive
+ - staticcheck
+ - typecheck
+ - unconvert
+ - unused
+ - vet
+ - vetshadow
run:
timeout: 10m
diff --git a/cmd/server_test.go b/cmd/server_test.go
index 07a189f723..3e2c2e5c55 100644
--- a/cmd/server_test.go
+++ b/cmd/server_test.go
@@ -38,7 +38,7 @@ var passedConfig server.UserConfig
type ServerCreatorMock struct{}
-func (s *ServerCreatorMock) NewServer(userConfig server.UserConfig, config server.Config) (ServerStarter, error) {
+func (s *ServerCreatorMock) NewServer(userConfig server.UserConfig, _ server.Config) (ServerStarter, error) {
passedConfig = userConfig
return &ServerStarterMock{}, nil
}
diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go
index e1d2085293..786aeaf96c 100644
--- a/server/controllers/events/events_controller_e2e_test.go
+++ b/server/controllers/events/events_controller_e2e_test.go
@@ -53,11 +53,11 @@ var mockPreWorkflowHookRunner *runtimemocks.MockPreWorkflowHookRunner
var mockPostWorkflowHookRunner *runtimemocks.MockPostWorkflowHookRunner
-func (m *NoopTFDownloader) GetFile(dst, src string) error {
+func (m *NoopTFDownloader) GetFile(_, _ string) error {
return nil
}
-func (m *NoopTFDownloader) GetAny(dst, src string) error {
+func (m *NoopTFDownloader) GetAny(_, _ string) error {
return nil
}
@@ -1572,13 +1572,13 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers
type mockLockURLGenerator struct{}
-func (m *mockLockURLGenerator) GenerateLockURL(lockID string) string {
+func (m *mockLockURLGenerator) GenerateLockURL(_ string) string {
return "lock-url"
}
type mockWebhookSender struct{}
-func (w *mockWebhookSender) Send(log logging.SimpleLogging, result webhooks.ApplyResult) error {
+func (w *mockWebhookSender) Send(_ logging.SimpleLogging, _ webhooks.ApplyResult) error {
return nil
}
diff --git a/server/controllers/github_app_controller.go b/server/controllers/github_app_controller.go
index 06a1604136..670f13351c 100644
--- a/server/controllers/github_app_controller.go
+++ b/server/controllers/github_app_controller.go
@@ -85,7 +85,7 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques
}
// New redirects the user to create a new GitHub app
-func (g *GithubAppController) New(w http.ResponseWriter, r *http.Request) {
+func (g *GithubAppController) New(w http.ResponseWriter, _ *http.Request) {
if g.GithubSetupComplete {
g.respond(w, logging.Error, http.StatusBadRequest, "Atlantis already has GitHub credentials")
diff --git a/server/controllers/locks_controller.go b/server/controllers/locks_controller.go
index 3fce3f5ad6..85a4420430 100644
--- a/server/controllers/locks_controller.go
+++ b/server/controllers/locks_controller.go
@@ -32,7 +32,7 @@ type LocksController struct {
// LockApply handles creating a global apply lock.
// If Lock already exists it will be a no-op
-func (l *LocksController) LockApply(w http.ResponseWriter, r *http.Request) {
+func (l *LocksController) LockApply(w http.ResponseWriter, _ *http.Request) {
lock, err := l.ApplyLocker.LockApply()
if err != nil {
l.respond(w, logging.Error, http.StatusInternalServerError, "creating apply lock failed with: %s", err)
@@ -44,7 +44,7 @@ func (l *LocksController) LockApply(w http.ResponseWriter, r *http.Request) {
// UnlockApply handles releasing a global apply lock.
// If Lock doesn't exists it will be a no-op
-func (l *LocksController) UnlockApply(w http.ResponseWriter, r *http.Request) {
+func (l *LocksController) UnlockApply(w http.ResponseWriter, _ *http.Request) {
err := l.ApplyLocker.UnlockApply()
if err != nil {
l.respond(w, logging.Error, http.StatusInternalServerError, "deleting apply lock failed with: %s", err)
diff --git a/server/controllers/status_controller.go b/server/controllers/status_controller.go
index b26a52f04d..e35f3bc7bd 100644
--- a/server/controllers/status_controller.go
+++ b/server/controllers/status_controller.go
@@ -23,7 +23,7 @@ type StatusResponse struct {
}
// Get is the GET /status route.
-func (d *StatusController) Get(w http.ResponseWriter, r *http.Request) {
+func (d *StatusController) Get(w http.ResponseWriter, _ *http.Request) {
status := d.Drainer.GetStatus()
data, err := json.MarshalIndent(&StatusResponse{
ShuttingDown: status.ShuttingDown,
diff --git a/server/core/config/raw/step.go b/server/core/config/raw/step.go
index de69abc3dc..68f8899717 100644
--- a/server/core/config/raw/step.go
+++ b/server/core/config/raw/step.go
@@ -37,16 +37,16 @@ const (
//
// 2. A map for an env step with name and command or value, or a run step with a command and output config
// - env:
-// name: test
-// command: echo 312
-// value: value
+// name: test
+// command: echo 312
+// value: value
// - run:
-// command: my custom command
-// output: hide
+// command: my custom command
+// output: hide
//
// 3. A map for a built-in command and extra_args:
// - plan:
-// extra_args: [-var-file=staging.tfvars]
+// extra_args: [-var-file=staging.tfvars]
//
// 4. A map for a custom run command:
// - run: my custom command
diff --git a/server/core/db/boltdb_test.go b/server/core/db/boltdb_test.go
index e16a10d086..9ef5568467 100644
--- a/server/core/db/boltdb_test.go
+++ b/server/core/db/boltdb_test.go
@@ -286,9 +286,9 @@ func TestUnlockingMultiple(t *testing.T) {
_, _, err := b.TryLock(lock)
Ok(t, err)
- new := lock
- new.Project.RepoFullName = "new/repo"
- _, _, err = b.TryLock(new)
+ new1 := lock
+ new1.Project.RepoFullName = "new/repo"
+ _, _, err = b.TryLock(new1)
Ok(t, err)
new2 := lock
@@ -306,7 +306,7 @@ func TestUnlockingMultiple(t *testing.T) {
Ok(t, err)
_, err = b.Unlock(new2.Project, workspace)
Ok(t, err)
- _, err = b.Unlock(new.Project, workspace)
+ _, err = b.Unlock(new1.Project, workspace)
Ok(t, err)
_, err = b.Unlock(project, workspace)
Ok(t, err)
@@ -383,9 +383,9 @@ func TestUnlockByPullMatching(t *testing.T) {
Ok(t, err)
// add additional locks with the same repo and pull num but different paths/workspaces
- new := lock
- new.Project.Path = "dif/path"
- _, _, err = b.TryLock(new)
+ new1 := lock
+ new1.Project.Path = "dif/path"
+ _, _, err = b.TryLock(new1)
Ok(t, err)
new2 := lock
new2.Workspace = "new-workspace"
diff --git a/server/core/locking/locking.go b/server/core/locking/locking.go
index 78676dbaf3..e7c648a44b 100644
--- a/server/core/locking/locking.go
+++ b/server/core/locking/locking.go
@@ -166,7 +166,7 @@ func NewNoOpLocker() *NoOpLocker {
}
// TryLock attempts to acquire a lock to a project and workspace.
-func (c *NoOpLocker) TryLock(p models.Project, workspace string, pull models.PullRequest, user models.User) (TryLockResponse, error) {
+func (c *NoOpLocker) TryLock(p models.Project, workspace string, _ models.PullRequest, _ models.User) (TryLockResponse, error) {
return TryLockResponse{true, models.ProjectLock{}, c.key(p, workspace)}, nil
}
@@ -174,7 +174,7 @@ func (c *NoOpLocker) TryLock(p models.Project, workspace string, pull models.Pul
// a pointer to the now deleted lock will be returned. Else, that
// pointer will be nil. An error will only be returned if there was
// an error deleting the lock (i.e. not if there was no lock).
-func (c *NoOpLocker) Unlock(key string) (*models.ProjectLock, error) {
+func (c *NoOpLocker) Unlock(_ string) (*models.ProjectLock, error) {
return &models.ProjectLock{}, nil
}
@@ -186,7 +186,7 @@ func (c *NoOpLocker) List() (map[string]models.ProjectLock, error) {
}
// UnlockByPull deletes all locks associated with that pull request.
-func (c *NoOpLocker) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error) {
+func (c *NoOpLocker) UnlockByPull(_ string, _ int) ([]models.ProjectLock, error) {
return []models.ProjectLock{}, nil
}
@@ -194,7 +194,7 @@ func (c *NoOpLocker) UnlockByPull(repoFullName string, pullNum int) ([]models.Pr
// a pointer to the lock will be returned. Else, the pointer will be nil.
// An error will only be returned if there was an error getting the lock
// (i.e. not if there was no lock).
-func (c *NoOpLocker) GetLock(key string) (*models.ProjectLock, error) {
+func (c *NoOpLocker) GetLock(_ string) (*models.ProjectLock, error) {
return nil, nil
}
diff --git a/server/core/redis/redis.go b/server/core/redis/redis.go
index 6f7ee36a2a..030cd15b82 100644
--- a/server/core/redis/redis.go
+++ b/server/core/redis/redis.go
@@ -56,7 +56,7 @@ func New(hostname string, port int, password string, tlsEnabled bool, insecureSk
}
// NewWithClient is used for testing.
-func NewWithClient(client *redis.Client, bucket string, globalBucket string) (*RedisDB, error) {
+func NewWithClient(client *redis.Client, _ string, _ string) (*RedisDB, error) {
return &RedisDB{
client: client,
}, nil
@@ -82,12 +82,12 @@ func (r *RedisDB) TryLock(newLock models.ProjectLock) (bool, models.ProjectLock,
} else if err != nil {
// otherwise the lock fails, return to caller the run that's holding the lock
return false, currLock, errors.Wrap(err, "db transaction failed")
- } else {
- if err := json.Unmarshal([]byte(val), &currLock); err != nil {
- return false, currLock, errors.Wrap(err, "failed to deserialize current lock")
- }
- return false, currLock, nil
}
+
+ if err := json.Unmarshal([]byte(val), &currLock); err != nil {
+ return false, currLock, errors.Wrap(err, "failed to deserialize current lock")
+ }
+ return false, currLock, nil
}
// Unlock attempts to unlock the project and workspace.
@@ -103,13 +103,13 @@ func (r *RedisDB) Unlock(project models.Project, workspace string) (*models.Proj
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "db transaction failed")
- } else {
- if err := json.Unmarshal([]byte(val), &lock); err != nil {
- return nil, errors.Wrap(err, "failed to deserialize current lock")
- }
- r.client.Del(ctx, key)
- return &lock, nil
}
+
+ if err := json.Unmarshal([]byte(val), &lock); err != nil {
+ return nil, errors.Wrap(err, "failed to deserialize current lock")
+ }
+ r.client.Del(ctx, key)
+ return &lock, nil
}
// List lists all current locks.
@@ -144,15 +144,15 @@ func (r *RedisDB) GetLock(project models.Project, workspace string) (*models.Pro
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "db transaction failed")
- } else {
- var lock models.ProjectLock
- if err := json.Unmarshal([]byte(val), &lock); err != nil {
- return nil, errors.Wrapf(err, "deserializing lock at key %q", key)
- }
- // need to set it to Local after deserialization due to https://github.com/golang/go/issues/19486
- lock.Time = lock.Time.Local()
- return &lock, nil
}
+
+ var lock models.ProjectLock
+ if err := json.Unmarshal([]byte(val), &lock); err != nil {
+ return nil, errors.Wrapf(err, "deserializing lock at key %q", key)
+ }
+ // need to set it to Local after deserialization due to https://github.com/golang/go/issues/19486
+ lock.Time = lock.Time.Local()
+ return &lock, nil
}
// UnlockByPull deletes all locks associated with that pull request and returns them.
@@ -203,9 +203,9 @@ func (r *RedisDB) LockCommand(cmdName command.Name, lockTime time.Time) (*comman
return &lock, errors.Wrap(err, "db transaction failed")
} else if err != nil {
return nil, errors.Wrap(err, "db transaction failed")
- } else {
- return nil, errors.New("db transaction failed: lock already exists")
}
+
+ return nil, errors.New("db transaction failed: lock already exists")
}
func (r *RedisDB) UnlockCommand(cmdName command.Name) error {
@@ -215,9 +215,10 @@ func (r *RedisDB) UnlockCommand(cmdName command.Name) error {
return errors.New("db transaction failed: no lock exists")
} else if err != nil {
return errors.Wrap(err, "db transaction failed")
- } else {
- return r.client.Del(ctx, cmdLockKey).Err()
}
+
+ return r.client.Del(ctx, cmdLockKey).Err()
+
}
func (r *RedisDB) CheckCommandLock(cmdName command.Name) (*command.Lock, error) {
@@ -229,12 +230,12 @@ func (r *RedisDB) CheckCommandLock(cmdName command.Name) (*command.Lock, error)
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "db transaction failed")
- } else {
- if err := json.Unmarshal([]byte(val), &cmdLock); err != nil {
- return nil, errors.Wrap(err, "failed to deserialize Lock")
- }
- return &cmdLock, err
}
+
+ if err := json.Unmarshal([]byte(val), &cmdLock); err != nil {
+ return nil, errors.Wrap(err, "failed to deserialize Lock")
+ }
+ return &cmdLock, err
}
// UpdatePullWithResults updates pull's status with the latest project results.
@@ -367,13 +368,13 @@ func (r *RedisDB) getPull(key string) (*models.PullStatus, error) {
return nil, nil
} else if err != nil {
return nil, errors.Wrap(err, "db transaction failed")
- } else {
- var p models.PullStatus
- if err := json.Unmarshal([]byte(val), &p); err != nil {
- return nil, errors.Wrapf(err, "deserializing pull at %q with contents %q", key, val)
- }
- return &p, nil
}
+
+ var p models.PullStatus
+ if err := json.Unmarshal([]byte(val), &p); err != nil {
+ return nil, errors.Wrapf(err, "deserializing pull at %q with contents %q", key, val)
+ }
+ return &p, nil
}
func (r *RedisDB) writePull(key string, pull models.PullStatus) error {
diff --git a/server/core/redis/redis_test.go b/server/core/redis/redis_test.go
index 63bd1a0873..aeb203fd30 100644
--- a/server/core/redis/redis_test.go
+++ b/server/core/redis/redis_test.go
@@ -322,9 +322,9 @@ func TestUnlockingMultiple(t *testing.T) {
_, _, err := rdb.TryLock(lock)
Ok(t, err)
- new := lock
- new.Project.RepoFullName = "new/repo"
- _, _, err = rdb.TryLock(new)
+ new1 := lock
+ new1.Project.RepoFullName = "new/repo"
+ _, _, err = rdb.TryLock(new1)
Ok(t, err)
new2 := lock
@@ -342,7 +342,7 @@ func TestUnlockingMultiple(t *testing.T) {
Ok(t, err)
_, err = rdb.Unlock(new2.Project, workspace)
Ok(t, err)
- _, err = rdb.Unlock(new.Project, workspace)
+ _, err = rdb.Unlock(new1.Project, workspace)
Ok(t, err)
_, err = rdb.Unlock(project, workspace)
Ok(t, err)
@@ -419,9 +419,9 @@ func TestUnlockByPullMatching(t *testing.T) {
Ok(t, err)
// add additional locks with the same repo and pull num but different paths/workspaces
- new := lock
- new.Project.Path = "dif/path"
- _, _, err = rdb.TryLock(new)
+ new1 := lock
+ new1.Project.Path = "dif/path"
+ _, _, err = rdb.TryLock(new1)
Ok(t, err)
new2 := lock
new2.Workspace = "new-workspace"
diff --git a/server/core/runtime/apply_step_runner_test.go b/server/core/runtime/apply_step_runner_test.go
index 0e5e65bd4e..2a31040c81 100644
--- a/server/core/runtime/apply_step_runner_test.go
+++ b/server/core/runtime/apply_step_runner_test.go
@@ -361,7 +361,7 @@ type remoteApplyMock struct {
}
// RunCommandAsync fakes out running terraform async.
-func (r *remoteApplyMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan runtimemodels.Line) {
+func (r *remoteApplyMock) RunCommandAsync(_ command.ProjectContext, _ string, args []string, _ map[string]string, _ *version.Version, _ string) (chan<- string, <-chan runtimemodels.Line) {
r.CalledArgs = args
in := make(chan string)
diff --git a/server/core/runtime/plan_step_runner.go b/server/core/runtime/plan_step_runner.go
index 6bc312696c..64414ae324 100644
--- a/server/core/runtime/plan_step_runner.go
+++ b/server/core/runtime/plan_step_runner.go
@@ -296,7 +296,7 @@ locally at this time.
// using Terraform Cloud remote operations in TF 1.1.0 and above
var remoteOpsErr110 = `╷
│ Error: Saving a generated plan is currently not supported
-│
+│
│ Terraform Cloud does not support saving the generated execution plan
│ locally at this time.
╵
diff --git a/server/core/runtime/plan_step_runner_test.go b/server/core/runtime/plan_step_runner_test.go
index 0adf4866d4..6ec16ef0ca 100644
--- a/server/core/runtime/plan_step_runner_test.go
+++ b/server/core/runtime/plan_step_runner_test.go
@@ -193,9 +193,8 @@ Terraform will perform the following actions:
return []ReturnValue{"default", nil}
} else if tfArgs[0] == "plan" {
return []ReturnValue{rawOutput, nil}
- } else {
- return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
}
+ return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
})
actOutput, err := s.Run(command.ProjectContext{Workspace: "default"}, nil, "", map[string]string(nil))
Ok(t, err)
@@ -246,9 +245,8 @@ func TestRun_OutputOnErr(t *testing.T) {
return []ReturnValue{"default\n", nil}
} else if tfArgs[0] == "plan" {
return []ReturnValue{expOutput, errors.New(expErrMsg)}
- } else {
- return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
}
+ return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
})
actOutput, actErr := s.Run(command.ProjectContext{Workspace: "default"}, nil, "", map[string]string(nil))
ErrEquals(t, expErrMsg, actErr)
@@ -359,7 +357,7 @@ locally at this time.
tfVersion: "1.1.0",
remoteOpsErr: `╷
│ Error: Saving a generated plan is currently not supported
-│
+│
│ Terraform Cloud does not support saving the generated execution plan
│ locally at this time.
╵
@@ -545,7 +543,7 @@ type remotePlanMock struct {
CalledArgs []string
}
-func (r *remotePlanMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan runtimemodels.Line) {
+func (r *remotePlanMock) RunCommandAsync(_ command.ProjectContext, _ string, args []string, _ map[string]string, _ *version.Version, _ string) (chan<- string, <-chan runtimemodels.Line) {
r.CalledArgs = args
in := make(chan string)
out := make(chan runtimemodels.Line)
diff --git a/server/core/runtime/run_step_runner.go b/server/core/runtime/run_step_runner.go
index b38ba20f24..70d084506a 100644
--- a/server/core/runtime/run_step_runner.go
+++ b/server/core/runtime/run_step_runner.go
@@ -76,9 +76,8 @@ func (r *RunStepRunner) Run(ctx command.ProjectContext, command string, path str
if !ctx.CustomPolicyCheck {
ctx.Log.Debug("error: %s", err)
return "", err
- } else {
- ctx.Log.Debug("Treating custom policy tool error exit code as a policy failure. Error output: %s", err)
}
+ ctx.Log.Debug("Treating custom policy tool error exit code as a policy failure. Error output: %s", err)
}
switch postProcessOutput {
diff --git a/server/core/runtime/runtime.go b/server/core/runtime/runtime.go
index 4f54420cd6..52fc5180eb 100644
--- a/server/core/runtime/runtime.go
+++ b/server/core/runtime/runtime.go
@@ -64,7 +64,7 @@ type Runner interface {
// NullRunner is a runner that isn't configured for a given plan type but outputs nothing
type NullRunner struct{}
-func (p NullRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p NullRunner) Run(ctx command.ProjectContext, _ []string, _ string, _ map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for plan type")
return "", nil
}
@@ -72,7 +72,7 @@ func (p NullRunner) Run(ctx command.ProjectContext, extraArgs []string, path str
// RemoteBackendUnsupportedRunner is a runner that is responsible for outputting that the remote backend is unsupported
type RemoteBackendUnsupportedRunner struct{}
-func (p RemoteBackendUnsupportedRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p RemoteBackendUnsupportedRunner) Run(ctx command.ProjectContext, _ []string, _ string, _ map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for remote backend")
return "Remote backend is unsupported for this step.", nil
}
diff --git a/server/core/runtime/show_step_runner.go b/server/core/runtime/show_step_runner.go
index d7078bb7eb..e7c0f7ff14 100644
--- a/server/core/runtime/show_step_runner.go
+++ b/server/core/runtime/show_step_runner.go
@@ -27,7 +27,7 @@ type showStepRunner struct {
defaultTFVersion *version.Version
}
-func (p *showStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p *showStepRunner) Run(ctx command.ProjectContext, _ []string, path string, envs map[string]string) (string, error) {
tfVersion := p.defaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/core/runtime/version_step_runner.go b/server/core/runtime/version_step_runner.go
index 8485e12303..c75c5396fb 100644
--- a/server/core/runtime/version_step_runner.go
+++ b/server/core/runtime/version_step_runner.go
@@ -14,7 +14,7 @@ type VersionStepRunner struct {
}
// Run ensures a given version for the executable, builds the args from the project context and then runs executable returning the result
-func (v *VersionStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (v *VersionStepRunner) Run(ctx command.ProjectContext, _ []string, path string, envs map[string]string) (string, error) {
tfVersion := v.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/events/apply_command_runner_test.go b/server/events/apply_command_runner_test.go
index b4fe315496..c63945c662 100644
--- a/server/events/apply_command_runner_test.go
+++ b/server/events/apply_command_runner_test.go
@@ -249,7 +249,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
},
RunnerInvokeMatch: []*EqMatcher{
@@ -258,7 +258,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
},
ExpComment: "Ran Apply for 2 projects:\n\n" +
"1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---\n### " +
- "2. dir: `` workspace: ``\n**Apply Error**\n```\nShabang!\n```\n\n---",
+ "2. dir: `` workspace: ``\n**Apply Error**\n```\nshabang\n```\n\n---",
},
{
Description: "When first apply fails, the second not will run",
@@ -279,7 +279,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Apply,
@@ -290,7 +290,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
Once(),
Never(),
},
- ExpComment: "Ran Apply for dir: `` workspace: ``\n\n**Apply Error**\n```\nShabang!\n```",
+ ExpComment: "Ran Apply for dir: `` workspace: ``\n\n**Apply Error**\n```\nshabang\n```",
},
{
Description: "When both in a group of two succeeds, the following two will run",
@@ -324,7 +324,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Apply,
@@ -343,7 +343,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
},
ExpComment: "Ran Apply for 2 projects:\n\n" +
"1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---\n### " +
- "2. dir: `` workspace: ``\n**Apply Error**\n```\nShabang!\n```\n\n---",
+ "2. dir: `` workspace: ``\n**Apply Error**\n```\nshabang\n```\n\n---",
},
{
Description: "When one out of two fails, the following two will not run",
@@ -381,7 +381,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Apply,
@@ -397,7 +397,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
ExpComment: "Ran Apply for 4 projects:\n\n" +
"1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---\n### " +
"2. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---\n### " +
- "3. dir: `` workspace: ``\n**Apply Error**\n```\nShabang!\n```\n\n---\n### " +
+ "3. dir: `` workspace: ``\n**Apply Error**\n```\nshabang\n```\n\n---\n### " +
"4. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---",
},
{
@@ -417,7 +417,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Apply,
@@ -429,7 +429,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
Once(),
},
ExpComment: "Ran Apply for 2 projects:\n\n" +
- "1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n**Apply Error**\n```\nShabang!\n```\n\n---\n### " +
+ "1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n**Apply Error**\n```\nshabang\n```\n\n---\n### " +
"2. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---",
},
{
@@ -447,7 +447,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Apply,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Apply,
@@ -459,7 +459,7 @@ func TestApplyCommandRunner_ExecutionOrder(t *testing.T) {
Once(),
},
ExpComment: "Ran Apply for 2 projects:\n\n" +
- "1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n**Apply Error**\n```\nShabang!\n```\n\n---\n### " +
+ "1. dir: `` workspace: ``\n1. dir: `` workspace: ``\n\n### 1. dir: `` workspace: ``\n**Apply Error**\n```\nshabang\n```\n\n---\n### " +
"2. dir: `` workspace: ``\n```diff\nGreat success!\n```\n\n---",
},
}
diff --git a/server/events/command_runner.go b/server/events/command_runner.go
index e9e44b864f..8bb7dea1d2 100644
--- a/server/events/command_runner.go
+++ b/server/events/command_runner.go
@@ -425,7 +425,7 @@ func (c *DefaultCommandRunner) ensureValidRepoMetadata(
baseRepo models.Repo,
maybeHeadRepo *models.Repo,
maybePull *models.PullRequest,
- user models.User,
+ _ models.User,
pullNum int,
log logging.SimpleLogging,
) (headRepo models.Repo, pull models.PullRequest, err error) {
diff --git a/server/events/command_runner_internal_test.go b/server/events/command_runner_internal_test.go
index f80c718802..1241fecc55 100644
--- a/server/events/command_runner_internal_test.go
+++ b/server/events/command_runner_internal_test.go
@@ -284,18 +284,18 @@ func (m *MockCSU) UpdateCombinedCount(repo models.Repo, pull models.PullRequest,
return nil
}
-func (m *MockCSU) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name) error {
+func (m *MockCSU) UpdateCombined(_ models.Repo, _ models.PullRequest, _ models.CommitStatus, _ command.Name) error {
return nil
}
-func (m *MockCSU) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string, result *command.ProjectResult) error {
+func (m *MockCSU) UpdateProject(_ command.ProjectContext, _ command.Name, _ models.CommitStatus, _ string, _ *command.ProjectResult) error {
return nil
}
-func (m *MockCSU) UpdatePreWorkflowHook(pull models.PullRequest, status models.CommitStatus, hookDescription string, runtimeDescription string, url string) error {
+func (m *MockCSU) UpdatePreWorkflowHook(_ models.PullRequest, _ models.CommitStatus, _ string, _ string, _ string) error {
return nil
}
-func (m *MockCSU) UpdatePostWorkflowHook(pull models.PullRequest, status models.CommitStatus, hookDescription string, runtimeDescription string, url string) error {
+func (m *MockCSU) UpdatePostWorkflowHook(_ models.PullRequest, _ models.CommitStatus, _ string, _ string, _ string) error {
return nil
}
diff --git a/server/events/event_parser.go b/server/events/event_parser.go
index 379cba7bb5..e72247b07e 100644
--- a/server/events/event_parser.go
+++ b/server/events/event_parser.go
@@ -599,9 +599,8 @@ func (e *EventParser) ParseGitlabMergeRequestUpdateEvent(event gitlab.MergeEvent
// Check for MR that has been marked as ready
(strings.HasPrefix(event.Changes.Title.Previous, "Draft:") && !strings.HasPrefix(event.Changes.Title.Current, "Draft:")) {
return models.UpdatedPullEvent
- } else {
- return models.OtherPullEvent
}
+ return models.OtherPullEvent
}
// ParseGitlabMergeRequestEvent parses GitLab merge request events.
diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go
index c25ce7f87f..ae67c2478b 100644
--- a/server/events/event_parser_test.go
+++ b/server/events/event_parser_test.go
@@ -253,7 +253,8 @@ func TestParseGithubPullEvent_EventType(t *testing.T) {
t.Run(c.action, func(t *testing.T) {
// Test normal parsing
event := deepcopy.Copy(PullEvent).(github.PullRequestEvent)
- event.Action = &c.action
+ action := c.action
+ event.Action = &action
_, actType, _, _, _, err := parser.ParseGithubPullEvent(&event)
Ok(t, err)
Equals(t, c.exp, actType)
diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go
index e5c5b3e03e..bdcbc0df30 100644
--- a/server/events/markdown_renderer_test.go
+++ b/server/events/markdown_renderer_test.go
@@ -564,7 +564,7 @@ $$$
RepoRelDir: "path",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
- models.PolicySetResult{
+ {
PolicySetName: "policy1",
PolicyOutput: "4 tests, 4 passed, 0 warnings, 0 failures, 0 exceptions",
Passed: true,
@@ -581,7 +581,7 @@ $$$
ProjectName: "projectname",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
- models.PolicySetResult{
+ {
PolicySetName: "policy1",
PolicyOutput: "4 tests, 4 passed, 0 warnings, 0 failures, 0 exceptions",
Passed: true,
@@ -777,7 +777,7 @@ $$$
RepoRelDir: "path",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
- models.PolicySetResult{
+ {
PolicySetName: "policy1",
PolicyOutput: "4 tests, 4 passed, 0 warnings, 0 failures, 0 exceptions",
Passed: true,
@@ -793,7 +793,7 @@ $$$
Failure: "failure",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
- models.PolicySetResult{
+ {
PolicySetName: "policy1",
PolicyOutput: "4 tests, 2 passed, 0 warnings, 2 failures, 0 exceptions",
Passed: false,
@@ -1316,7 +1316,7 @@ func TestRenderCustomPolicyCheckTemplate_DisableApplyAll(t *testing.T) {
RepoRelDir: "path",
PolicyCheckResults: &models.PolicyCheckResults{
PolicySetResults: []models.PolicySetResult{
- models.PolicySetResult{
+ {
PolicySetName: "policy1",
PolicyOutput: "4 tests, 4 passed, 0 warnings, 0 failures, 0 exceptions",
Passed: true,
diff --git a/server/events/plan_command_runner_test.go b/server/events/plan_command_runner_test.go
index 8cc9f6c851..0e70d5c734 100644
--- a/server/events/plan_command_runner_test.go
+++ b/server/events/plan_command_runner_test.go
@@ -192,7 +192,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
},
RunnerInvokeMatch: []*EqMatcher{
@@ -221,7 +221,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
@@ -256,7 +256,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
@@ -306,7 +306,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
@@ -372,7 +372,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
},
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
@@ -407,7 +407,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
@@ -438,7 +438,7 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) {
ProjectResults: []command.ProjectResult{
{
Command: command.Plan,
- Error: errors.New("Shabang!"),
+ Error: errors.New("shabang"),
},
{
Command: command.Plan,
diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go
index 25f0e2c3e9..333d7173ce 100644
--- a/server/events/project_command_builder.go
+++ b/server/events/project_command_builder.go
@@ -119,7 +119,7 @@ func NewProjectCommandBuilder(
IncludeGitUntrackedFiles bool,
AutoDiscoverMode string,
scope tally.Scope,
- logger logging.SimpleLogging,
+ _ logging.SimpleLogging,
terraformClient terraform.Client,
) *DefaultProjectCommandBuilder {
return &DefaultProjectCommandBuilder{
diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go
index 6c3217fd24..2100c4a6cf 100644
--- a/server/events/project_command_builder_test.go
+++ b/server/events/project_command_builder_test.go
@@ -562,13 +562,14 @@ projects:
var actCtxs []command.ProjectContext
var err error
+ cmd := c.Cmd
if cmdName == command.Plan {
actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
- }, &c.Cmd)
+ }, &cmd)
} else {
- actCtxs, err = builder.BuildApplyCommands(&command.Context{Log: logger, Scope: scope}, &c.Cmd)
+ actCtxs, err = builder.BuildApplyCommands(&command.Context{Log: logger, Scope: scope}, &cmd)
}
if c.ExpErr != "" {
@@ -752,10 +753,11 @@ projects:
var actCtxs []command.ProjectContext
var err error
+ cmd := c.Cmd
actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
- }, &c.Cmd)
+ }, &cmd)
if c.ExpErr != "" {
ErrEquals(t, c.ExpErr, err)
@@ -1956,10 +1958,11 @@ func TestDefaultProjectCommandBuilder_BuildPlanCommands_Single_With_RestrictFile
var actCtxs []command.ProjectContext
var err error
+ cmd := c.Cmd
actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
- }, &c.Cmd)
+ }, &cmd)
if c.ExpErr != "" {
ErrEquals(t, c.ExpErr, err)
return
@@ -2068,10 +2071,11 @@ func TestDefaultProjectCommandBuilder_BuildPlanCommands_with_IncludeGitUntracked
var actCtxs []command.ProjectContext
var err error
+ cmd := c.Cmd
actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
- }, &c.Cmd)
+ }, &cmd)
if c.ExpErr != "" {
ErrEquals(t, c.ExpErr, err)
return
diff --git a/server/events/unlock_command_runner.go b/server/events/unlock_command_runner.go
index 648f829b9b..dd2b4c45ef 100644
--- a/server/events/unlock_command_runner.go
+++ b/server/events/unlock_command_runner.go
@@ -1,9 +1,10 @@
package events
import (
+ "slices"
+
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/vcs"
- "slices"
)
func NewUnlockCommandRunner(
@@ -29,10 +30,7 @@ type UnlockCommandRunner struct {
DisableUnlockLabel string
}
-func (u *UnlockCommandRunner) Run(
- ctx *command.Context,
- cmd *CommentCommand,
-) {
+func (u *UnlockCommandRunner) Run(ctx *command.Context, _ *CommentCommand) {
baseRepo := ctx.Pull.BaseRepo
pullNum := ctx.Pull.Num
disableUnlockLabel := u.DisableUnlockLabel
diff --git a/server/events/vcs/azuredevops_client.go b/server/events/vcs/azuredevops_client.go
index 5ff3f3ff38..429380d3f8 100644
--- a/server/events/vcs/azuredevops_client.go
+++ b/server/events/vcs/azuredevops_client.go
@@ -95,7 +95,7 @@ func (g *AzureDevopsClient) GetModifiedFiles(repo models.Repo, pull models.PullR
//
// If comment length is greater than the max comment length we split into
// multiple comments.
-func (g *AzureDevopsClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
+func (g *AzureDevopsClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error { //nolint: revive
sepEnd := "\n```\n" +
"\n
\n\n**Warning**: Output length greater than max comment size. Continued in next comment."
sepStart := "Continued from previous comment.\nShow Output
\n\n" +
@@ -134,7 +134,7 @@ func (g *AzureDevopsClient) ReactToComment(repo models.Repo, pullNum int, commen
return nil
}
-func (g *AzureDevopsClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error {
+func (g *AzureDevopsClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error { //nolint: revive
return nil
}
@@ -170,13 +170,13 @@ func (g *AzureDevopsClient) PullIsApproved(repo models.Repo, pull models.PullReq
return approvalStatus, nil
}
-func (g *AzureDevopsClient) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
+func (g *AzureDevopsClient) DiscardReviews(repo models.Repo, pull models.PullRequest) error { //nolint: revive
// TODO implement
return nil
}
// PullIsMergeable returns true if the merge request can be merged.
-func (g *AzureDevopsClient) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
+func (g *AzureDevopsClient) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) { //nolint: revive
owner, project, repoName := SplitAzureDevopsRepoFullName(repo.FullName)
opts := azuredevops.PullRequestGetOptions{IncludeWorkItemRefs: true}
@@ -390,16 +390,16 @@ func SplitAzureDevopsRepoFullName(repoFullName string) (owner string, project st
}
// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
-func (g *AzureDevopsClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
+func (g *AzureDevopsClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { //nolint: revive
return nil, nil
}
-func (g *AzureDevopsClient) SupportsSingleFileDownload(repo models.Repo) bool {
+func (g *AzureDevopsClient) SupportsSingleFileDownload(repo models.Repo) bool { //nolint: revive
return false
}
-func (g *AzureDevopsClient) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
- return false, []byte{}, fmt.Errorf("Not Implemented")
+func (g *AzureDevopsClient) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) { //nolint: revive
+ return false, []byte{}, fmt.Errorf("not implemented")
}
// GitStatusContextFromSrc parses an Atlantis formatted src string into a context suitable
@@ -421,10 +421,10 @@ func GitStatusContextFromSrc(src string) *azuredevops.GitStatusContext {
}
}
-func (g *AzureDevopsClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (g *AzureDevopsClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) { //nolint: revive
return "", fmt.Errorf("not yet implemented")
}
-func (g *AzureDevopsClient) GetPullLabels(repo models.Repo, pull models.PullRequest) ([]string, error) {
+func (g *AzureDevopsClient) GetPullLabels(_ models.Repo, _ models.PullRequest) ([]string, error) {
return nil, fmt.Errorf("not yet implemented")
}
diff --git a/server/events/vcs/azuredevops_client_test.go b/server/events/vcs/azuredevops_client_test.go
index da29b0dadf..1c6e142298 100644
--- a/server/events/vcs/azuredevops_client_test.go
+++ b/server/events/vcs/azuredevops_client_test.go
@@ -618,7 +618,9 @@ func TestAzureDevopsClient_GitStatusContextFromSrc(t *testing.T) {
for _, c := range cases {
result := vcs.GitStatusContextFromSrc(c.src)
- Equals(t, &c.expName, result.Name)
- Equals(t, &c.expGenre, result.Genre)
+ expName := c.expName
+ expGenre := c.expGenre
+ Equals(t, &expName, result.Name)
+ Equals(t, &expGenre, result.Genre)
}
}
diff --git a/server/events/vcs/bitbucketcloud/client.go b/server/events/vcs/bitbucketcloud/client.go
index fa1751db19..13462a7a51 100644
--- a/server/events/vcs/bitbucketcloud/client.go
+++ b/server/events/vcs/bitbucketcloud/client.go
@@ -85,7 +85,7 @@ func (b *Client) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]
}
// CreateComment creates a comment on the merge request.
-func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
+func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, _ string) error {
// NOTE: I tried to find the maximum size of a comment for bitbucket.org but
// I got up to 200k chars without issue so for now I'm not going to bother
// to detect this.
@@ -101,12 +101,12 @@ func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, co
}
// UpdateComment updates the body of a comment on the merge request.
-func (b *Client) ReactToComment(repo models.Repo, pullNum int, commentID int64, reaction string) error { // nolint revive
+func (b *Client) ReactToComment(_ models.Repo, _ int, _ int64, _ string) error {
// TODO: Bitbucket support for reactions
return nil
}
-func (b *Client) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error {
+func (b *Client) HidePrevCommandComments(_ models.Repo, _ int, _ string) error {
return nil
}
@@ -138,7 +138,7 @@ func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (appr
}
// PullIsMergeable returns true if the merge request has no conflicts and can be merged.
-func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
+func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, _ string) (bool, error) {
nextPageURL := fmt.Sprintf("%s/2.0/repositories/%s/pullrequests/%d/diffstat", b.BaseURL, repo.FullName, pull.Num)
// We'll only loop 1000 times as a safety measure.
maxLoops := 1000
@@ -207,7 +207,7 @@ func (b *Client) UpdateStatus(repo models.Repo, pull models.PullRequest, status
}
// MergePull merges the pull request.
-func (b *Client) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
+func (b *Client) MergePull(pull models.PullRequest, _ models.PullRequestOptions) error {
path := fmt.Sprintf("%s/2.0/repositories/%s/pullrequests/%d/merge", b.BaseURL, pull.BaseRepo.FullName, pull.Num)
_, err := b.makeRequest("POST", path, nil)
return err
@@ -234,7 +234,7 @@ func (b *Client) prepRequest(method string, path string, body io.Reader) (*http.
return req, nil
}
-func (b *Client) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
+func (b *Client) DiscardReviews(_ models.Repo, _ models.PullRequest) error {
// TODO implement
return nil
}
@@ -263,7 +263,7 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b
}
// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
-func (b *Client) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
+func (b *Client) GetTeamNamesForUser(_ models.Repo, _ models.User) ([]string, error) {
return nil, nil
}
@@ -274,14 +274,14 @@ func (b *Client) SupportsSingleFileDownload(models.Repo) bool {
// GetFileContent a repository file content from VCS (which support fetch a single file from repository)
// The first return value indicates whether the repo contains a file or not
// if BaseRepo had a file, its content will placed on the second return value
-func (b *Client) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
- return false, []byte{}, fmt.Errorf("Not Implemented")
+func (b *Client) GetFileContent(_ models.PullRequest, _ string) (bool, []byte, error) {
+ return false, []byte{}, fmt.Errorf("not implemented")
}
-func (b *Client) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (b *Client) GetCloneURL(_ models.VCSHostType, _ string) (string, error) {
return "", fmt.Errorf("not yet implemented")
}
-func (b *Client) GetPullLabels(repo models.Repo, pull models.PullRequest) ([]string, error) {
+func (b *Client) GetPullLabels(_ models.Repo, _ models.PullRequest) ([]string, error) {
return nil, fmt.Errorf("not yet implemented")
}
diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go
index 943fd3b6c8..9012c35e58 100644
--- a/server/events/vcs/bitbucketserver/client.go
+++ b/server/events/vcs/bitbucketserver/client.go
@@ -133,7 +133,7 @@ func (b *Client) GetProjectKey(repoName string, cloneURL string) (string, error)
// CreateComment creates a comment on the merge request. It will write multiple
// comments if a single comment is too long.
-func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
+func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, _ string) error {
sepEnd := "\n```\n**Warning**: Output length greater than max comment size. Continued in next comment."
sepStart := "Continued from previous comment.\n```diff\n"
comments := common.SplitComment(comment, maxCommentLength, sepEnd, sepStart)
@@ -145,11 +145,11 @@ func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string, co
return nil
}
-func (b *Client) ReactToComment(repo models.Repo, pullNum int, commentID int64, reaction string) error { // nolint: revive
+func (b *Client) ReactToComment(_ models.Repo, _ int, _ int64, _ string) error {
return nil
}
-func (b *Client) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error {
+func (b *Client) HidePrevCommandComments(_ models.Repo, _ int, _ string) error {
return nil
}
@@ -196,13 +196,13 @@ func (b *Client) PullIsApproved(repo models.Repo, pull models.PullRequest) (appr
return approvalStatus, nil
}
-func (b *Client) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
+func (b *Client) DiscardReviews(_ models.Repo, _ models.PullRequest) error {
// TODO implement
return nil
}
// PullIsMergeable returns true if the merge request has no conflicts and can be merged.
-func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
+func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, _ string) (bool, error) {
projectKey, err := b.GetProjectKey(repo.Name, repo.SanitizedCloneURL)
if err != nil {
return false, err
@@ -226,7 +226,7 @@ func (b *Client) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcss
}
// UpdateStatus updates the status of a commit.
-func (b *Client) UpdateStatus(repo models.Repo, pull models.PullRequest, status models.CommitStatus, src string, description string, url string) error {
+func (b *Client) UpdateStatus(_ models.Repo, pull models.PullRequest, status models.CommitStatus, src string, description string, url string) error {
bbState := "FAILED"
switch status {
case models.PendingCommitStatus:
@@ -347,25 +347,25 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b
}
// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
-func (b *Client) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
+func (b *Client) GetTeamNamesForUser(_ models.Repo, _ models.User) ([]string, error) {
return nil, nil
}
-func (b *Client) SupportsSingleFileDownload(repo models.Repo) bool {
+func (b *Client) SupportsSingleFileDownload(_ models.Repo) bool {
return false
}
// GetFileContent a repository file content from VCS (which support fetch a single file from repository)
// The first return value indicates whether the repo contains a file or not
// if BaseRepo had a file, its content will placed on the second return value
-func (b *Client) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
+func (b *Client) GetFileContent(_ models.PullRequest, _ string) (bool, []byte, error) {
return false, []byte{}, fmt.Errorf("not implemented")
}
-func (b *Client) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (b *Client) GetCloneURL(_ models.VCSHostType, _ string) (string, error) {
return "", fmt.Errorf("not yet implemented")
}
-func (b *Client) GetPullLabels(repo models.Repo, pull models.PullRequest) ([]string, error) {
+func (b *Client) GetPullLabels(_ models.Repo, _ models.PullRequest) ([]string, error) {
return nil, fmt.Errorf("not yet implemented")
}
diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go
index ab075fba03..64f8c84665 100644
--- a/server/events/vcs/github_client.go
+++ b/server/events/vcs/github_client.go
@@ -199,7 +199,7 @@ func (g *GithubClient) CreateComment(repo models.Repo, pullNum int, comment stri
}
// ReactToComment adds a reaction to a comment.
-func (g *GithubClient) ReactToComment(repo models.Repo, pullNum int, commentID int64, reaction string) error {
+func (g *GithubClient) ReactToComment(repo models.Repo, _ int, commentID int64, reaction string) error {
_, resp, err := g.client.Reactions.CreateIssueCommentReaction(g.ctx, repo.Owner, repo.Name, commentID, reaction)
g.logger.Debug("POST /repos/%v/%v/issues/comments/%d/reactions returned: %v", repo.Owner, repo.Name, commentID, resp.StatusCode)
return err
@@ -446,14 +446,11 @@ func (g *GithubClient) GetCombinedStatusMinusApply(repo models.Repo, pull *githu
if isRequiredCheck(*r.Name, required.RequiredStatusChecks.Contexts) {
if *c.Conclusion == "success" {
continue
- } else {
- return false, nil
}
- } else {
- //ignore checks that arent required
- continue
+ return false, nil
}
-
+ //ignore checks that arent required
+ continue
}
}
}
@@ -588,7 +585,7 @@ func (g *GithubClient) UpdateStatus(repo models.Repo, pull models.PullRequest, s
}
// MergePull merges the pull request.
-func (g *GithubClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
+func (g *GithubClient) MergePull(pull models.PullRequest, _ models.PullRequestOptions) error {
// Users can set their repo to disallow certain types of merging.
// We detect which types aren't allowed and use the type that is.
repo, resp, err := g.client.Repositories.Get(g.ctx, pull.BaseRepo.Owner, pull.BaseRepo.Name)
@@ -721,11 +718,11 @@ func (g *GithubClient) GetFileContent(pull models.PullRequest, fileName string)
return true, decodedData, nil
}
-func (g *GithubClient) SupportsSingleFileDownload(repo models.Repo) bool {
+func (g *GithubClient) SupportsSingleFileDownload(_ models.Repo) bool {
return true
}
-func (g *GithubClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (g *GithubClient) GetCloneURL(_ models.VCSHostType, repo string) (string, error) {
parts := strings.Split(repo, "/")
repository, resp, err := g.client.Repositories.Get(g.ctx, parts[0], parts[1])
g.logger.Debug("GET /repos/%v/%v returned: %v", parts[0], parts[1], resp.StatusCode)
diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go
index 84602c069c..3575da949a 100644
--- a/server/events/vcs/gitlab_client.go
+++ b/server/events/vcs/gitlab_client.go
@@ -171,14 +171,14 @@ func (g *GitlabClient) GetModifiedFiles(repo models.Repo, pull models.PullReques
}
// CreateComment creates a comment on the merge request.
-func (g *GitlabClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
+func (g *GitlabClient) CreateComment(repo models.Repo, pullNum int, comment string, _ string) error {
sepEnd := "\n```\n " +
"\n
\n\n**Warning**: Output length greater than max comment size. Continued in next comment."
sepStart := "Continued from previous comment.\nShow Output
\n\n" +
"```diff\n"
comments := common.SplitComment(comment, gitlabMaxCommentLength, sepEnd, sepStart)
for _, c := range comments {
- _, resp, err := g.Client.Notes.CreateMergeRequestNote(repo.FullName, pullNum, &gitlab.CreateMergeRequestNoteOptions{Body: gitlab.String(c)})
+ _, resp, err := g.Client.Notes.CreateMergeRequestNote(repo.FullName, pullNum, &gitlab.CreateMergeRequestNoteOptions{Body: gitlab.Ptr(c)})
g.logger.Debug("POST /projects/%s/merge_requests/%d/notes returned: %d", repo.FullName, pullNum, resp.StatusCode)
if err != nil {
return err
@@ -202,8 +202,8 @@ func (g *GitlabClient) HidePrevCommandComments(repo models.Repo, pullNum int, co
g.logger.Debug("/projects/%v/merge_requests/%d/notes", repo.FullName, pullNum)
comments, resp, err := g.Client.Notes.ListMergeRequestNotes(repo.FullName, pullNum,
&gitlab.ListMergeRequestNotesOptions{
- Sort: gitlab.String("asc"),
- OrderBy: gitlab.String("created_at"),
+ Sort: gitlab.Ptr("asc"),
+ OrderBy: gitlab.Ptr("created_at"),
ListOptions: gitlab.ListOptions{Page: nextPage},
})
g.logger.Debug("GET /projects/%s/merge_requests/%d/notes returned: %d", repo.FullName, pullNum, resp.StatusCode)
@@ -329,6 +329,7 @@ func (g *GitlabClient) PullIsMergeable(repo models.Repo, pull models.PullRequest
}
if ((ok && (mr.DetailedMergeStatus == "mergeable" || mr.DetailedMergeStatus == "ci_still_running")) ||
+ //nolint:staticcheck // SA1019 this check ensures compatibility with older gitlab versions
(!ok && mr.MergeStatus == "can_be_merged")) &&
mr.ApprovalsBeforeMerge <= 0 &&
mr.BlockingDiscussionsResolved &&
@@ -398,10 +399,10 @@ func (g *GitlabClient) UpdateStatus(repo models.Repo, pull models.PullRequest, s
_, resp, err := g.Client.Commits.SetCommitStatus(repo.FullName, pull.HeadCommit, &gitlab.SetCommitStatusOptions{
State: gitlabState,
- Context: gitlab.String(src),
- Description: gitlab.String(description),
+ Context: gitlab.Ptr(src),
+ Description: gitlab.Ptr(description),
TargetURL: &url,
- Ref: gitlab.String(refTarget),
+ Ref: gitlab.Ptr(refTarget),
})
g.logger.Debug("POST /projects/%s/statuses/%s returned: %d", repo.FullName, pull.HeadCommit, resp.StatusCode)
return err
@@ -471,7 +472,7 @@ func (g *GitlabClient) MarkdownPullLink(pull models.PullRequest) (string, error)
return fmt.Sprintf("!%d", pull.Num), nil
}
-func (g *GitlabClient) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
+func (g *GitlabClient) DiscardReviews(_ models.Repo, _ models.PullRequest) error {
// TODO implement
return nil
}
@@ -516,7 +517,7 @@ func MustConstraint(constraint string) version.Constraints {
}
// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to).
-func (g *GitlabClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
+func (g *GitlabClient) GetTeamNamesForUser(_ models.Repo, _ models.User) ([]string, error) {
return nil, nil
}
@@ -524,7 +525,7 @@ func (g *GitlabClient) GetTeamNamesForUser(repo models.Repo, user models.User) (
// The first return value indicates whether the repo contains a file or not
// if BaseRepo had a file, its content will placed on the second return value
func (g *GitlabClient) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
- opt := gitlab.GetRawFileOptions{Ref: gitlab.String(pull.HeadBranch)}
+ opt := gitlab.GetRawFileOptions{Ref: gitlab.Ptr(pull.HeadBranch)}
bytes, resp, err := g.Client.RepositoryFiles.GetRawFile(pull.BaseRepo.FullName, fileName, &opt)
g.logger.Debug("GET /projects/%s/repository/files/%s/raw returned: %d", pull.BaseRepo.FullName, fileName, resp.StatusCode)
@@ -539,11 +540,11 @@ func (g *GitlabClient) GetFileContent(pull models.PullRequest, fileName string)
return true, bytes, nil
}
-func (g *GitlabClient) SupportsSingleFileDownload(repo models.Repo) bool {
+func (g *GitlabClient) SupportsSingleFileDownload(_ models.Repo) bool {
return true
}
-func (g *GitlabClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (g *GitlabClient) GetCloneURL(_ models.VCSHostType, repo string) (string, error) {
project, resp, err := g.Client.Projects.GetProject(repo, nil)
g.logger.Debug("GET /projects/%s returned: %d", repo, resp.StatusCode)
if err != nil {
diff --git a/server/events/vcs/gitlab_client_test.go b/server/events/vcs/gitlab_client_test.go
index 112f35bcc5..2719e296fd 100644
--- a/server/events/vcs/gitlab_client_test.go
+++ b/server/events/vcs/gitlab_client_test.go
@@ -125,7 +125,7 @@ func TestGitlabClient_GetModifiedFiles(t *testing.T) {
switch r.RequestURI {
case "/api/v4/projects/lkysow%2Fatlantis-example/merge_requests/8312/changes?page=1&per_page=100":
w.WriteHeader(200)
- numAttempts += 1
+ numAttempts++
if numAttempts < c.attempts {
w.Write([]byte(changesPending)) // nolint: errcheck
t.Logf("returning changesPending for attempt %d", numAttempts)
@@ -332,7 +332,7 @@ func TestGitlabClient_PullIsMergeable(t *testing.T) {
statusName string
status models.CommitStatus
gitlabVersion []string
- mrId int
+ mrID int
expState bool
}{
{
@@ -442,7 +442,8 @@ func TestGitlabClient_PullIsMergeable(t *testing.T) {
Version string
}
v := version{Version: serverVersion}
- json.NewEncoder(w).Encode(v)
+ err := json.NewEncoder(w).Encode(v)
+ Ok(t, err)
default:
t.Errorf("got unexpected request at %q", r.RequestURI)
http.Error(w, "not found", http.StatusNotFound)
@@ -468,7 +469,7 @@ func TestGitlabClient_PullIsMergeable(t *testing.T) {
}
mergeable, err := client.PullIsMergeable(repo, models.PullRequest{
- Num: c.mrId,
+ Num: c.mrID,
BaseRepo: repo,
HeadCommit: "67cb91d3f6198189f433c045154a885784ba6977",
}, vcsStatusName)
@@ -554,7 +555,8 @@ func TestGitlabClient_HideOldComments(t *testing.T) {
case strings.HasPrefix(r.RequestURI, fmt.Sprintf("/api/v4/projects/runatlantis%%2Fatlantis/merge_requests/%d/notes/", pullNum)):
w.WriteHeader(http.StatusOK)
var body jsonBody
- json.NewDecoder(r.Body).Decode(&body)
+ err := json.NewDecoder(r.Body).Decode(&body)
+ Ok(t, err)
notePutCallDetail := notePutCallDetails{
noteID: path.Base(r.RequestURI),
comment: strings.Split(body.Body, "\n"),
diff --git a/server/events/vcs/not_configured_vcs_client.go b/server/events/vcs/not_configured_vcs_client.go
index 6ce6f2da56..c916195f3b 100644
--- a/server/events/vcs/not_configured_vcs_client.go
+++ b/server/events/vcs/not_configured_vcs_client.go
@@ -26,54 +26,54 @@ type NotConfiguredVCSClient struct {
Host models.VCSHostType
}
-func (a *NotConfiguredVCSClient) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]string, error) {
+func (a *NotConfiguredVCSClient) GetModifiedFiles(_ models.Repo, _ models.PullRequest) ([]string, error) {
return nil, a.err()
}
-func (a *NotConfiguredVCSClient) CreateComment(repo models.Repo, pullNum int, comment string, command string) error {
+func (a *NotConfiguredVCSClient) CreateComment(_ models.Repo, _ int, _ string, _ string) error {
return a.err()
}
-func (a *NotConfiguredVCSClient) HidePrevCommandComments(repo models.Repo, pullNum int, command string) error {
+func (a *NotConfiguredVCSClient) HidePrevCommandComments(_ models.Repo, _ int, _ string) error {
return nil
}
func (a *NotConfiguredVCSClient) ReactToComment(repo models.Repo, pullNum int, commentID int64, reaction string) error { // nolint: revive
return nil
}
-func (a *NotConfiguredVCSClient) PullIsApproved(repo models.Repo, pull models.PullRequest) (models.ApprovalStatus, error) {
+func (a *NotConfiguredVCSClient) PullIsApproved(_ models.Repo, _ models.PullRequest) (models.ApprovalStatus, error) {
return models.ApprovalStatus{}, a.err()
}
-func (a *NotConfiguredVCSClient) DiscardReviews(repo models.Repo, pull models.PullRequest) error {
+func (a *NotConfiguredVCSClient) DiscardReviews(_ models.Repo, _ models.PullRequest) error {
return nil
}
-func (a *NotConfiguredVCSClient) PullIsMergeable(repo models.Repo, pull models.PullRequest, vcsstatusname string) (bool, error) {
+func (a *NotConfiguredVCSClient) PullIsMergeable(_ models.Repo, _ models.PullRequest, _ string) (bool, error) {
return false, a.err()
}
-func (a *NotConfiguredVCSClient) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, src string, description string, url string) error {
+func (a *NotConfiguredVCSClient) UpdateStatus(_ models.Repo, _ models.PullRequest, _ models.CommitStatus, _ string, _ string, _ string) error {
return a.err()
}
-func (a *NotConfiguredVCSClient) MergePull(pull models.PullRequest, pullOptions models.PullRequestOptions) error {
+func (a *NotConfiguredVCSClient) MergePull(_ models.PullRequest, _ models.PullRequestOptions) error {
return a.err()
}
-func (a *NotConfiguredVCSClient) MarkdownPullLink(pull models.PullRequest) (string, error) {
+func (a *NotConfiguredVCSClient) MarkdownPullLink(_ models.PullRequest) (string, error) {
return "", a.err()
}
func (a *NotConfiguredVCSClient) err() error {
return fmt.Errorf("atlantis was not configured to support repos from %s", a.Host.String())
}
-func (a *NotConfiguredVCSClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) {
+func (a *NotConfiguredVCSClient) GetTeamNamesForUser(_ models.Repo, _ models.User) ([]string, error) {
return nil, a.err()
}
-func (a *NotConfiguredVCSClient) SupportsSingleFileDownload(repo models.Repo) bool {
+func (a *NotConfiguredVCSClient) SupportsSingleFileDownload(_ models.Repo) bool {
return false
}
-func (a *NotConfiguredVCSClient) GetFileContent(pull models.PullRequest, fileName string) (bool, []byte, error) {
+func (a *NotConfiguredVCSClient) GetFileContent(_ models.PullRequest, _ string) (bool, []byte, error) {
return true, []byte{}, a.err()
}
-func (a *NotConfiguredVCSClient) GetCloneURL(VCSHostType models.VCSHostType, repo string) (string, error) {
+func (a *NotConfiguredVCSClient) GetCloneURL(_ models.VCSHostType, _ string) (string, error) {
return "", a.err()
}
-func (a *NotConfiguredVCSClient) GetPullLabels(repo models.Repo, pull models.PullRequest) ([]string, error) {
+func (a *NotConfiguredVCSClient) GetPullLabels(_ models.Repo, _ models.PullRequest) ([]string, error) {
return nil, a.err()
}
diff --git a/server/events/webhooks/slack.go b/server/events/webhooks/slack.go
index 091297c74c..c55340cb95 100644
--- a/server/events/webhooks/slack.go
+++ b/server/events/webhooks/slack.go
@@ -43,7 +43,7 @@ func NewSlack(wr *regexp.Regexp, br *regexp.Regexp, channel string, client Slack
}
// Send sends the webhook to Slack if workspace and branch matches their respective regex.
-func (s *SlackWebhook) Send(log logging.SimpleLogging, applyResult ApplyResult) error {
+func (s *SlackWebhook) Send(_ logging.SimpleLogging, applyResult ApplyResult) error {
if !s.WorkspaceRegex.MatchString(applyResult.Workspace) || !s.BranchRegex.MatchString(applyResult.Pull.BaseBranch) {
return nil
}
diff --git a/server/events/working_dir.go b/server/events/working_dir.go
index a6b2c73656..d3a33b038b 100644
--- a/server/events/working_dir.go
+++ b/server/events/working_dir.go
@@ -132,10 +132,9 @@ func (w *FileWorkspace) Clone(
if w.CheckForUpstreamChanges && w.CheckoutMerge && w.recheckDiverged(p, headRepo, cloneDir) {
w.Logger.Info("base branch has been updated, using merge strategy and will clone again")
return cloneDir, true, w.mergeAgain(c)
- } else {
- w.Logger.Debug("repo is at correct commit %q so will not re-clone", p.HeadCommit)
- return cloneDir, false, nil
}
+ w.Logger.Debug("repo is at correct commit %q so will not re-clone", p.HeadCommit)
+ return cloneDir, false, nil
} else {
w.Logger.Debug("repo was already cloned but is not at correct commit, wanted %q got %q", p.HeadCommit, currCommit)
}
diff --git a/server/events/working_dir_test.go b/server/events/working_dir_test.go
index 8eae7c730d..f277c12e6b 100644
--- a/server/events/working_dir_test.go
+++ b/server/events/working_dir_test.go
@@ -3,13 +3,14 @@ package events_test
import (
"crypto/tls"
"fmt"
- "github.com/stretchr/testify/assert"
"net/http"
"os"
"path/filepath"
"strings"
"testing"
+ "github.com/stretchr/testify/assert"
+
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
diff --git a/server/jobs/project_command_output_handler.go b/server/jobs/project_command_output_handler.go
index 3a447ed4be..4634e779e9 100644
--- a/server/jobs/project_command_output_handler.go
+++ b/server/jobs/project_command_output_handler.go
@@ -267,21 +267,22 @@ func (p *AsyncProjectCommandOutputHandler) CleanUp(pullInfo PullInfo) {
// NoopProjectOutputHandler is a mock that doesn't do anything
type NoopProjectOutputHandler struct{}
-func (p *NoopProjectOutputHandler) Send(ctx command.ProjectContext, msg string, isOperationComplete bool) {
+func (p *NoopProjectOutputHandler) Send(_ command.ProjectContext, _ string, _ bool) {
}
-func (p *NoopProjectOutputHandler) SendWorkflowHook(ctx models.WorkflowHookCommandContext, msg string, operationComplete bool) {
+func (p *NoopProjectOutputHandler) SendWorkflowHook(_ models.WorkflowHookCommandContext, _ string, _ bool) {
}
-func (p *NoopProjectOutputHandler) Register(jobID string, receiver chan string) {}
-func (p *NoopProjectOutputHandler) Deregister(jobID string, receiver chan string) {}
+func (p *NoopProjectOutputHandler) Register(_ string, _ chan string) {}
+
+func (p *NoopProjectOutputHandler) Deregister(_ string, _ chan string) {}
func (p *NoopProjectOutputHandler) Handle() {
}
-func (p *NoopProjectOutputHandler) CleanUp(pullInfo PullInfo) {
+func (p *NoopProjectOutputHandler) CleanUp(_ PullInfo) {
}
-func (p *NoopProjectOutputHandler) IsKeyExists(key string) bool {
+func (p *NoopProjectOutputHandler) IsKeyExists(_ string) bool {
return false
}
diff --git a/server/jobs/project_command_output_handler_test.go b/server/jobs/project_command_output_handler_test.go
index 71e9abcced..4cd934c5fb 100644
--- a/server/jobs/project_command_output_handler_test.go
+++ b/server/jobs/project_command_output_handler_test.go
@@ -191,7 +191,7 @@ func TestProjectCommandOutputHandler(t *testing.T) {
// read from channel
go func() {
- for range ch {
+ for range ch { //revive:disable-line:empty-block
}
}()
@@ -225,7 +225,7 @@ func TestProjectCommandOutputHandler(t *testing.T) {
// read from channel
go func() {
- for range ch {
+ for range ch { //revive:disable-line:empty-block
}
}()
@@ -240,7 +240,7 @@ func TestProjectCommandOutputHandler(t *testing.T) {
// buffer channel will be closed immediately after logs are streamed
go func() {
- for range ch2 {
+ for range ch2 { //revive:disable-line:empty-block
}
opComplete <- true
}()
diff --git a/server/server.go b/server/server.go
index adf74ed300..d92c9c2fd8 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1005,7 +1005,8 @@ func (s *Server) Start() error {
s.Logger.Err(err.Error())
}
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) // nolint: vet
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
if err := server.Shutdown(ctx); err != nil {
return fmt.Errorf("while shutting down: %s", err)
}