update linter and fix lints (#284)

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
This commit is contained in:
Hamza El-Saawy
2023-04-14 15:24:28 -04:00
committed by GitHub
parent b884eb77db
commit 070c828abb
9 changed files with 58 additions and 29 deletions
+33 -11
View File
@@ -4,21 +4,26 @@ on:
- pull_request - pull_request
env: env:
GO_VERSION: "1.17" GO_VERSION: "oldstable"
GOTESTSUM_VERSION: "latest"
jobs: jobs:
lint: lint:
name: Lint name: Lint
runs-on: windows-2019 runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: actions/setup-go@v3 uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- name: Run golangci-lint - name: Run golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v3
with: with:
version: v1.50 version: v1.52
args: >- args: >-
--verbose --verbose
--timeout=5m --timeout=5m
@@ -31,10 +36,14 @@ jobs:
name: Go Generate name: Go Generate
runs-on: windows-2019 runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: actions/setup-go@v3 uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- name: Run go generate - name: Run go generate
shell: pwsh shell: pwsh
run: | run: |
@@ -45,6 +54,7 @@ jobs:
Write-Output "::error title=Go Generate::Error running go generate." Write-Output "::error title=Go Generate::Error running go generate."
exit $LASTEXITCODE exit $LASTEXITCODE
} }
- name: Diff - name: Diff
shell: pwsh shell: pwsh
run: | run: |
@@ -66,11 +76,19 @@ jobs:
matrix: matrix:
os: [windows-2019, windows-2022, ubuntu-latest] os: [windows-2019, windows-2022, ubuntu-latest]
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: actions/setup-go@v3 uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- run: go test -gcflags=all=-d=checkptr -v ./...
- name: Install gotestsum
run: go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: Test repo
run: gotestsum --format standard-verbose --debug -- -gcflags=all=-d=checkptr -v ./...
build: build:
name: Build Repo name: Build Repo
@@ -78,10 +96,14 @@ jobs:
- test - test
runs-on: "windows-2019" runs-on: "windows-2019"
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: actions/setup-go@v3 uses: actions/checkout@v3
- name: Install go
uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- run: go build ./pkg/etw/sample/ - run: go build ./pkg/etw/sample/
- run: go build ./tools/etw-provider-gen/ - run: go build ./tools/etw-provider-gen/
- run: go build ./tools/mkwinsyscall/ - run: go build ./tools/mkwinsyscall/
+12
View File
@@ -35,6 +35,18 @@ issues:
text: "^line-length-limit: " text: "^line-length-limit: "
source: "^//(go:generate|sys) " source: "^//(go:generate|sys) "
#TODO: remove after upgrading to go1.18
# ignore comment spacing for nolint and sys directives
- linters:
- revive
text: "^comment-spacings: no space between comment delimiter and comment text"
source: "//(cspell:|nolint:|sys |todo)"
# not on go 1.18 yet, so no any
- linters:
- revive
text: "^use-any: since GO 1.18 'interface{}' can be replaced by 'any'"
# allow unjustified ignores of error checks in defer statements # allow unjustified ignores of error checks in defer statements
- linters: - linters:
- nolintlint - nolintlint
+2 -2
View File
@@ -15,7 +15,7 @@ const MinWStringCap = 310
// use *[]uint16 since []uint16 creates an extra allocation where the slice header // use *[]uint16 since []uint16 creates an extra allocation where the slice header
// is copied to heap and then referenced via pointer in the interface header that sync.Pool // is copied to heap and then referenced via pointer in the interface header that sync.Pool
// stores. // stores.
var pathPool = sync.Pool{ //! if go1.18+ adds Pool[T], use that to store []uint16 directly var pathPool = sync.Pool{ // if go1.18+ adds Pool[T], use that to store []uint16 directly
New: func() interface{} { New: func() interface{} {
b := make([]uint16, MinWStringCap) b := make([]uint16, MinWStringCap)
return &b return &b
@@ -108,7 +108,7 @@ func (b *WString) String() string {
// Using [windows.UTF16ToString] would require importing "golang.org/x/sys/windows" // Using [windows.UTF16ToString] would require importing "golang.org/x/sys/windows"
// and would make this code Windows-only, which makes no sense. // and would make this code Windows-only, which makes no sense.
// So copy UTF16ToString code into here. // So copy UTF16ToString code into here.
//! If other windows-specific code is added, switch to [windows.UTF16ToString] // If other windows-specific code is added, switch to [windows.UTF16ToString]
s := b.b s := b.b
for i, v := range s { for i, v := range s {
-2
View File
@@ -47,8 +47,6 @@ const (
) )
// EventDescriptor represents various metadata for an ETW event. // EventDescriptor represents various metadata for an ETW event.
//
//nolint:structcheck // task is currently unused
type eventDescriptor struct { type eventDescriptor struct {
id uint16 id uint16
version uint8 version uint8
-2
View File
@@ -21,7 +21,6 @@ type (
trusteeForm uint32 trusteeForm uint32
trusteeType uint32 trusteeType uint32
//nolint:structcheck // structcheck thinks fields are unused, but the are used to pass data to OS
explicitAccess struct { explicitAccess struct {
accessPermissions accessMask accessPermissions accessMask
accessMode accessMode accessMode accessMode
@@ -29,7 +28,6 @@ type (
trustee trustee trustee trustee
} }
//nolint:structcheck,unused // structcheck thinks fields are unused, but the are used to pass data to OS
trustee struct { trustee struct {
multipleTrustee *trustee multipleTrustee *trustee
multipleTrusteeOperation int32 multipleTrusteeOperation int32
+4 -5
View File
@@ -489,15 +489,14 @@ func (f *decompressor) readCompressedBlock(start, end uint16, hmain, hlength, ha
f.lru[0] = matchoffset f.lru[0] = matchoffset
} }
if matchoffset <= i && matchlen <= end-i { if !(matchoffset <= i && matchlen <= end-i) {
f.fail(errCorrupt)
break
}
copyend := i + matchlen copyend := i + matchlen
for ; i < copyend; i++ { for ; i < copyend; i++ {
f.window[i] = f.window[i-matchoffset] f.window[i] = f.window[i-matchoffset]
} }
} else {
f.fail(errCorrupt)
break
}
} }
return int(i - start), f.err return int(i - start), f.err
} }