- Notifications
You must be signed in to change notification settings - Fork907
chore: Add golangci-lint and codecov#3
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
c8788af
chore: Add golangci-lint and codecov
kylecarbs3a7e909
Use consistent file names
kylecarbsed05fea
Format settings.json
kylecarbsadba002
Add golangci-lint and codecov GitHub Actions
kylecarbsf359eeb
Add base Go file for linting
kylecarbsb7ec563
Add test coverage
kylecarbsFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
24 changes: 21 additions & 3 deletions.github/workflows/coder.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
258 changes: 258 additions & 0 deletions.golangci.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
# See https://golangci-lint.run/usage/configuration/ | ||
# Over time we should try tightening some of these. | ||
linters-settings: | ||
gocognit: | ||
min-complexity: 46 # Min code complexity (def 30). | ||
goconst: | ||
min-len: 4 # Min length of string consts (def 3). | ||
min-occurrences: 3 # Min number of const occurrences (def 3). | ||
gocritic: | ||
enabled-checks: | ||
# - appendAssign | ||
# - appendCombine | ||
- argOrder | ||
# - assignOp | ||
# - badCall | ||
- badCond | ||
- badLock | ||
- badRegexp | ||
- boolExprSimplify | ||
# - builtinShadow | ||
- builtinShadowDecl | ||
- captLocal | ||
- caseOrder | ||
- codegenComment | ||
# - commentedOutCode | ||
- commentedOutImport | ||
# - commentFormatting | ||
- defaultCaseOrder | ||
- deferUnlambda | ||
# - deprecatedComment | ||
# - docStub | ||
- dupArg | ||
- dupBranchBody | ||
- dupCase | ||
- dupImport | ||
- dupSubExpr | ||
# - elseif | ||
- emptyFallthrough | ||
# - emptyStringTest | ||
# - equalFold | ||
# - evalOrder | ||
# - exitAfterDefer | ||
# - exposedSyncMutex | ||
# - filepathJoin | ||
- flagDeref | ||
- flagName | ||
- hexLiteral | ||
# - httpNoBody | ||
# - hugeParam | ||
# - ifElseChain | ||
# - importShadow | ||
- indexAlloc | ||
- initClause | ||
# - ioutilDeprecated | ||
- mapKey | ||
- methodExprCall | ||
# - nestingReduce | ||
- newDeref | ||
- nilValReturn | ||
# - octalLiteral | ||
- offBy1 | ||
# - paramTypeCombine | ||
# - preferStringWriter | ||
# - preferWriteByte | ||
# - ptrToRefParam | ||
# - rangeExprCopy | ||
# - rangeValCopy | ||
- regexpMust | ||
- regexpPattern | ||
# - regexpSimplify | ||
- ruleguard | ||
- singleCaseSwitch | ||
- sloppyLen | ||
# - sloppyReassign | ||
- sloppyTypeAssert | ||
- sortSlice | ||
# - sprintfQuotedString | ||
- sqlQuery | ||
# - stringConcatSimplify | ||
# - stringXbytes | ||
# - suspiciousSorting | ||
- switchTrue | ||
- truncateCmp | ||
- typeAssertChain | ||
# - typeDefFirst | ||
- typeSwitchVar | ||
# - typeUnparen | ||
- underef | ||
# - unlabelStmt | ||
# - unlambda | ||
# - unnamedResult | ||
# - unnecessaryBlock | ||
# - unnecessaryDefer | ||
# - unslice | ||
- valSwap | ||
- weakCond | ||
# - whyNoLint | ||
# - wrapperFunc | ||
# - yodaStyleExpr | ||
settings: | ||
ruleguard: | ||
failOn: all | ||
rules: "${configDir}/lib/go/lintrules/*.go" | ||
goimports: | ||
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder | ||
gocyclo: | ||
min-complexity: 50 | ||
importas: | ||
no-unaliased: true | ||
alias: | ||
- pkg: k8s.io/api/(\w+)/(v[\w\d]+) | ||
alias: ${1}${2} | ||
- pkg: k8s.io/apimachinery/pkg/apis/meta/(v[\w\d]+) | ||
alias: meta${1} | ||
- pkg: k8s.io/client-go/kubernetes/typed/(\w+)/(v[\w\d]+) | ||
alias: ${1}${2}client | ||
- pkg: k8s.io/metrics/pkg/apis/metrics/(v[\w\d]+) | ||
alias: metrics${1} | ||
- pkg: github.com/docker/docker/api/types | ||
alias: dockertypes | ||
- pkg: github.com/docker/docker/client | ||
alias: dockerclient | ||
misspell: | ||
locale: US | ||
nestif: | ||
min-complexity: 4 # Min complexity of if statements (def 5, goal 4) | ||
revive: | ||
# see https://github.com/mgechev/revive#available-rules for details. | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: atomic | ||
- name: bare-return | ||
- name: blank-imports | ||
- name: bool-literal-in-expr | ||
- name: call-to-gc | ||
- name: confusing-naming | ||
- name: confusing-results | ||
- name: constant-logical-expr | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: deep-exit | ||
- name: defer | ||
- name: dot-imports | ||
- name: duplicated-imports | ||
- name: early-return | ||
- name: empty-block | ||
- name: empty-lines | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
- name: flag-parameter | ||
- name: get-return | ||
- name: identical-branches | ||
- name: if-return | ||
- name: import-shadowing | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: modifies-parameter | ||
- name: modifies-value-receiver | ||
- name: package-comments | ||
- name: range | ||
- name: range-val-address | ||
- name: range-val-in-closure | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: string-of-int | ||
- name: struct-tag | ||
- name: superfluous-else | ||
- name: time-naming | ||
- name: unconditional-recursion | ||
- name: unexported-naming | ||
- name: unexported-return | ||
- name: unhandled-error | ||
- name: unnecessary-stmt | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: unused-receiver | ||
- name: var-declaration | ||
- name: var-naming | ||
- name: waitgroup-by-value | ||
issues: | ||
# Rules listed here: https://github.com/securego/gosec#available-rules | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
# We use assertions rather than explicitly checking errors in tests | ||
- errcheck | ||
fix: true | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
run: | ||
concurrency: 4 | ||
skip-dirs: | ||
- node_modules | ||
timeout: 5m | ||
# Over time, add more and more linters from | ||
# https://golangci-lint.run/usage/linters/ as the code improves. | ||
linters: | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- contextcheck | ||
- deadcode | ||
- dogsled | ||
- errcheck | ||
- errname | ||
- errorlint | ||
- exportloopref | ||
- forcetypeassert | ||
- gocritic | ||
- gocyclo | ||
- goimports | ||
- gomodguard | ||
- gosec | ||
- gosimple | ||
- govet | ||
- importas | ||
- ineffassign | ||
# - ireturn | ||
- makezero | ||
- misspell | ||
- nilnil | ||
- noctx | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- structcheck | ||
- tenv | ||
- typecheck | ||
- unconvert | ||
- unused | ||
- varcheck | ||
- varnamelen | ||
- wastedassign |
15 changes: 15 additions & 0 deletions.vscode/settings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"go.lintTool": "golangci-lint", | ||
"go.lintFlags": ["--fast"], | ||
"go.lintOnSave": "package", | ||
"go.coverOnSave": true, | ||
"go.coverageDecorator": { | ||
"type": "gutter", | ||
"coveredHighlightColor": "rgba(64,128,128,0.5)", | ||
"uncoveredHighlightColor": "rgba(128,64,64,0.25)", | ||
"coveredBorderColor": "rgba(64,128,128,0.5)", | ||
"uncoveredBorderColor": "rgba(128,64,64,0.25)", | ||
"coveredGutterStyle": "blockgreen", | ||
"uncoveredGutterStyle": "blockred" | ||
} | ||
} |
7 changes: 7 additions & 0 deletionscmd/coder/main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
import "fmt" | ||
func main() { | ||
fmt.Println("Hello World!") | ||
} |
20 changes: 20 additions & 0 deletionscodecov.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
codecov: | ||
require_ci_to_pass: false | ||
comment: | ||
show_carryforward_flags: yes | ||
coverage: | ||
notify: | ||
slack: | ||
default: | ||
url: secret:v1::ALa1/e2X+k36fPseab5D7+kBFc9bJyIoIQioD0IMA5jr+0HXVpBRNDCHZhHjCdGc67yff6PPixPEOLwEZpxC37rM23RBZOYlqAq9A5e0MeZVlEoVq19aOYN4Xel17hMJ6GGm7n17wrYpCpcvlVSqNrN0+cr3guVDyG10kQyfh2Y= | ||
threshold: 1% | ||
only_pulls: false | ||
branches: | ||
- "main" | ||
status: | ||
project: | ||
default: | ||
target: 80% | ||
informational: yes |
3 changes: 3 additions & 0 deletionsgo.mod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/coder/coder | ||
go 1.17 |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.