Skip to content

chore: undo comments #10285

chore: undo comments

chore: undo comments #10285

This check has been archived and is scheduled for deletion. Learn more about checks retention
GitHub Actions / golangci failed Jul 28, 2023 in 1s

reviewdog [golangci] report

reported by reviewdog 🐶

Findings (47)

database/pipeline/create.go|5| 5-53 lines are duplicate of database/pipeline/update.go:5-54 (dupl)
database/pipeline/update.go|5| 5-54 lines are duplicate of database/pipeline/create.go:5-53 (dupl)
mock/server/schedule.go|5| 5-213 lines are duplicate of mock/server/secret.go:6-169 (dupl)
secret/native/count_test.go|37 col 18| Error return value of db.DeleteSecret is not checked (errcheck)
secret/native/create_test.go|40 col 18| Error return value of db.DeleteSecret is not checked (errcheck)
secret/native/create_test.go|89 col 18| Error return value of db.DeleteSecret is not checked (errcheck)
internal/token/refresh_test.go|54 col 16| Error return value of db.DeleteUser is not checked (errcheck)
internal/token/refresh_test.go|113 col 16| Error return value of db.DeleteUser is not checked (errcheck)
router/middleware/org/org_test.go|68 col 16| Error return value of db.DeleteRepo is not checked (errcheck)
router/middleware/worker/worker_test.go|61 col 18| Error return value of db.DeleteWorker is not checked (errcheck)
router/middleware/claims/claims_test.go|277 col 16| Error return value of db.DeleteUser is not checked (errcheck)
router/middleware/repo/repo_test.go|75 col 16| Error return value of db.DeleteRepo is not checked (errcheck)
router/middleware/build/build_test.go|92 col 17| Error return value of db.DeleteBuild is not checked (errcheck)
router/middleware/build/build_test.go|93 col 16| Error return value of db.DeleteRepo is not checked (errcheck)
router/middleware/pipeline/pipeline_test.go|105 col 20| Error return value of db.DeletePipeline is not checked (errcheck)
router/middleware/perm/perm_test.go|445 col 17| Error return value of db.DeleteBuild is not checked (errcheck)
router/middleware/perm/perm_test.go|534 col 17| Error return value of db.DeleteBuild is not checked (errcheck)
router/middleware/step/step_test.go|85 col 16| Error return value of db.DeleteStep is not checked (errcheck)
router/middleware/service/service_test.go|83 col 19| Error return value of db.DeleteService is not checked (errcheck)
cmd/vela-server/server.go|28| Function 'server' is too long (184 > 160) (funlen)
mock/server/authentication.go|43 col 9| string error has 3 occurrences, make it a constant (goconst)
database/database.go|79 col 13| Comment should end in a period (godot)
random/random.go|1 col 18| Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
version/version.go|1 col 18| Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
compiler/registry/doc.go|1 col 18| Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
database/resource.go|1 col 40| Actual: e. All rights reserved.
database/validate.go|1 col 40| Actual: e. All rights reserved.
database/validate_test.go|1 col 40| Actual: e. All rights reserved.
compiler/template/starlark/render.go|10| File is not goimports-ed (goimports)
cmd/vela-server/schedule.go|106 col 35| occurence is a misspelling of occurrence (misspell)
database/pipeline/pipeline_test.go|205 col 28| unused-parameter: parameter 'v' seems to be unused, consider removing or renaming it as _ (revive)
database/user/user_test.go|198 col 28| unused-parameter: parameter 'v' seems to be unused, consider removing or renaming it as _ (revive)
database/log/log_test.go|179 col 28| unused-parameter: parameter 'v' seems to be unused, consider removing or renaming it as _ (revive)
scm/github/authentication.go|60 col 31| unused-parameter: parameter 'w' seems to be unused, consider removing or renaming it as _ (revive)
compiler/native/parse_test.go|849 col 24| unused-parameter: parameter 'p' seems to be unused, consider removing or renaming it as _ (revive)
router/middleware/logger.go|30 col 36| unused-parameter: parameter 'timeFormat' seems to be unused, consider removing or renaming it as _ (revive)
api/metrics.go|443| unnecessary leading newline (whitespace)
router/router.go|139| unnecessary trailing newline (whitespace)
cmd/vela-server/schedule.go|275 col 3| expressions should not be cuddled with blocks (wsl)
database/schedule/create.go|5 col 1| directive //nolint:dupl // ignore similar code with update.go is unused for linter "dupl" (nolintlint)
compiler/native/compile.go|266 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|363 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|38 col 2| directive //nolint:staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)
secret/vault/get.go|41 col 2| directive //nolint:ineffassign,staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)
secret/vault/list.go|46 col 2| directive //nolint:staticcheck // ignore false positive is unused for linter "staticcheck" (nolintlint)
api/build/create.go|303 col 2| directive //nolint:dupl // ignore duplicate code is unused for linter "dupl" (nolintlint)
api/build/restart.go|294 col 2| directive //nolint:dupl // ignore duplicate code is unused for linter "dupl" (nolintlint)

