chore: linting

This commit is contained in:
Kevin Franklin Kim 2021-11-19 14:16:09 +01:00
parent 54b4154426
commit 661f16e550
13 changed files with 51452 additions and 39 deletions

View File

@ -8,5 +8,5 @@ indent_style = tab
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{yaml,yml}] [*.{yaml,yml,md,mdx}]
indent_style = space indent_style = space

View File

@ -23,7 +23,7 @@ jobs:
run: | run: |
matrix=$(find . -type f -name "go.mod" -printf "{\"folder\":\"%h\"}," | sed -e 's/,$//') matrix=$(find . -type f -name "go.mod" -printf "{\"folder\":\"%h\"}," | sed -e 's/,$//')
echo "Matrix: $matrix" echo "Matrix: $matrix"
echo ::set-output name=matrix::{\"include\":[$(echo $matrix)]} echo "::set-output name=matrix::{\"include\":[$matrix]}"
go_lint: go_lint:
name: go lint name: go lint
needs: go_matrix needs: go_matrix

View File

@ -30,7 +30,6 @@ linters:
- bodyclose - bodyclose
- dogsled - dogsled
- dupl - dupl
- exhaustive
- exportloopref - exportloopref
- gci - gci
- goconst - goconst

View File

@ -16,24 +16,30 @@ check: test lint
test: test:
gotestsum --format short-verbose ./... gotestsum --format short-verbose ./...
lint%:files=$(shell find . -type f -name go.mod)
lint%:dirs=$(foreach file,$(files),$(dir $(file)) )
.PHONY: lint .PHONY: lint
## Run linter ## Run linter
lint: lint:
golangci-lint run @for dir in $(dirs); do cd $$dir && golangci-lint run; done
.PHONY: lint.fix .PHONY: lint.fix
## Fix lint violations ## Fix lint violations
lint.fix: lint.fix:
golangci-lint run --fix @for dir in $(dirs); do cd $$dir && golangci-lint run --fix; done
.PHONY: lint.super .PHONY: lint.super
## Run super linter ## Run super linter
lint.super: lint.super:
docker run --rm -it \ docker run --rm -it \
-e 'RUN_LOCAL=true' \ -e 'RUN_LOCAL=true' \
-e 'VALIDATE_ALL_CODEBASE=true' \ -e 'DEFAULT_BRANCH=main' \
-e 'VALIDATE_GO=true' \ -e 'IGNORE_GITIGNORED_FILES=true' \
-e 'VALIDATE_GITHUB_ACTIONS=true' \ -e 'VALIDATE_SHELL_SHFMT=false' \
-e 'VALIDATE_JSCPD=false' \
-e 'VALIDATE_BASH=false' \
-e 'VALIDATE_GO=false' \
-v $(PWD):/tmp/lint \ -v $(PWD):/tmp/lint \
github/super-linter github/super-linter

View File

@ -22,36 +22,36 @@ See the examples folder for usages
package main package main
import ( import (
"net/http" "net/http"
"github.com/foomo/keel" "github.com/foomo/keel"
) )
func main() { func main() {
svr := keel.NewServer( svr := keel.NewServer(
keel.WithHTTPZapService(true), keel.WithHTTPZapService(true),
keel.WithHTTPViperService(true), keel.WithHTTPViperService(true),
keel.WithHTTPPrometheusService(true), keel.WithHTTPPrometheusService(true),
) )
l := svr.Logger() l := svr.Logger()
svs := newService() svs := newService()
svr.AddService( svr.AddService(
keel.NewServiceHTTP(l, "demo", ":8080", svs), keel.NewServiceHTTP(l, "demo", ":8080", svs),
) )
svr.Run() svr.Run()
} }
func newService() *http.ServeMux { func newService() *http.ServeMux {
s := http.NewServeMux() s := http.NewServeMux()
s.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { s.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("OK")) _, _ = w.Write([]byte("OK"))
}) })
return s return s
} }
``` ```

View File

@ -37,4 +37,3 @@ func main() {
svr.Run() svr.Run()
} }

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"time" "time"
"github.com/google/uuid"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
@ -12,8 +13,6 @@ import (
"github.com/foomo/keel/example/persistence/mongo/store" "github.com/foomo/keel/example/persistence/mongo/store"
"github.com/foomo/keel/log" "github.com/foomo/keel/log"
keelmongo "github.com/foomo/keel/persistence/mongo" keelmongo "github.com/foomo/keel/persistence/mongo"
"github.com/google/uuid"
) )
// docker run -it --rm -p 27017:27017 mongo // docker run -it --rm -p 27017:27017 mongo

View File

@ -2,7 +2,6 @@ package repository
import ( import (
"context" "context"
"sync"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
@ -11,8 +10,7 @@ import (
) )
type DummyRepository struct { type DummyRepository struct {
collection *keelmongo.Collection collection *keelmongo.Collection
upsertMutex sync.Mutex
} }
// NewDummyRepository constructor // NewDummyRepository constructor

View File

@ -34,8 +34,7 @@ func (d *DateTimeCodec) DecodeValue(_ bsoncodec.DecodeContext, vr bsonrw.ValueRe
} }
var dateTimeVal DateTime var dateTimeVal DateTime
valueType := vr.Type() switch t := vr.Type(); t {
switch valueType {
case bsontype.DateTime: case bsontype.DateTime:
dt, err := vr.ReadDateTime() dt, err := vr.ReadDateTime()
if err != nil { if err != nil {
@ -49,7 +48,7 @@ func (d *DateTimeCodec) DecodeValue(_ bsoncodec.DecodeContext, vr bsonrw.ValueRe
} }
dateTimeVal = DateTime(decimalStr) dateTimeVal = DateTime(decimalStr)
default: default:
return fmt.Errorf("cannot decode %v into a DateTime", valueType) return fmt.Errorf("cannot decode %v into a DateTime", t)
} }
val.Set(reflect.ValueOf(dateTimeVal)) val.Set(reflect.ValueOf(dateTimeVal))

View File

@ -1,4 +1,4 @@
package jetstream package main
import ( import (
"context" "context"

View File

@ -1,4 +1,4 @@
package jetstream package main
import ( import (
"net/http" "net/http"

View File

@ -25,7 +25,7 @@ func main() {
// enable trace output (default: false) // enable trace output (default: false)
// OTEL_EXPORTER_STDOUT_TRACE_ENABLED="true" // OTEL_EXPORTER_STDOUT_TRACE_ENABLED="true"
// //
// pretty print ouput (default: true) // pretty print output (default: true)
// OTEL_EXPORTER_STDOUT_PRETTY_PRINT="true" // OTEL_EXPORTER_STDOUT_PRETTY_PRINT="true"
// //
// disable host metrics (default: true) // disable host metrics (default: true)

File diff suppressed because it is too large Load Diff