Skip to content

Commit 9885e30

Browse files
authored
wsl v5 - a complete rewrite ✍️ (#169)
* Initial boilerplate for rewrite * Update dependencies, improve leading whitespace * Add `Cursor`, explore `*ast.IfStmt` * Handle force error checking * Handle if statements * Improve cursor states, add test * WIP: Cursor * Fix multiple if * Simplify resetting cursor * Improve handling of if * Add support to force error cuddlig * Add check for return * Add test for else/else-if * For, range, switch * Type switch * Branch * Decl, check types config * More exploration with CheckType * Improve leading whitespace check * Add initial expression statement check * Go stmt * Reorganize tests * Defer * Support to enable/disable more checks * Trailing newline * Case clause leading newline * Append check and some refactoring * IncDec * Assign and call (not really...) cuddle * Improved decl * More decl testing * Some config work * Support to cuddling if used anywhere in block * Whole block and first statement config * First in block improvements and config * Config and comments updates * Add case max lines * Add more types to detect idents * Fix false positives found on wsl * Add support for exclusive declarations * Fix broken tests * Linting and versioning * Some more types * Fix if false positives * Label statement * Improve/add select * More assign test * Improve defer * Rework finding idents * Drop `FirstInBlockMaxDepth` + fixes * Update golangci-lint and fix issues * Remove `allIdents`, support disable IncDec * Update dependencies * Add test with all checks disabled * Update github actions * Skip cgo files * Comments and cleanup * Add support for send, update conifg * Update README * Configuration and flag changes * Move send test to test with config * Update README * WIP: Rules * More docs and small fixes * Add check type to diagnostic, make branch a single check * Add fix for label statement (actually check statement) * Update tests with failed check * Use preset instead of two bools * Rename preset to default to align with `golangci-lint` * Add migration tool for `.golangci.yml` * Use more sensible default in example * Report leading and trailing whitespace on the empty line * Ensure we never remove user comments * Don't report whitespace issues on the same line * Doc updates * Bump version * Update LICENSE year * Rename faulty struct names * Test updates * Doc updates * Remove tests * Refactor cuddling check with intersection * Improve decl check * Branch and return fixes * More descriptive diagnostic * Improve labeled statement handling * Improve send handling * Add `default` as valid default, enable `send` by default * Remove TODO comment * Remove config migration comment * Move `send` test * Clarify cuddling without intersection * Rename function * Fix copy-paste mistake * Make all wsl types and functions private * Improve `CompositeLit` * Ignore more expr * Add test for else-if/else blocks * Add test for multiline case * Don't check block list for switch * Keep and convert `AllowAssignAndCall` to check * Docs sorting * Fix lint issues * Remove print statements used for debugging * Change badge branch * Remove no longer valid deprecation log * Support Go 1.23 * Don't use `SplitSq` when supporting Go 1.23 * Rename `RULES.md` to `CHECKS.md` * Improve documentation * Header is lowercase only * More docs updates
1 parent 4740984 commit 9885e30

File tree

108 files changed

+6270
-5524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+6270
-5524
lines changed

.github/workflows/go.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,60 @@
22
name: CI
33
on:
44
push:
5+
branches:
6+
- main
57
pull_request:
68

79
jobs:
810
golangci-lint:
911
name: golangci-lint
1012
runs-on: ubuntu-latest
1113
steps:
12-
- uses: actions/setup-go@v3
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
1316
with:
14-
go-version: '1.20'
15-
- uses: actions/checkout@v3
16-
- uses: golangci/golangci-lint-action@v3
17+
go-version: stable
18+
- uses: golangci/golangci-lint-action@v8
19+
with:
20+
version: v2.1.6
1721

1822
tests:
19-
# run after golangci-lint action to not produce duplicated errors
2023
name: tests
2124
needs: golangci-lint
2225
strategy:
2326
matrix:
2427
go:
25-
- '1.20'
28+
- oldstable
29+
- stable
2630
os:
2731
- ubuntu-latest
2832
runs-on: ${{ matrix.os }}
2933
steps:
30-
- name: Install Go
31-
uses: actions/setup-go@v3
32-
with:
33-
go-version: ${{ matrix.go }}
34-
3534
- name: Checkout code
36-
uses: actions/checkout@v2
35+
uses: actions/checkout@v4
3736

38-
- name: Setup cache
39-
uses: actions/cache@v3
37+
- name: Install Go
38+
uses: actions/setup-go@v5
4039
with:
41-
path: ~/go/pkg/mod
42-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
43-
restore-keys: ${{ runner.os }}-go-
40+
go-version: ${{ matrix.go }}
4441

4542
- name: Test code
4643
run: go test -race -v ./...
4744

45+
- name: Run
46+
run: go run ./cmd/wsl/ ./...
47+
4848
coverage:
4949
runs-on: ubuntu-latest
5050
steps:
51-
- name: Install Go
51+
- name: Checkout code
5252
if: success()
53-
uses: actions/setup-go@v3
54-
with:
55-
go-version: '1.20'
53+
uses: actions/checkout@v4
5654

57-
- name: Checkout code
58-
uses: actions/checkout@v3
55+
- name: Install Go
56+
uses: actions/setup-go@v5
57+
with:
58+
go-version: stable
5959

6060
- name: Calc coverage
6161
run: |

.golangci.yml

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,82 @@
11
---
2-
run:
3-
deadline: 1m
4-
issues-exit-code: 1
5-
tests: true
6-
skip-dirs:
7-
- vendor$
2+
version: "2"
83

94
output:
10-
format: colored-line-number
11-
print-issued-lines: false
12-
13-
linters-settings:
14-
gocognit:
15-
min-complexity: 10
16-
17-
depguard:
18-
list-type: blacklist
19-
include-go-root: false
20-
packages:
21-
- github.com/davecgh/go-spew/spew
22-
23-
misspell:
24-
locale: US
25-
26-
gocritic:
27-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run`
28-
# to see all tags and checks. Empty list by default. See
29-
# https://github.com/go-critic/go-critic#usage -> section "Tags".
30-
enabled-tags:
31-
- diagnostic
32-
- experimental
33-
- opinionated
34-
- performance
35-
- style
5+
formats:
6+
text:
7+
path: stdout
8+
print-issued-lines: false
369

3710
linters:
38-
enable-all: true
11+
default: all
3912
disable:
4013
- cyclop
41-
- deadcode
4214
- depguard
4315
- dupl
4416
- dupword
45-
- exhaustivestruct
17+
- err113
4618
- exhaustruct
4719
- forbidigo
20+
- funcorder
4821
- funlen
49-
- gci
5022
- gocognit
5123
- gocyclo
24+
- godot
5225
- godox
53-
- golint
54-
- gomnd
55-
- ifshort
56-
- interfacer
5726
- lll
5827
- maintidx
59-
- maligned
28+
- mnd
6029
- nakedret
6130
- nestif
6231
- nlreturn
63-
- nosnakecase
6432
- paralleltest
6533
- prealloc
6634
- rowserrcheck
67-
- scopelint
68-
- structcheck
35+
- tagliatelle
6936
- testpackage
70-
- varcheck
37+
- tparallel
7138
- varnamelen
7239
- wastedassign
73-
fast: false
7440

41+
settings:
42+
depguard:
43+
rules:
44+
main:
45+
deny:
46+
- pkg: github.com/davecgh/go-spew/spew
47+
desc: not allowed
48+
gocognit:
49+
min-complexity: 10
50+
gocritic:
51+
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run`
52+
# to see all tags and checks. Empty list by default. See
53+
# https://github.com/go-critic/go-critic#usage -> section "Tags".
54+
enabled-tags:
55+
- diagnostic
56+
- experimental
57+
- opinionated
58+
- performance
59+
- style
60+
misspell:
61+
locale: US
62+
63+
exclusions:
64+
presets:
65+
- comments
66+
- common-false-positives
67+
- std-error-handling
7568

7669
issues:
77-
exclude-use-default: true
7870
max-issues-per-linter: 0
7971
max-same-issues: 0
80-
72+
formatters:
73+
enable:
74+
- gofmt
75+
- gofumpt
76+
- goimports
77+
settings:
78+
gofmt:
79+
rewrite-rules:
80+
- pattern: "interface{}"
81+
replacement: "any"
8182
# vim: set sw=2 ts=2 et:

0 commit comments

Comments
 (0)