Filtered Findings (0)

Annotations

Check failure on line 5 in database/pipeline/create.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/pipeline/create.go#L5

5-53 lines are duplicate of `database/pipeline/update.go:5-54` (dupl)
Raw output
database/pipeline/create.go:5: 5-53 lines are duplicate of `database/pipeline/update.go:5-54` (dupl)
package pipeline

import (
	"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(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 5 in database/pipeline/update.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/pipeline/update.go#L5

5-54 lines are duplicate of `database/pipeline/create.go:5-53` (dupl)
Raw output
database/pipeline/update.go:5: 5-54 lines are duplicate of `database/pipeline/create.go:5-53` (dupl)
package pipeline

import (
	"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(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 5 in mock/server/schedule.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] mock/server/schedule.go#L5

5-213 lines are duplicate of `mock/server/secret.go:6-169` (dupl)
Raw output
mock/server/schedule.go:5: 5-213 lines are duplicate of `mock/server/secret.go:6-169` (dupl)
package server

import (
	"encoding/json"
	"fmt"
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"
	"github.com/go-vela/types"
	"github.com/go-vela/types/library"
)

const (
	// ScheduleResp represents a JSON return for a single schedule.
	ScheduleResp = `{
	"id": 2,
	"active": true,
	"name": "foo",
	"entry": "@weekly",
	"created_at": 1683154980,
	"created_by": "octocat",
	"updated_at": 1683154980,
	"updated_by": "octocat",
	"scheduled_at": 0,
	"repo": {
		"id": 1,
		"user_id": 1,
		"org": "github",
		"name": "octocat",
		"full_name": "github/octocat",
		"link": "https://github.com/github/octocat",
		"clone": "https://github.com/github/octocat.git",
		"branch": "main",
		"topics": [],
		"build_limit": 10,
		"timeout": 30,
		"counter": 0,
		"visibility": "public",
		"private": false,
		"trusted": false,
		"active": true,
		"allow_pull": false,
		"allow_push": true,
		"allow_deploy": false,
		"allow_tag": false,
		"allow_comment": false,
		"pipeline_type": "yaml",
		"previous_name": ""
	}
}`
	SchedulesResp = `[
	{
		"id": 2,
		"active": true,
		"name": "foo",
		"entry": "@weekly",
		"created_at": 1683154980,
		"created_by": "octocat",
		"updated_at": 1683154980,
		"updated_by": "octocat",
		"scheduled_at": 0,
		"repo": {
			"id": 1,
			"user_id": 1,
			"org": "github",
			"name": "octokitty",
			"full_name": "github/octokitty",
			"link": "https://github.com/github/octokitty",
			"clone": "https://github.com/github/octokitty.git",
			"branch": "main",
			"topics": [],
			"build_limit": 10,
			"timeout": 30,
			"counter": 0,
			"visibility": "public",
			"private": false,
			"trusted": false,
			"active": true,
			"allow_pull": false,
			"allow_push": true,
			"allow_deploy": false,
			"allow_tag": false,
			"allow_comment": false,
			"pipeline_type": "yaml",
			"previous_name": ""
		}
	},
	{
		"id": 1,
		"active": true,
		"name": "bar",
		"entry": "@weekly",
		"created_at": 1683154974,
		"created_by": "octocat",
		"updated_at": 1683154974,
		"updated_by": "octocat",
		"scheduled_at": 0,
		"repo": {
			"id": 1,
			"user_id": 1,
			"org": "github",
			"name": "octokitty",
			"full_name": "github/octokitty",
			"link": "https://github.com/github/octokitty",
			"clone": "https://github.com/github/octokitty.git",
			"branch": "main",
			"topics": [],
			"build_limit": 10,
			"timeout": 30,
			"counter": 0,
			"visibility": "public",
			"private": false,
			"trusted": false,
			"active": true,
			"allow_pull": false,
			"allow_push": true,
			"allow_deploy": false,
			"allow_tag": false,
			"allow_comment": false,
			"pipeline_type": "yaml",
			"previous_name": ""
		}
	}
]`
)

// getSchedules returns mock JSON for a http GET.
func getSchedules(c *gin.Context) {
	data := []byte(SchedulesResp)

	var body []library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// getSchedule has a param :schedule returns mock JSON for a http GET.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func getSchedule(c *gin.Context) {
	s := c.Param("schedule")

	if strings.Contains(s, "not-found") {
		msg := fmt.Sprintf("Schedule %s does not exist", s)

		c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

		return
	}

	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// addSchedule returns mock JSON for a http POST.
func addSchedule(c *gin.Context) {
	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusCreated, body)
}

// updateSchedule has a param :schedule returns mock JSON for a http PUT.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func updateSchedule(c *gin.Context) {
	if !strings.Contains(c.FullPath(), "admin") {
		s := c.Param("schedule")

		if strings.Contains(s, "not-found") {
			msg := fmt.Sprintf("Schedule %s does not exist", s)

			c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

			return
		}
	}

	data := []byte(ScheduleResp)

	var body library.Schedule
	_ = json.Unmarshal(data, &body)

	c.JSON(http.StatusOK, body)
}

// removeSchedule has a param :schedule returns mock JSON for a http DELETE.
//
// Pass "not-found" to :schedule to test receiving a http 404 response.
func removeSchedule(c *gin.Context) {
	s := c.Param("schedule")

	if strings.Contains(s, "not-found") {
		msg := fmt.Sprintf("Schedule %s does not exist", s)

		c.AbortWithStatusJSON(http.StatusNotFound, types.Error{Message: &msg})

		return
	}

	c.JSON(http.StatusOK, fmt.Sprintf("schedule %s deleted", s))
}

Check failure on line 37 in secret/native/count_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] secret/native/count_test.go#L37

