diff options
author | dkegel-fastly <[email protected]> | 2024-04-22 11:10:13 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-04-22 11:10:13 -0700 |
commit | 3d433fe9f15dc6cff400ce7fd03cf15ad55f64fc (patch) | |
tree | 3e4f853cb177ccb0cc4788eed8dc28a823ab4ddf | |
parent | 1154212c15e6e97048e122068730dab5a1a9427f (diff) | |
download | tinygo-3d433fe9f15dc6cff400ce7fd03cf15ad55f64fc.tar.gz tinygo-3d433fe9f15dc6cff400ce7fd03cf15ad55f64fc.zip |
Lint: lint and fix src/{os,reflect} (#4228)
* lint: expand to src/{os,reflect}, fix or suppress what it found
* internal/tools/tools.go: the tools idiom requires a build tag guard to avoid go test complaints
-rw-r--r-- | GNUmakefile | 10 | ||||
-rw-r--r-- | internal/tools/tools.go | 2 | ||||
-rw-r--r-- | revive.toml | 5 | ||||
-rw-r--r-- | src/os/file.go | 1 | ||||
-rw-r--r-- | src/os/path_unix.go | 4 | ||||
-rw-r--r-- | src/os/path_windows.go | 4 | ||||
-rw-r--r-- | src/reflect/value_test.go | 4 |
7 files changed, 20 insertions, 10 deletions
diff --git a/GNUmakefile b/GNUmakefile index c15b7724d..8987fcaa5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -915,7 +915,9 @@ deb: build/release endif lint: - # Only run on compiler dir for now, expand as we clean up other dirs - # This obviously won't scale, but it's a start, and it's fast - go run github.com/mgechev/revive --version - go run github.com/mgechev/revive --config revive.toml compiler/... + go run github.com/mgechev/revive -version + # TODO: lint more directories! + # revive.toml isn't flexible enough to filter out just one kind of error from a checker, so do it with grep here. + # Can't use grep with friendly formatter. Plain output isn't too bad, though. + # Use 'grep .' to get rid of stray blank line + go run github.com/mgechev/revive -config revive.toml compiler/... src/{os,reflect}/*.go | grep -v "should have comment or be unexported" | grep '.' | awk '{print}; END {exit NR>0}' diff --git a/internal/tools/tools.go b/internal/tools/tools.go index c22654a78..60e6a8cb6 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -1,3 +1,5 @@ +//go:build tools + // Install linter versions specified in go.mod // See https://marcofranssen.nl/manage-go-tools-via-go-modules for idom package tools diff --git a/revive.toml b/revive.toml index f09127ca6..37778be50 100644 --- a/revive.toml +++ b/revive.toml @@ -6,15 +6,19 @@ warningCode = 0 # Enable these as we fix them [rule.blank-imports] + Exclude=["src/os/file_other.go"] [rule.context-as-argument] [rule.context-keys-type] [rule.dot-imports] + Exclude=["**/*_test.go"] [rule.error-return] [rule.error-strings] [rule.error-naming] [rule.exported] + Exclude=["src/reflect/*.go"] [rule.increment-decrement] [rule.var-naming] + Exclude=["src/os/*.go"] [rule.var-declaration] #[rule.package-comments] [rule.range] @@ -27,4 +31,5 @@ warningCode = 0 [rule.superfluous-else] #[rule.unused-parameter] [rule.unreachable-code] + Exclude=["src/reflect/visiblefields_test.go", "src/reflect/all_test.go"] #[rule.redefines-builtin-id] diff --git a/src/os/file.go b/src/os/file.go index ff62899bd..e003d47da 100644 --- a/src/os/file.go +++ b/src/os/file.go @@ -310,6 +310,7 @@ func (e *LinkError) Unwrap() error { return e.Err } +// OpenFile flag values. const ( O_RDONLY int = syscall.O_RDONLY O_WRONLY int = syscall.O_WRONLY diff --git a/src/os/path_unix.go b/src/os/path_unix.go index 97a028c5c..9bb5c726b 100644 --- a/src/os/path_unix.go +++ b/src/os/path_unix.go @@ -7,8 +7,8 @@ package os const ( - PathSeparator = '/' // OS-specific path separator - PathListSeparator = ':' // OS-specific path list separator + PathSeparator = '/' // PathSeparator is the OS-specific path separator + PathListSeparator = ':' // PathListSeparator is the OS-specific path list separator ) // IsPathSeparator reports whether c is a directory separator character. diff --git a/src/os/path_windows.go b/src/os/path_windows.go index a96245f35..7118c45b5 100644 --- a/src/os/path_windows.go +++ b/src/os/path_windows.go @@ -5,8 +5,8 @@ package os const ( - PathSeparator = '\\' // OS-specific path separator - PathListSeparator = ';' // OS-specific path list separator + PathSeparator = '\\' // PathSeparator is the OS-specific path separator + PathListSeparator = ';' // PathListSeparator is the OS-specific path list separator ) // IsPathSeparator reports whether c is a directory separator character. diff --git a/src/reflect/value_test.go b/src/reflect/value_test.go index 6641750b9..40f0919bd 100644 --- a/src/reflect/value_test.go +++ b/src/reflect/value_test.go @@ -489,7 +489,7 @@ func TestTinyStruct(t *testing.T) { func TestTinyZero(t *testing.T) { s := "hello, world" - var sptr *string = &s + sptr := &s v := ValueOf(&sptr).Elem() v.Set(Zero(v.Type())) @@ -535,7 +535,7 @@ func TestTinyAddr(t *testing.T) { } func TestTinyNilType(t *testing.T) { - var a any = nil + var a any typ := TypeOf(a) if typ != nil { t.Errorf("Type of any{nil} is not nil") |