Skip to content

Commit 7c64930

Browse files
authored
FEATURE/fix-linter-issues (#529)
1 parent d21d0e2 commit 7c64930

File tree

102 files changed

+182
-223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+182
-223
lines changed

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ ifdef VERBOSE
123123
TESTVERBOSEOPTIONS := -v
124124
endif
125125

126-
SOURCES := $(shell find $(SRCDIR) -name '*.go' -not -path './test/*')
126+
SOURCES_QUERY := find $(SRCDIR) -name '*.go' -type f -not -path '$(SRCDIR)/tests/*' -not -path '$(SRCDIR)/vendor/*' -not -path '$(SRCDIR)/.gobuild/*' -not -path '$(SRCDIR)/deps/*' -not -path '$(SRCDIR)/tools/*'
127+
SOURCES := $(shell $(SOURCES_QUERY))
128+
SOURCES_PACKAGES := $(shell $(SOURCES_QUERY) -exec dirname {} \; | sort | uniq)
127129
DASHBOARDSOURCES := $(shell find $(DASHBOARDDIR)/src -name '*.js' -not -path './test/*') $(DASHBOARDDIR)/package.json
128130

129131
ifndef ARANGOSYNCSRCDIR
@@ -157,13 +159,22 @@ allall: all
157159
# Tip: Run `eval $(minikube docker-env)` before calling make if you're developing on minikube.
158160
#
159161

162+
GOLANGCI_ENABLED=deadcode gocyclo golint varcheck structcheck maligned errcheck \
163+
ineffassign interfacer unconvert goconst \
164+
megacheck
165+
166+
#GOLANGCI_ENABLED+=dupl - disable dupl check
167+
160168
.PHONY: fmt
161169
fmt:
162-
golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all --enable=deadcode --enable=gocyclo \
163-
--enable=golint --enable=varcheck --enable=structcheck --enable=maligned --enable=errcheck \
164-
--enable=dupl --enable=ineffassign --enable=interfacer --enable=unconvert --enable=goconst \
165-
--enable=gosec --enable=megacheck --exclude-use-default=false \
166-
$(ROOTDIR)/pkg/backup/...
170+
@goimports -w $(SOURCES)
171+
172+
.PHONY: linter
173+
linter: fmt
174+
@golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all \
175+
$(foreach MODE,$(GOLANGCI_ENABLED),--enable $(MODE) ) \
176+
--exclude-use-default=false \
177+
$(SOURCES_PACKAGES)
167178

168179
.PHONY: build
169180
build: docker docker-ubi manifests

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import (
3131
"strings"
3232
"time"
3333

34+
utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
35+
3436
"github.com/pkg/errors"
3537
"github.com/rs/zerolog"
3638
"github.com/spf13/cobra"
@@ -232,7 +234,7 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
232234
}); err != nil {
233235
cliLog.Fatal().Err(err).Msg("Failed to create HTTP server")
234236
} else {
235-
go svr.Run()
237+
go utilsError.LogError(cliLog, "error while starting service", svr.Run)
236238
}
237239

238240
// startChaos(context.Background(), cfg.KubeCli, cfg.Namespace, chaosLevel)

pkg/apis/backup/definitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ var (
3838
ArangoBackupShortNames = []string{"arangobackup"}
3939

4040
ArangoBackupPolicyShortNames = []string{"arangobackuppolicy"}
41-
)
41+
)

pkg/apis/backup/v1/backup_status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (a *ArangoBackupDetails) Equal(b *ArangoBackupDetails) bool {
8080
compareBoolPointer(a.Imported, b.Imported)
8181
}
8282

83-
func compareBoolPointer(a, b * bool) bool {
83+
func compareBoolPointer(a, b *bool) bool {
8484
if a == nil && b != nil || a != nil && b == nil {
8585
return false
8686
}
@@ -94,4 +94,4 @@ func compareBoolPointer(a, b * bool) bool {
9494
}
9595

9696
return false
97-
}
97+
}

pkg/apis/backup/v1/register.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ var (
3737
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
3838
AddToScheme = SchemeBuilder.AddToScheme
3939

40-
4140
SchemeGroupVersion = schema.GroupVersion{Group: backup.ArangoBackupGroupName, Version: ArangoBackupVersion}
4241
)
4342

pkg/apis/deployment/definitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ const (
3232

3333
var (
3434
ArangoDeploymentShortNames = []string{"arangodb", "arango"}
35-
)
35+
)

pkg/apis/deployment/v1/server_group_spec.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ func (s *ServerGroupSpecSecurityContext) NewSecurityContext() *v1.SecurityContex
125125
if caps := s.GetAddCapabilities(); caps != nil {
126126
capabilities.Add = []v1.Capability{}
127127

128-
for _, capability := range caps {
129-
capabilities.Add = append(capabilities.Add, capability)
130-
}
128+
capabilities.Add = append(capabilities.Add, caps...)
131129
}
132130

133131
r.Capabilities = capabilities

pkg/apis/replication/definitions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ package replication
2525
const (
2626
ArangoDeploymentReplicationResourceKind = "ArangoDeploymentReplication"
2727
ArangoDeploymentReplicationResourcePlural = "arangodeploymentreplications"
28-
ArangoDeploymentReplicationGroupName = "replication.database.arangodb.com"
28+
ArangoDeploymentReplicationGroupName = "replication.database.arangodb.com"
2929
)
3030

3131
var (
3232
ArangoDeploymentReplicationCRDName = ArangoDeploymentReplicationResourcePlural + "." + ArangoDeploymentReplicationGroupName
3333
ArangoDeploymentReplicationShortNames = []string{"arangorepl"}
34-
)
34+
)

pkg/backup/handlers/arango/backup/arango_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
package backup
2424

2525
import (
26-
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
2726
"net/http"
2827

28+
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
29+
2930
"github.com/arangodb/go-driver"
3031
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
3132
database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"

pkg/backup/handlers/arango/backup/arango_client_mock_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ func (m *mockArangoClientBackup) Abort(d driver.BackupTransferJobID) error {
9898
return m.state.errors.abortError
9999
}
100100

101-
if _, ok := m.state.progresses[d]; ok {
102-
delete(m.state.progresses, d)
103-
}
101+
delete(m.state.progresses, d)
104102

105103
return nil
106104
}
@@ -126,9 +124,7 @@ func (m *mockArangoClientBackup) Delete(id driver.BackupID) error {
126124
return m.state.errors.deleteError
127125
}
128126

129-
if _, ok := m.state.backups[id]; ok {
130-
delete(m.state.backups, id)
131-
}
127+
delete(m.state.backups, id)
132128

133129
return nil
134130
}

0 commit comments

Comments
 (0)