Skip to content

Commit

Permalink
Merge pull request #262 from ackama:setup-linting
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695612866
  • Loading branch information
copybara-github committed Nov 12, 2024
2 parents e4be496 + e831668 commit 4d135f3
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ on:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: 1.22.x

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
tests:
strategy:
matrix:
Expand Down
92 changes: 92 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# TODO(#274): this should match the configuration of osv-scanner for the most part
# currently it does not because using that config raises type errors,
# in addition to some of the rules having violations that need addressing,
# so the current focus is on getting as many linters as possible running

output:
sort-results: true
linters:
# TODO(#274): currently linting raises a type error, so until that's resolved we've got to be very selective in what we enable
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
# - containedctx
# - contextcheck
# - copyloopvar
- decorder
# - depguard
- dogsled
# - dupl
# - dupword
- durationcheck
# - errcheck
# - errchkjson
# - errname
# - errorlint
# - exhaustive
# - fatcontext
# - forbidigo
- ginkgolinter
- gocheckcompilerdirectives
# - gochecknoinits
- gochecksumtype
# - gocritic
# - gofmt
- goheader
# - goimports
- gomoddirectives
- gomodguard
- goprintffuncname
# - gosec
# - gosimple
- gosmopolitan
# - govet
- grouper
- importas
# - inamedparam
# - ineffassign
- interfacebloat
# - intrange
- loggercheck
- makezero
- mirror
# - misspell
# - musttag
- nakedret
# - nilerr
# - nilnil
# - nlreturn
# - noctx
- nolintlint
# - nosprintfhostport
# - paralleltest
# - perfsprint
# - prealloc
# - predeclared
- promlinter
# - protogetter
- reassign
# - revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
# - staticcheck
# - stylecheck
- tagalign
- tenv
- testableexamples
- testifylint
# - thelper
# - tparallel
# - unconvert
# - unparam
# - unused
# - usestdlibvars
# - wastedassign
# - whitespace
- zerologlint
disable-all: true
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ scalibr:
# go-sqlite3 used by the RPM extractor.
CGO_ENABLED=1 go build binary/scalibr/scalibr.go

lint:
go run github.com/golangci/golangci-lint/cmd/[email protected] run ./... --max-same-issues 0

test:
CGO_ENABLED=1 go test ./...

Expand Down

0 comments on commit 4d135f3

Please sign in to comment.