Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixing code lint issues #999

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/build/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const (
// GetBuildGraph represents the API handler to capture a
// directed a-cyclical graph for a build from the configured backend.
//
//nolint:funlen,goconst // ignore function length and constants
//nolint:funlen,goconst,gocyclo // ignore function length and constants
func GetBuildGraph(c *gin.Context) {
// capture middleware values
b := build.Retrieve(c)
Expand Down Expand Up @@ -425,6 +425,7 @@ func GetBuildGraph(c *gin.Context) {
if stage.Name == "init" {
cluster = BuiltInCluster
}

if stage.Name == "clone" {
cluster = BuiltInCluster
}
Expand Down
1 change: 0 additions & 1 deletion api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ func recordGauges(c *gin.Context) {
}
// check if the worker checked in within the last worker_active_interval
if worker.GetLastCheckedIn() >= before {

switch worker.GetStatus() {
case constants.WorkerStatusIdle:
idleWorkers++
Expand Down
2 changes: 1 addition & 1 deletion database/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func testRepo() *library.Repo {
type AnyArgument struct{}

// Match satisfies sqlmock.Argument interface.
func (a AnyArgument) Match(v driver.Value) bool {
func (a AnyArgument) Match(_ driver.Value) bool {
return true
}

Expand Down
1 change: 1 addition & 0 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type (
//
// * postgres
// * sqlite3
// .
func New(opts ...EngineOpt) (Interface, error) {
// create new database engine
e := new(engine)
Expand Down
2 changes: 1 addition & 1 deletion database/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func testSqlite(t *testing.T) *engine {
type AnyArgument struct{}

// Match satisfies sqlmock.Argument interface.
func (a AnyArgument) Match(v driver.Value) bool {
func (a AnyArgument) Match(_ driver.Value) bool {
return true
}

Expand Down
2 changes: 1 addition & 1 deletion database/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ func testPipeline() *library.Pipeline {
type AnyArgument struct{}

// Match satisfies sqlmock.Argument interface.
func (a AnyArgument) Match(v driver.Value) bool {
func (a AnyArgument) Match(_ driver.Value) bool {
return true
}
2 changes: 1 addition & 1 deletion database/repo/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,6 @@ func testRepo() *library.Repo {
type AnyArgument struct{}

// Match satisfies sqlmock.Argument interface.
func (a AnyArgument) Match(v driver.Value) bool {
func (a AnyArgument) Match(_ driver.Value) bool {
return true
}
2 changes: 1 addition & 1 deletion database/user/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ func testUser() *library.User {
type AnyArgument struct{}

// Match satisfies sqlmock.Argument interface.
func (a AnyArgument) Match(v driver.Value) bool {
func (a AnyArgument) Match(_ driver.Value) bool {
return true
}
4 changes: 2 additions & 2 deletions internal/token/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestTokenManager_Refresh(t *testing.T) {
}

defer func() {
db.DeleteUser(context.TODO(), u)
_ = db.DeleteUser(context.TODO(), u)
db.Close()
}()

Expand Down Expand Up @@ -112,7 +112,7 @@ func TestTokenManager_Refresh_Expired(t *testing.T) {
}

defer func() {
db.DeleteUser(context.TODO(), u)
_ = db.DeleteUser(context.TODO(), u)
db.Close()
}()

Expand Down
10 changes: 5 additions & 5 deletions router/middleware/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func TestBuild_Establish(t *testing.T) {
}

defer func() {
db.DeleteBuild(context.TODO(), want)
db.DeleteRepo(context.TODO(), r)
_ = db.DeleteBuild(context.TODO(), want)
_ = db.DeleteRepo(context.TODO(), r)
db.Close()
}()

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestBuild_Establish_NoBuildParameter(t *testing.T) {
}

defer func() {
db.DeleteRepo(context.TODO(), r)
_ = db.DeleteRepo(context.TODO(), r)
db.Close()
}()

Expand Down Expand Up @@ -219,7 +219,7 @@ func TestBuild_Establish_InvalidBuildParameter(t *testing.T) {
}

defer func() {
db.DeleteRepo(context.TODO(), r)
_ = db.DeleteRepo(context.TODO(), r)
db.Close()
}()

Expand Down Expand Up @@ -267,7 +267,7 @@ func TestBuild_Establish_NoBuild(t *testing.T) {
}

defer func() {
db.DeleteRepo(context.TODO(), r)
_ = db.DeleteRepo(context.TODO(), r)
db.Close()
}()

Expand Down
2 changes: 1 addition & 1 deletion router/middleware/claims/claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestClaims_Establish_BadToken(t *testing.T) {
}

defer func() {
db.DeleteUser(_context.TODO(), u)
_ = db.DeleteUser(_context.TODO(), u)
db.Close()
}()

Expand Down
3 changes: 3 additions & 0 deletions router/middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//
// It receives:
// 1. A time package format string (e.g. time.RFC3339).
func Logger(logger *logrus.Logger, timeFormat string) gin.HandlerFunc {

Check failure on line 42 in router/middleware/logger.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] router/middleware/logger.go#L42

unused-parameter: parameter 'timeFormat' seems to be unused, consider removing or renaming it as _ (revive)
Raw output
router/middleware/logger.go:42:36: unused-parameter: parameter 'timeFormat' seems to be unused, consider removing or renaming it as _ (revive)
func Logger(logger *logrus.Logger, timeFormat string) gin.HandlerFunc {
                                   ^
return func(c *gin.Context) {
start := time.Now()
// some evil middlewares modify this values
Expand Down Expand Up @@ -134,12 +134,14 @@
if f.DataKey != "" {
datahint = 2
}

data := make(logrus.Fields, datahint)
if len(e.Data) > 0 {
extraData := data
if f.DataKey != "" {
extraData = make(logrus.Fields, len(e.Data))
}

for k, v := range e.Data {
switch k {
case "ip":
Expand All @@ -160,6 +162,7 @@
extraData[k] = v
}
}

if f.DataKey != "" && len(extraData) > 0 {
data[f.DataKey] = extraData
}
Expand All @@ -181,5 +184,5 @@
TimestampFormat: "2006-01-02T15:04:05.000Z0700",
FieldMap: ecsFieldMap,
}
return jf.Format(e)

Check failure on line 187 in router/middleware/logger.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] router/middleware/logger.go#L187

return statements should not be cuddled if block has more than two lines (wsl)
Raw output
router/middleware/logger.go:187:2: return statements should not be cuddled if block has more than two lines (wsl)
	return jf.Format(e)
	^
}
2 changes: 1 addition & 1 deletion router/middleware/org/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestOrg_Establish(t *testing.T) {
}

defer func() {
db.DeleteRepo(context.TODO(), r)
_ = db.DeleteRepo(context.TODO(), r)
db.Close()
}()

Expand Down
Loading
Loading