Skip to content

Commit

Permalink
chore: fixing code lint issues (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 authored Nov 3, 2023
1 parent 32bd680 commit 542c244
Show file tree
Hide file tree
Showing 26 changed files with 102 additions and 98 deletions.
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 @@ -134,12 +134,14 @@ func (f *ECSFormatter) Format(e *logrus.Entry) ([]byte, error) {
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 @@ func (f *ECSFormatter) Format(e *logrus.Entry) ([]byte, error) {
extraData[k] = v
}
}

if f.DataKey != "" && len(extraData) > 0 {
data[f.DataKey] = extraData
}
Expand Down
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

0 comments on commit 542c244

Please sign in to comment.