Skip to content

Commit 8ea00db

Browse files
committed
fmt: introduce golangci-lint and go vet using build tag
1 parent 297ad41 commit 8ea00db

File tree

247 files changed

+934
-11
lines changed

Some content is hidden

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

247 files changed

+934
-11
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- dev
8+
pull_request:
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
name: "Lint"
17+
steps:
18+
- uses: actions/checkout@v5
19+
- uses: actions/setup-go@v6
20+
with:
21+
go-version: '1.22'
22+
cache: false
23+
- name: golangci-lint
24+
uses: golangci/golangci-lint-action@v8
25+
with:
26+
version: v2.5.0
27+
args: --build-tags=lint
28+
29+
# Optional: show only new issues if it's a pull request. The default value is `false`.
30+
# only-new-issues: true
31+
32+
# Optional: if set to true then the all caching functionality will be complete disabled,
33+
# takes precedence over all other caching options.
34+
# skip-cache: true

.golangci.yml

Lines changed: 311 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
clean:
32
@rm -rf build
43

@@ -26,3 +25,29 @@ unit-test:
2625
@go test -v $(addprefix ./,$(TESTS))
2726

2827
test: clean fmt-check unit-test smoke-test
28+
29+
fmt_quick_check:
30+
@# a very fast check before build, but depends on accessibility of all imports
31+
@# switch off the "stdmethods" analyzer is needed due to finding:
32+
@# at24cx/at24cx.go:57:18: method WriteByte(eepromAddress uint16, value uint8) error should have signature WriteByte(byte) error
33+
@# at24cx/at24cx.go:67:18: method ReadByte(eepromAddress uint16) (uint8, error) should have signature ReadByte() (byte, error)
34+
@# switch off the "shift" analyzer is needed due to finding:
35+
@#tmc5160/registers.go:1939:16: m.CUR_A (16 bits) too small for shift of 16
36+
@#tmc5160/registers.go:1996:16: m.X3 (8 bits) too small for shift of 27
37+
@#tmc5160/registers.go:1996:27: m.X2 (8 bits) too small for shift of 24
38+
@#tmc5160/registers.go:1996:38: m.X1 (8 bits) too small for shift of 21
39+
@#tmc5160/registers.go:1996:49: m.W3 (8 bits) too small for shift of 18
40+
@#tmc5160/registers.go:1996:60: m.W2 (8 bits) too small for shift of 16
41+
@#tmc5160/registers.go:1996:71: m.W1 (8 bits) too small for shift of 14
42+
@#tmc5160/registers.go:1996:82: m.W0 (8 bits) too small for shift of 12
43+
go vet -tags lint -stdmethods=false -shift=false ./...
44+
45+
fmt_check:
46+
@# a complete format check, but depends on accessibility of all imports
47+
golangci-lint -v run --build-tags=lint
48+
49+
fmt_fix:
50+
@# an automatic reformat and complete format check, but depends on accessibility of all imports
51+
@#TODO: activate when ready
52+
@#gofumpt -l -w ./...
53+
golangci-lint -v run --build-tags=lint --fix

adafruit4650/device_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"testing"
1414
"time"
15+
1516
"tinygo.org/x/drivers"
1617
"tinygo.org/x/tinyfont"
1718
"tinygo.org/x/tinyfont/freemono"

apa102/apa102.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
//go:build !lint
2+
13
// Package apa102 implements a driver for the APA102 SPI LED.
24
//
35
// Datasheet: https://cdn-shop.adafruit.com/product-files/2343/APA102C.pdf
6+
//
47
package apa102 // import "tinygo.org/x/drivers/apa102"
58

69
import (

apa102/softspi.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !lint
2+
13
package apa102
24

35
import "machine"

bmi160/bmi160.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !lint
2+
13
package bmi160
24

35
import (

buzzer/buzzer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
//go:build !lint
2+
13
// Package buzzer provides a very simplistic driver for a connected buzzer or low-fidelity speaker.
4+
//
25
package buzzer // import "tinygo.org/x/drivers/buzzer"
36

47
import (

cmd/convert2bin/convert2bin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func main() {
1919

2020
func run(args []string) error {
2121
if len(args) < 2 {
22-
return fmt.Errorf("usage: %s FILE")
22+
return fmt.Errorf("usage: %s FILE", args[0])
2323
}
2424

2525
b, err := ioutil.ReadFile(args[1])

comboat/comboat.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !lint
2+
13
// Package comboat implements WiFi driver for the Aithinker-Combo-AT WiFi
24
// device found on the Elecrow W5 rp2040 and rp2350 devices. Ths WiFi device
35
// is a RTL8720d variant. The driver interface is via AT command set over UART

0 commit comments

Comments
 (0)