Error return value of `db.DeleteSecret` is not checked (errcheck)
Raw output
secret/native/count_test.go:37:18: Error return value of `db.DeleteSecret` is not checked (errcheck)
		db.DeleteSecret(sec)
		               ^

Check failure on line 40 in secret/native/create_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] secret/native/create_test.go#L40

Error return value of `db.DeleteSecret` is not checked (errcheck)
Raw output
secret/native/create_test.go:40:18: Error return value of `db.DeleteSecret` is not checked (errcheck)
		db.DeleteSecret(want)
		               ^

Check failure on line 89 in secret/native/create_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] secret/native/create_test.go#L89

Error return value of `db.DeleteSecret` is not checked (errcheck)
Raw output
secret/native/create_test.go:89:18: Error return value of `db.DeleteSecret` is not checked (errcheck)
		db.DeleteSecret(want)
		               ^

Check failure on line 54 in internal/token/refresh_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] internal/token/refresh_test.go#L54

Error return value of `db.DeleteUser` is not checked (errcheck)
Raw output
internal/token/refresh_test.go:54:16: Error return value of `db.DeleteUser` is not checked (errcheck)
		db.DeleteUser(u)
		             ^

Check failure on line 113 in internal/token/refresh_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] internal/token/refresh_test.go#L113

Error return value of `db.DeleteUser` is not checked (errcheck)
Raw output
internal/token/refresh_test.go:113:16: Error return value of `db.DeleteUser` is not checked (errcheck)
		db.DeleteUser(u)
		             ^

Check failure on line 68 in router/middleware/org/org_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/org/org_test.go#L68

Error return value of `db.DeleteRepo` is not checked (errcheck)
Raw output
router/middleware/org/org_test.go:68:16: Error return value of `db.DeleteRepo` is not checked (errcheck)
		db.DeleteRepo(r)
		             ^

Check failure on line 61 in router/middleware/worker/worker_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/worker/worker_test.go#L61

Error return value of `db.DeleteWorker` is not checked (errcheck)
Raw output
router/middleware/worker/worker_test.go:61:18: Error return value of `db.DeleteWorker` is not checked (errcheck)
		db.DeleteWorker(want)
		               ^

