1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-28 13:48:49 +08:00
b1ackd0t 5e060d5620
NOISSUE - Add More Linters (#1924)
* Fix linting errors

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* feat(linters): add ineffassign linter

This commit adds the `ineffassign` linter to the project's `.golangci.yml` configuration file. The `ineffassign` linter helps identify and flag assignments to variables that are never used, helping to improve code quality and maintainability.

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* Add extra linters

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* feat(golangci): Add header check

- Added goheader check to ensure all files have license headers
- Added build tags for "nats" in the .golangci.yml file to include the necessary dependencies for the "nats" package during the build process.
- Also, increased the maximum number of issues per linter and the maximum number of same issues reported by the linter to improve the code quality analysis.

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* feat(.golangci.yml): Add new linters

Add the following new linters to the .golangci.yml configuration file:
- asasalint
- asciicheck
- bidichk
- contextcheck
- decorder
- dogsled
- errchkjson
- errname
- execinquery
- exportloopref
- ginkgolinter
- gocheckcompilerdirectives

These linters will help improve code quality and catch potential issues during the code review process.

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

---------

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
2023-10-16 11:43:33 +02:00

157 lines
4.1 KiB
Go

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package mocks
import (
context "context"
auth "github.com/mainflux/mainflux/auth"
"github.com/stretchr/testify/mock"
)
var (
_ auth.Authz = (*Authz)(nil)
_ auth.PolicyAgent = (*PolicyAgent)(nil)
)
type Authz struct {
mock.Mock
}
func (m *Authz) AddPolicies(ctx context.Context, token, object string, subjectIDs, relations []string) error {
ret := m.Called(ctx, token, object, subjectIDs, relations)
return ret.Error(0)
}
func (m *Authz) AddPolicy(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *Authz) Authorize(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *Authz) CountObjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(int), ret.Error(1)
}
func (m *Authz) CountSubjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(int), ret.Error(1)
}
func (m *Authz) DeletePolicies(ctx context.Context, token, object string, subjectIDs, relations []string) error {
ret := m.Called(ctx, token, object, subjectIDs, relations)
return ret.Error(0)
}
func (m *Authz) DeletePolicy(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *Authz) ListAllObjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
}
func (m *Authz) ListAllSubjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
}
func (m *Authz) ListObjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
ret := m.Called(ctx, pr, nextPageToken, limit)
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
}
func (m *Authz) ListSubjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
ret := m.Called(ctx, pr, nextPageToken, limit)
return ret.Get(0).(auth.PolicyPage), ret.Error(1)
}
type PolicyAgent struct {
mock.Mock
}
func (m *PolicyAgent) AddPolicies(ctx context.Context, prs []auth.PolicyReq) error {
ret := m.Called(ctx, prs)
return ret.Error(0)
}
func (m *PolicyAgent) AddPolicy(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *PolicyAgent) CheckPolicy(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *PolicyAgent) DeletePolicies(ctx context.Context, pr []auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *PolicyAgent) DeletePolicy(ctx context.Context, pr auth.PolicyReq) error {
ret := m.Called(ctx, pr)
return ret.Error(0)
}
func (m *PolicyAgent) RetrieveAllObjects(ctx context.Context, pr auth.PolicyReq) ([]auth.PolicyRes, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).([]auth.PolicyRes), ret.Error(1)
}
func (m *PolicyAgent) RetrieveAllObjectsCount(ctx context.Context, pr auth.PolicyReq) (int, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(int), ret.Error(1)
}
func (m *PolicyAgent) RetrieveAllSubjects(ctx context.Context, pr auth.PolicyReq) ([]auth.PolicyRes, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).([]auth.PolicyRes), ret.Error(1)
}
func (m *PolicyAgent) RetrieveAllSubjectsCount(ctx context.Context, pr auth.PolicyReq) (int, error) {
ret := m.Called(ctx, pr)
return ret.Get(0).(int), ret.Error(1)
}
func (m *PolicyAgent) RetrieveObjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) ([]auth.PolicyRes, string, error) {
ret := m.Called(ctx, pr, nextPageToken, limit)
return ret.Get(0).([]auth.PolicyRes), ret.String(1), ret.Error(2)
}
func (m *PolicyAgent) RetrieveSubjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) ([]auth.PolicyRes, string, error) {
ret := m.Called(ctx, pr, nextPageToken, limit)
return ret.Get(0).([]auth.PolicyRes), ret.String(1), ret.Error(2)
}