reviewdog [golangci] report
reported by reviewdog 🐶
Findings (47)
database/step/count.go|6| File is not goimports
-ed (goimports)
database/step/count_build.go|6| File is not goimports
-ed (goimports)
database/step/create.go|6| File is not goimports
-ed (goimports)
database/step/get_build.go|14 col 34| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
database/step/update.go|14 col 29| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
database/step/create.go|14 col 29| unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
compiler/native/expand.go|48| Function 'ExpandSteps' has too many statements (71 > 70) (funlen)
compiler/native/compile_test.go|1818 col 50| G601: Implicit memory aliasing in for loop. (gosec)
compiler/native/compile_test.go|3129 col 51| G601: Implicit memory aliasing in for loop. (gosec)
compiler/native/compile_test.go|3477 col 51| G601: Implicit memory aliasing in for loop. (gosec)
compiler/native/parse_test.go|861 col 24| unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
database/pipeline/create.go|3| 3-53 lines are duplicate of database/pipeline/update.go:3-54
(dupl)
database/pipeline/update.go|3| 3-54 lines are duplicate of database/pipeline/create.go:3-53
(dupl)
compiler/registry/github/github.go|41 col 21| string /api/v3/
has 5 occurrences, make it a constant (goconst)
secret/vault/refresh_test.go|45 col 74| unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|71 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|108 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|128 col 40| unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
secret/vault/refresh_test.go|201 col 74| unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
database/deployment/create.go|3| 3-33 lines are duplicate of database/deployment/update.go:3-32
(dupl)
database/deployment/update.go|3| 3-32 lines are duplicate of database/deployment/create.go:3-33
(dupl)
queue/redis/redis_test.go|95 col 2| _steps
is unused (deadcode)
database/resource.go|29 col 20| Non-inherited new context, use function like context.WithXXX
instead (contextcheck)
database/resource.go|40 col 25| Non-inherited new context, use function like context.WithXXX
instead (contextcheck)
database/resource.go|53 col 25| Non-inherited new context, use function like context.WithXXX
instead (contextcheck)
mock/server/schedule.go|3| 3-142 lines are duplicate of mock/server/secret.go:4-189
(dupl)
mock/server/authentication.go|41 col 9| string error
has 4 occurrences, make it a constant (goconst)
compiler/template/starlark/starlark.go|131 col 4| only one cuddle assignment allowed before if statement (wsl)
api/step/plan.go|41 col 48| not enough arguments in call to planStep
api/step/plan.go|71 col 4| s.SetCheckID undefined (type *library.Step has no field or method SetCheckID) (typecheck)
api/step/plan.go|74 col 9| no new variables on left side of := (typecheck)
api/build/create.go|323 col 59| not enough arguments in call to PlanBuild
api/build/restart.go|322 col 55| not enough arguments in call to PlanBuild
router/middleware/scm_test.go|12 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|653 col 76| s.GetCheckID undefined (type *library.Step has no field or method GetCheckID)) (typecheck)
router/middleware/perm/perm_test.go|22 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|653 col 76| s.GetCheckID undefined (type *library.Step has no field or method GetCheckID)) (typecheck)
router/middleware/pipeline/pipeline_test.go|25 col 2| could not import github.com/go-vela/server/scm/github (-: # github.com/go-vela/server/scm/github
scm/github/repo.go|653 col 76| s.GetCheckID undefined (type *library.Step has no field or method GetCheckID)) (typecheck)
scm/github/access.go|1| : # github.com/go-vela/server/scm/github [github.com/go-vela/server/scm/github.test]
scm/github/repo.go|653 col 76| s.GetCheckID undefined (type *library.Step has no field or method GetCheckID) (typecheck)
compiler/native/compile.go|259 col 1| directive //nolint:dupl,lll // linter thinks the steps and stages workflows are identical
is unused for linter "dupl" (nolintlint)
compiler/native/compile.go|356 col 1| directive //nolint:dupl,lll // linter thinks the steps and stages workflows are identical
is unused for linter "dupl" (nolintlint)
secret/vault/count.go|37 col 2| directive //nolint:staticcheck // ignore false positive
is unused for linter "staticcheck" (nolintlint)
secret/vault/get.go|40 col 2| directive //nolint:ineffassign,staticcheck // ignore false positive
is unused for linter "staticcheck" (nolintlint)
secret/vault/list.go|45 col 2| directive //nolint:staticcheck // ignore false positive
is unused for linter "staticcheck" (nolintlint)
database/schedule/create.go|3 col 1| directive //nolint:dupl // ignore similar code with update.go
is unused for linter "dupl" (nolintlint)
Filtered Findings (0)
Annotations
Check failure on line 6 in database/step/count.go
github-actions / golangci
[golangci] database/step/count.go#L6
File is not `goimports`-ed (goimports)
Raw output
database/step/count.go:6: File is not `goimports`-ed (goimports)
"context"
Check failure on line 6 in database/step/count_build.go
github-actions / golangci
[golangci] database/step/count_build.go#L6
File is not `goimports`-ed (goimports)
Raw output
database/step/count_build.go:6: File is not `goimports`-ed (goimports)
"context"
Check failure on line 6 in database/step/create.go
github-actions / golangci
[golangci] database/step/create.go#L6
File is not `goimports`-ed (goimports)
Raw output
database/step/create.go:6: File is not `goimports`-ed (goimports)
"context"
Check failure on line 14 in database/step/get_build.go
github-actions / golangci
[golangci] database/step/get_build.go#L14
unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
database/step/get_build.go:14:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (e *engine) GetStepForBuild(ctx context.Context, b *library.Build, number int) (*library.Step, error) {
^
Check failure on line 14 in database/step/update.go
github-actions / golangci
[golangci] database/step/update.go#L14
unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
database/step/update.go:14:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (e *engine) UpdateStep(ctx context.Context, s *library.Step) (*library.Step, error) {
^
Check failure on line 14 in database/step/create.go
github-actions / golangci
[golangci] database/step/create.go#L14
unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
database/step/create.go:14:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (e *engine) CreateStep(ctx context.Context, s *library.Step) (*library.Step, error) {
^
Check failure on line 48 in compiler/native/expand.go
github-actions / golangci
[golangci] compiler/native/expand.go#L48
Function 'ExpandSteps' has too many statements (71 > 70) (funlen)
Raw output
compiler/native/expand.go:48: Function 'ExpandSteps' has too many statements (71 > 70) (funlen)
func (c *client) ExpandSteps(s *yaml.Build, tmpls map[string]*yaml.Template, r *pipeline.RuleData, depth int) (*yaml.Build, error) {
Check failure on line 1818 in compiler/native/compile_test.go
github-actions / golangci
[golangci] compiler/native/compile_test.go#L1818
G601: Implicit memory aliasing in for loop. (gosec)
Raw output
compiler/native/compile_test.go:1818:50: G601: Implicit memory aliasing in for loop. (gosec)
compiler.WithRepo(&library.Repo{PipelineType: &tt.args.pipelineType})
^
Check failure on line 3129 in compiler/native/compile_test.go
github-actions / golangci
[golangci] compiler/native/compile_test.go#L3129
G601: Implicit memory aliasing in for loop. (gosec)
Raw output
compiler/native/compile_test.go:3129:51: G601: Implicit memory aliasing in for loop. (gosec)
compiler.WithRepo(&library.Repo{PipelineType: &tt.args.pipelineType})
^
Check failure on line 3477 in compiler/native/compile_test.go
github-actions / golangci
[golangci] compiler/native/compile_test.go#L3477
G601: Implicit memory aliasing in for loop. (gosec)
Raw output
compiler/native/compile_test.go:3477:51: G601: Implicit memory aliasing in for loop. (gosec)
compiler.WithRepo(&library.Repo{PipelineType: &tt.args.pipelineType})
^
Check failure on line 861 in compiler/native/parse_test.go
github-actions / golangci
[golangci] compiler/native/parse_test.go#L861
unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
compiler/native/parse_test.go:861:24: unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
func (FailReader) Read(p []byte) (n int, err error) {
^
Check failure on line 3 in database/pipeline/create.go
github-actions / golangci
[golangci] database/pipeline/create.go#L3
3-53 lines are duplicate of `database/pipeline/update.go:3-54` (dupl)
Raw output
database/pipeline/create.go:3: 3-53 lines are duplicate of `database/pipeline/update.go:3-54` (dupl)
package pipeline
import (
"context"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/database"
"github.com/go-vela/types/library"
"github.com/sirupsen/logrus"
)
// CreatePipeline creates a new pipeline in the database.
func (e *engine) CreatePipeline(ctx context.Context, p *library.Pipeline) (*library.Pipeline, error) {
e.logger.WithFields(logrus.Fields{
"pipeline": p.GetCommit(),
}).Tracef("creating pipeline %s in the database", p.GetCommit())
// cast the library type to database type
//
// https://pkg.go.dev/github.com/go-vela/types/database#PipelineFromLibrary
pipeline := database.PipelineFromLibrary(p)
// validate the necessary fields are populated
//
// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Validate
err := pipeline.Validate()
if err != nil {
return nil, err
}
// compress data for the pipeline
//
// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Compress
err = pipeline.Compress(e.config.CompressionLevel)
if err != nil {
return nil, err
}
// send query to the database
err = e.client.Table(constants.TablePipeline).Create(pipeline).Error
if err != nil {
return nil, err
}
err = pipeline.Decompress()
if err != nil {
return nil, err
}
return pipeline.ToLibrary(), nil
}
Check failure on line 3 in database/pipeline/update.go
github-actions / golangci
[golangci] database/pipeline/update.go#L3
3-54 lines are duplicate of `database/pipeline/create.go:3-53` (dupl)
Raw output
database/pipeline/update.go:3: 3-54 lines are duplicate of `database/pipeline/create.go:3-53` (dupl)
package pipeline
import (
"context"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/database"
"github.com/go-vela/types/library"
"github.com/sirupsen/logrus"
)
// UpdatePipeline updates an existing pipeline in the database.
func (e *engine) UpdatePipeline(ctx context.Context, p *library.Pipeline) (*library.Pipeline, error) {
e.logger.WithFields(logrus.Fields{
"pipeline": p.GetCommit(),
}).Tracef("updating pipeline %s in the database", p.GetCommit())
// cast the library type to database type
//
// https://pkg.go.dev/github.com/go-vela/types/database#PipelineFromLibrary
pipeline := database.PipelineFromLibrary(p)
// validate the necessary fields are populated
//
// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Validate
err := pipeline.Validate()
if err != nil {
return nil, err
}
// compress data for the pipeline
//
// https://pkg.go.dev/github.com/go-vela/types/database#Pipeline.Compress
err = pipeline.Compress(e.config.CompressionLevel)
if err != nil {
return nil, err
}
// send query to the database
err = e.client.Table(constants.TablePipeline).Save(pipeline).Error
if err != nil {
return nil, err
}
// decompress pipeline to return
err = pipeline.Decompress()
if err != nil {
return nil, err
}
return pipeline.ToLibrary(), nil
}
Check failure on line 41 in compiler/registry/github/github.go
github-actions / golangci
[golangci] compiler/registry/github/github.go#L41
string `/api/v3/` has 5 occurrences, make it a constant (goconst)
Raw output
compiler/registry/github/github.go:41:21: string `/api/v3/` has 5 occurrences, make it a constant (goconst)
c.API = c.URL + "/api/v3/"
^
Check failure on line 45 in secret/vault/refresh_test.go
github-actions / golangci
[golangci] secret/vault/refresh_test.go#L45
unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/refresh_test.go:45:74: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
^
Check failure on line 71 in secret/vault/refresh_test.go
github-actions / golangci
[golangci] secret/vault/refresh_test.go#L71
unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/refresh_test.go:71:40: unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
mockGetCallerIdentityRequest: func(in *sts.GetCallerIdentityInput) (*request.Request, *sts.GetCallerIdentityOutput) {
^
Check failure on line 108 in secret/vault/refresh_test.go
github-actions / golangci
[golangci] secret/vault/refresh_test.go#L108
unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/refresh_test.go:108:40: unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
mockGetCallerIdentityRequest: func(in *sts.GetCallerIdentityInput) (*request.Request, *sts.GetCallerIdentityOutput) {
^
Check failure on line 128 in secret/vault/refresh_test.go
github-actions / golangci
[golangci] secret/vault/refresh_test.go#L128
unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/refresh_test.go:128:40: unused-parameter: parameter 'in' seems to be unused, consider removing or renaming it as _ (revive)
mockGetCallerIdentityRequest: func(in *sts.GetCallerIdentityInput) (*request.Request, *sts.GetCallerIdentityOutput) {
^
Check failure on line 201 in secret/vault/refresh_test.go
github-actions / golangci
[golangci] secret/vault/refresh_test.go#L201
unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
secret/vault/refresh_test.go:201:74: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
^
Check failure on line 3 in database/deployment/create.go
github-actions / golangci
[golangci] database/deployment/create.go#L3
3-33 lines are duplicate of `database/deployment/update.go:3-32` (dupl)
Raw output
database/deployment/create.go:3: 3-33 lines are duplicate of `database/deployment/update.go:3-32` (dupl)
package deployment
import (
"context"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/database"
"github.com/go-vela/types/library"
"github.com/sirupsen/logrus"
)
// CreateDeployment creates a new deployment in the database.
func (e *engine) CreateDeployment(ctx context.Context, d *library.Deployment) (*library.Deployment, error) {
e.logger.WithFields(logrus.Fields{
"deployment": d.GetID(),
}).Tracef("creating deployment %d in the database", d.GetID())
// cast the library type to database type
deployment := database.DeploymentFromLibrary(d)
// validate the necessary fields are populated
err := deployment.Validate()
if err != nil {
return nil, err
}
result := e.client.Table(constants.TableDeployment).Create(deployment)
// send query to the database
return deployment.ToLibrary(d.Builds), result.Error
}
Check failure on line 3 in database/deployment/update.go
github-actions / golangci
[golangci] database/deployment/update.go#L3
3-32 lines are duplicate of `database/deployment/create.go:3-33` (dupl)
Raw output
database/deployment/update.go:3: 3-32 lines are duplicate of `database/deployment/create.go:3-33` (dupl)
package deployment
import (
"context"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/database"
"github.com/go-vela/types/library"
"github.com/sirupsen/logrus"
)
// UpdateDeployment updates an existing deployment in the database.
func (e *engine) UpdateDeployment(ctx context.Context, d *library.Deployment) (*library.Deployment, error) {
e.logger.WithFields(logrus.Fields{
"deployment": d.GetID(),
}).Tracef("updating deployment %d in the database", d.GetID())
// cast the library type to database type
deployment := database.DeploymentFromLibrary(d)
// validate the necessary fields are populated
err := deployment.Validate()
if err != nil {
return nil, err
}
result := e.client.Table(constants.TableDeployment).Save(deployment)
// send query to the database
return deployment.ToLibrary(d.Builds), result.Error
}
Check failure on line 95 in queue/redis/redis_test.go
github-actions / golangci
[golangci] queue/redis/redis_test.go#L95
`_steps` is unused (deadcode)
Raw output
queue/redis/redis_test.go:95:2: `_steps` is unused (deadcode)
_steps = &pipeline.Build{
^
Check failure on line 29 in database/resource.go
github-actions / golangci
[golangci] database/resource.go#L29
Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
database/resource.go:29:20: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
build.WithContext(e.ctx),
^
Check failure on line 40 in database/resource.go
github-actions / golangci
[golangci] database/resource.go#L40
Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
database/resource.go:40:25: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
executable.WithContext(e.ctx),
^
Check failure on line 53 in database/resource.go
github-actions / golangci
[golangci] database/resource.go#L53
Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
database/resource.go:53:25: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
deployment.WithContext(e.ctx),
^