Skip to content
Closed
Show file tree
Hide file tree
Changes from 11 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
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
with:
go-version: '1.22.6'
cache: true
- name: install
run: make install-tools
- name: lint
run: make lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.7.2
# - name: Report Status
# if: always()
# uses: ravsamhq/notify-slack-action@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dist/
# binary
brev-cli
brev
brev-local

# golang executable
go1.*
Expand Down
102 changes: 102 additions & 0 deletions .golangci.bck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
linters-settings:
goimports:
local-prefixes: github.com/brevdev/brev-cli
revive:
min-confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
gocyclo:
min-complexity: 16
govet:
check-shadowing: true
misspell:
locale: US
nolintlint:
allow-leading-space: false # require machine-readable nolint directives (with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: true # require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
funlen:
lines: 100
wrapcheck:
ignoreSigs:
- .WrapAndTrace
- .Errorf
- .Wrap
- .New
stylecheck:
checks: ["all", "-ST1020", "-ST1000"]

run:
build-tags:
- codeanalysis

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
# - staticcheck
- typecheck
- unused
- bodyclose
# - depguard
- dupl
- exportloopref
- forcetypeassert
- funlen
# - gci
- gocognit
# - goconst
- gocritic
- gocyclo
# - godot
- gofumpt
# - revive
# - gomnd
- goprintffuncname
- gosec
# - ifshort
- misspell
- noctx
- nolintlint
- rowserrcheck
- sqlclosecheck
- stylecheck
- thelper
- tparallel
- unconvert
- unparam
# - whitespace
# - errorlint
# - goerr113
- wrapcheck
issues:
# enable issues excluded by default
exclude-use-default: false
163 changes: 86 additions & 77 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,111 @@
linters-settings:
goimports:
local-prefixes: github.com/brevdev/brev-cli
revive:
min-confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
gocyclo:
min-complexity: 16
govet:
check-shadowing: true
misspell:
locale: US
nolintlint:
allow-leading-space: false # require machine-readable nolint directives (with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: true # require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
funlen:
lines: 100
wrapcheck:
ignoreSigs:
- .WrapAndTrace
- .Errorf
- .Wrap
- .New
stylecheck:
checks: ["all", "-ST1020", "-ST1000"]

version: "2"
run:
build-tags:
- codeanalysis

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
default: none
enable:
- errcheck
- gosimple
- govet
- ineffassign
# - staticcheck
- typecheck
- unused
- bodyclose
# - depguard
- copyloopvar
- dupl
- exportloopref
- errcheck
- forcetypeassert
- funlen
# - gci
- gocognit
# - goconst
- goconst
- gocritic
- gocyclo
# - godot
- gofumpt
# - revive
# - gomnd
- goprintffuncname
- gosec
# - ifshort
- govet
- ineffassign
- misspell
- noctx
- nolintlint
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- thelper
- staticcheck
- tparallel
- unconvert
- unparam
# - whitespace
# - errorlint
# - goerr113
- unused
- whitespace
- wrapcheck
settings:
errcheck:
exclude-functions:
- (*encoding/json.Encoder).Encode
funlen:
lines: 100
gocyclo:
min-complexity: 15
govet:
check-shadowing: true
misspell:
locale: US
nolintlint:
allow-leading-space: false # require machine-readable nolint directives (with no leading space)
require-explanation: true
require-specific: false
allow-unused: false
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
staticcheck:
checks:
- all
- -S1016 # https://staticcheck.dev/docs/checks/#S1016 - ignore as explicit field copy is preferred
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 - ignore as explicit use of embedded fields is preferred
- -QF1001 # https://staticcheck.dev/docs/checks/#QF1001 - De Morgan's law (use of "!a && !b" over "!(a || b)") is typically preferred, but this is always case by case
wrapcheck:
ignore-sigs:
- .WrapAndTrace
- .Errorf
- .Wrap
- .New
- .ValidateStruct
- .Permanent
- .Decode
issues:
# enable issues excluded by default
exclude-use-default: false
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofumpt
settings:
goimports:
local-prefixes:
- github.com/brevdev/brev-cli
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ ifdef env
@echo "Building with env=$(env) wrapper..."
@echo ${VERSION}
CGO_ENABLED=0 go build -o brev -ldflags "-X github.com/brevdev/brev-cli/pkg/cmd/version.Version=${VERSION}"
@echo '#!/bin/sh' > brev
@echo '# Auto-generated wrapper with environment overrides' >> brev
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev
@echo 'export BREV_AUTH_URL="https://api.stg.ngc.nvidia.com"' >> brev
@echo 'export BREV_AUTH_ISSUER_URL="https://stg.login.nvidia.com"' >> brev
@echo 'export BREV_API_URL="https://bd.$(env).brev.nvidia.com"' >> brev
@echo 'export BREV_GRPC_URL="api.$(env).brev.nvidia.com:443"' >> brev
@echo 'exec "$$(cd "$$(dirname "$$0")" && pwd)/brev" "$$@"' >> brev
@chmod +x brev
@echo '#!/bin/sh' > brev-local
@echo '# Auto-generated wrapper with environment overrides' >> brev-local
@echo 'export BREV_CONSOLE_URL="https://localhost.nvidia.com:3000"' >> brev-local
@echo 'export BREV_AUTH_URL="https://api.stg.ngc.nvidia.com"' >> brev-local
@echo 'export BREV_AUTH_ISSUER_URL="https://stg.login.nvidia.com"' >> brev-local
@echo 'export BREV_API_URL="https://bd.$(env).brev.nvidia.com"' >> brev-local
@echo 'export BREV_GRPC_URL="api.$(env).brev.nvidia.com:443"' >> brev-local
@echo 'exec "$$(cd "$$(dirname "$$0")" && pwd)/brev" "$$@"' >> brev-local
@chmod +x brev-local
else
@echo "Building without environment overrides (using config.go defaults)..."
$(MAKE) fast-build
Expand Down Expand Up @@ -54,6 +54,9 @@ clean: ## remove files created during build pipeline
install-tools: ## go install tools
$(call print-target)
cd tools && go install $(shell cd tools && go list -e -f '{{ join .Imports " " }}' -tags=tools)
@if [ "$(shell uname)" = "Darwin" ] && ! command -v golangci-lint >/dev/null 2>&1; then \
(echo "Installing golangci-lint on macOS via homebrew..." && brew install golangci-lint); \
fi;

.PHONY: generate
generate: ## go generate
Expand All @@ -78,6 +81,7 @@ fmtcheck: ## go fmt --check
.PHONY: lint
lint: ## golangci-lint
$(call print-target)
golangci-lint --version
golangci-lint run --timeout 5m

.PHONY: test
Expand Down
Loading
Loading