From a7a5d0011feed08bae498ae8804dc311ec3d45e7 Mon Sep 17 00:00:00 2001 From: Tit Petric Date: Mon, 23 Jul 2018 17:42:07 +0200 Subject: [PATCH] add(make): include gocritic checks with make critic --- Makefile | 8 +++++++- rbac/client.go | 2 +- rbac/sessions.go | 4 ++-- sam/service/team.go | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ae7f1f669..bef6d2dbc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build realize dep spec protobuf test test.rbac qa qa.test qa.vet codegen +.PHONY: build realize dep spec protobuf critic test test.rbac qa qa.test qa.vet codegen PKG = "github.com/$(shell cat .project)" @@ -11,6 +11,7 @@ SPEC = $(GOPATH)/bin/spec PROTOC = $(GOPATH)/bin/protoc-gen-go REALIZE = ${GOPATH}/bin/realize GOTEST = ${GOPATH}/bin/gotest +GOCRITIC = ${GOPATH}/bin/gocritic build: docker build --no-cache --rm -t $(shell cat .project) . @@ -39,6 +40,9 @@ protobuf: $(PROTOC) ######################################################################################################################## # QA +critic: $(GOCRITIC) + $(GOCRITIC) check-project . + test: $(GOTEST) $(GOTEST) -cover -v ./... @@ -70,6 +74,8 @@ $(SPEC): $(PROTOC): $(GOGET) github.com/golang/protobuf/protoc-gen-go +$(GOCRITIC): + $(GOGET) github.com/go-critic/go-critic/... clean.tools: rm -f $(SPEC) $(PROTOC) $(REALIZE) diff --git a/rbac/client.go b/rbac/client.go index 5a2886cb3..8a7fa4ec2 100644 --- a/rbac/client.go +++ b/rbac/client.go @@ -89,7 +89,7 @@ func (c *Client) Delete(url string) (*http.Response, error) { return c.Request("DELETE", url, nil) } -func (c *Client) Request(method string, url string, body interface{}) (*http.Response, error) { +func (c *Client) Request(method, url string, body interface{}) (*http.Response, error) { link := strings.TrimRight(c.config.baseURL, "/") + "/" + strings.TrimLeft(url, "/") if c.debugLevel == "info" { diff --git a/rbac/sessions.go b/rbac/sessions.go index 14ddcd3dd..0b5582560 100644 --- a/rbac/sessions.go +++ b/rbac/sessions.go @@ -13,7 +13,7 @@ type ( } SessionsInterface interface { - Create(sessionID string, username string, roles ...string) error + Create(sessionID, username string, roles ...string) error Get(sessionID string) (*types.Session, error) Delete(sessionID string) error @@ -30,7 +30,7 @@ const ( sessionsDeactivateRole = "/sessions/%s/deactivateRole" ) -func (u *Sessions) Create(sessionID string, username string, roles ...string) error { +func (u *Sessions) Create(sessionID, username string, roles ...string) error { body := struct { Username string `json:"username"` Roles []string `json:"roles,omitempty"` diff --git a/sam/service/team.go b/sam/service/team.go index 00386716f..921858ce7 100644 --- a/sam/service/team.go +++ b/sam/service/team.go @@ -74,12 +74,12 @@ func (svc team) Unarchive(ctx context.Context, id uint64) error { return svc.repository.Unarchive(ctx, id) } -func (svc team) Merge(ctx context.Context, id uint64, targetTeamId uint64) error { +func (svc team) Merge(ctx context.Context, id, targetTeamId uint64) error { // @todo: permission check if current user can merge team return svc.repository.Merge(ctx, id, targetTeamId) } -func (svc team) Move(ctx context.Context, id uint64, targetOrganisationId uint64) error { +func (svc team) Move(ctx context.Context, id, targetOrganisationId uint64) error { // @todo: permission check if current user can move team to another organisation return svc.repository.Move(ctx, id, targetOrganisationId) }