Skip to content

Commit

Permalink
chore: add basic golangci-lint configuration. (#23)
Browse files Browse the repository at this point in the history
* chore: add a basic golangci-lint configuration.
  • Loading branch information
ldez authored Feb 7, 2021
1 parent 32489b6 commit cec1130
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ on:
branches: [master]

jobs:
golangci-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.36

tests:
runs-on: ubuntu-18.04

Expand Down
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
run:
skip-dirs:
- pkg/analyzer/testdata

linters-settings:
golint:
min-confidence: 0
goconst:
min-len: 2
min-occurrences: 3
misspell:
locale: US
gci:
local-prefixes: github.com/kulti/thelper

linters:
enable-all: true
disable:
- lll
- prealloc
- dupl
- wsl
- nlreturn
- goerr113
- exhaustivestruct
- paralleltest
- gomnd
- gocognit
- nestif
4 changes: 2 additions & 2 deletions pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAllChecks(t *testing.T) {
a := analyzer.NewAnalyzer()
err := a.Flags.Set("checks", "")
if err != nil {
t.Fatalf("failed to set checks empty value: %s", err.Error())
t.Fatalf("failed to set checks empty value: %v", err)
}
analysistest.Run(t, testdata, a, "t", "b", "tb")
})
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestSingleCheck(t *testing.T) {
a := analyzer.NewAnalyzer()
err := a.Flags.Set("checks", tc)
if err != nil {
t.Fatalf("failed to set checks into %q: %s", tc, err.Error())
t.Fatalf("failed to set checks into %q: %v", tc, err)
}
analysistest.Run(t, testdata, a, tc)
})
Expand Down
15 changes: 9 additions & 6 deletions scripts/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"text/template"
)

var tTmpl = `// Code generated by generator. DO NOT EDIT.
const tTmpl = `// Code generated by generator. DO NOT EDIT.
package {{.Name}}
Expand Down Expand Up @@ -93,18 +93,21 @@ func main() {
path = filepath.Join(path, name)
}
if err := os.MkdirAll(path, 0755); err != nil {
log.Fatalf("failed to create path %q: %s", path, err.Error())
log.Fatalf("failed to create path %q: %v", path, err)
}

tmpl, err := template.New(name).Parse(tTmpl)
if err != nil {
log.Fatalf("failed to parse template: %s", err.Error())
log.Fatalf("failed to parse template: %v", err)
}

filePath := filepath.Join(path, name+".go")
f, err := os.Create(filePath)
if err != nil {
log.Fatalf("failed to create file %q: %v", filePath, err)
}
if err := os.MkdirAll(path, 0600); err != nil {
log.Fatalf("failed to create file %q: %s", filePath, err.Error())
log.Fatalf("failed to create directory %q: %v", path, err)
}

testingStr := "*testing"
Expand All @@ -120,9 +123,9 @@ func main() {
Testing string
TestingComment string
}{
name, strings.ToUpper(name), check, testingStr, testingComment,
Name: name, UName: strings.ToUpper(name), Check: check, Testing: testingStr, TestingComment: testingComment,
}
if err := tmpl.Execute(f, &data); err != nil {
log.Fatalf("failed to execute template: %s", err.Error())
log.Fatalf("failed to execute template: %v", err)
}
}

0 comments on commit cec1130

Please sign in to comment.