Check failure on line 277 in router/middleware/claims/claims_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/claims/claims_test.go#L277

Error return value of `db.DeleteUser` is not checked (errcheck)
Raw output
router/middleware/claims/claims_test.go:277:16: Error return value of `db.DeleteUser` is not checked (errcheck)
		db.DeleteUser(u)
		             ^

Check failure on line 75 in router/middleware/repo/repo_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/repo/repo_test.go#L75

Error return value of `db.DeleteRepo` is not checked (errcheck)
Raw output
router/middleware/repo/repo_test.go:75:16: Error return value of `db.DeleteRepo` is not checked (errcheck)
		db.DeleteRepo(want)
		             ^

Check failure on line 92 in router/middleware/build/build_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/build/build_test.go#L92

Error return value of `db.DeleteBuild` is not checked (errcheck)
Raw output
router/middleware/build/build_test.go:92:17: Error return value of `db.DeleteBuild` is not checked (errcheck)
		db.DeleteBuild(want)
		              ^

Check failure on line 93 in router/middleware/build/build_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/build/build_test.go#L93

Error return value of `db.DeleteRepo` is not checked (errcheck)
Raw output
router/middleware/build/build_test.go:93:16: Error return value of `db.DeleteRepo` is not checked (errcheck)
		db.DeleteRepo(r)
		             ^

Check failure on line 105 in router/middleware/pipeline/pipeline_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/pipeline/pipeline_test.go#L105

Error return value of `db.DeletePipeline` is not checked (errcheck)
Raw output
router/middleware/pipeline/pipeline_test.go:105:20: Error return value of `db.DeletePipeline` is not checked (errcheck)
		db.DeletePipeline(want)
		                 ^

Check failure on line 445 in router/middleware/perm/perm_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/perm/perm_test.go#L445

Error return value of `db.DeleteBuild` is not checked (errcheck)
Raw output
router/middleware/perm/perm_test.go:445:17: Error return value of `db.DeleteBuild` is not checked (errcheck)
		db.DeleteBuild(b)
		              ^

Check failure on line 534 in router/middleware/perm/perm_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/perm/perm_test.go#L534

Error return value of `db.DeleteBuild` is not checked (errcheck)
Raw output
router/middleware/perm/perm_test.go:534:17: Error return value of `db.DeleteBuild` is not checked (errcheck)
		db.DeleteBuild(b)
		              ^

Check failure on line 85 in router/middleware/step/step_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/step/step_test.go#L85

Error return value of `db.DeleteStep` is not checked (errcheck)
Raw output
router/middleware/step/step_test.go:85:16: Error return value of `db.DeleteStep` is not checked (errcheck)
		db.DeleteStep(want)
		             ^

Check failure on line 83 in router/middleware/service/service_test.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] router/middleware/service/service_test.go#L83

Error return value of `db.DeleteService` is not checked (errcheck)
Raw output
router/middleware/service/service_test.go:83:19: Error return value of `db.DeleteService` is not checked (errcheck)
		db.DeleteService(want)
		                ^

Check failure on line 28 in cmd/vela-server/server.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] cmd/vela-server/server.go#L28

Function 'server' is too long (184 > 160) (funlen)
Raw output
cmd/vela-server/server.go:28: Function 'server' is too long (184 > 160) (funlen)
func server(c *cli.Context) error {

Check failure on line 43 in mock/server/authentication.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] mock/server/authentication.go#L43

string `error` has 3 occurrences, make it a constant (goconst)
Raw output
mock/server/authentication.go:43:9: string `error` has 3 occurrences, make it a constant (goconst)
	err := "error"
	       ^

Check failure on line 79 in database/database.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] database/database.go#L79

Comment should end in a period (godot)
Raw output
database/database.go:79:13: Comment should end in a period (godot)
// * sqlite3
            ^

Check failure on line 1 in random/random.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] random/random.go#L1

Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
Raw output
random/random.go:1:18: Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
                 ^

Check failure on line 1 in version/version.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] version/version.go#L1

Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
Raw output
version/version.go:1:18: Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
                 ^

Check failure on line 1 in compiler/registry/doc.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] compiler/registry/doc.go#L1

Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
Raw output
compiler/registry/doc.go:1:18: Expected:2023, Actual: 2022 Target Brands, Inc. All rights reserved. (goheader)
// Copyright (c) 2022 Target Brands, Inc. All rights reserved.
                 ^