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

feat: define linting rules #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
60 changes: 60 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
run:
timeout: 3m
modules-download-mode: readonly
allow-parallel-runners: true
build-tags:
- docker

linters:
enable:
- errname
- gofmt
- goimports
- stylecheck
- importas
- errcheck
- gosimple
- govet
- ineffassign
- mirror
- misspell
- staticcheck
- tagalign
- testifylint
- typecheck
- unused
- unconvert
- unparam
- wastedassign
- whitespace
- protogetter
# TODO enable https://github.com/openfga/openfga/issues/598
# - bodyclose
# - contextcheck
# - exhaustive
# - errorlint
# - gochecknoglobals
# - gocritic
# - godot
# - gosec
# - noctx
# - inamedparam
# - perfsprint
# - prealloc
# - tparallel
linters-settings:
govet:
enable-all: true
disable:
- shadow
- fieldalignment
goimports:
local-prefixes: "github.com/openfga/openfga-contrib"
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
# Do not allow non-required aliases.
no-extra-aliases: false
alias:
- pkg: github.com/openfga/api/proto/openfga/v1
alias: openfgav1
1 change: 0 additions & 1 deletion middleware/authorizer/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

func UnaryServerInterceptor(authorizer Authorizer) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {

storeIDGetter, ok := req.(FGAStoreIDGetter)
if !ok {
// no storeID
Expand Down
3 changes: 2 additions & 1 deletion plugins/middleware/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (

"google.golang.org/grpc"

"github.com/openfga/openfga/pkg/plugin"

"github.com/openfga/openfga-contrib/middleware/authorizer"
"github.com/openfga/openfga-contrib/middleware/ratelimiter"
"github.com/openfga/openfga/pkg/plugin"
)

type mockAuthorizer struct{}
Expand Down
3 changes: 2 additions & 1 deletion plugins/storage/sqlite/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/openfga/openfga-contrib/storage/sqlite"
"github.com/openfga/openfga/pkg/plugin"

"github.com/openfga/openfga-contrib/storage/sqlite"
)

func InitPlugin(pm *plugin.PluginManager) error {
Expand Down