Skip to content

Go: Add static analysis for generated Go bindings#126

Open
bact wants to merge 11 commits into
JPEWdev:mainfrom
bact:add-go-vet-staticcheck
Open

Go: Add static analysis for generated Go bindings#126
bact wants to merge 11 commits into
JPEWdev:mainfrom
bact:add-go-vet-staticcheck

Conversation

@bact

@bact bact commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Add go vet and staticcheck.

Test will failed as there are few style suggestions from the analysers to be addressed.

See #120

--

These minor issues are also fixed. Mostly about comment lines, missing package name declaration, and code styles.

  • ST1000 (package doc missing) - removed a blank line before header to make package doc visible
  • ST1021/ST1022 - doc comment must start with a symbol name (type/func)
  • ST1023 - var valid bool = true -> var valid = true ("bool" is redundant)
  • S1034 - do switch v := x.(type) once instead of re-asserting per case
  • S1009 - dropped redundant x != nil && before len(x) > 0
  • S1011 - loop-copy -> append(lst, values...)
  • S1032 - sort.Sort(sort.StringSlice(...)) -> sort.Strings(...)
  • S1005 - for o, _ := range m -> for o := range m

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact added the tests Tests, test spec, test data label Jul 4, 2026
bact added 2 commits July 4, 2026 17:56
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

@bact

bact commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

Test runs well and detect a number of warnings from S and ST categories:

listproperty.go:73:9: should omit nil check; len() for nil slices is defined as zero (S1009)

shaclobjectset.go:348:10: assigning the result of this type assertion to a variable (switch v := v.(type)) could eliminate type assertions in switch cases (S1034)

encode.go:8:1: at least one file in a package should have a package comment (ST1000)

validator.go:50:1: comment on exported type RegexValidator should be of the form "RegexValidator ..." (with optional leading article) (ST1021)

classes.go:1982:15: should omit type bool from declaration; it will be inferred from the right-hand side (ST1023)

@bact bact marked this pull request as draft July 4, 2026 17:54
bact added 5 commits July 4, 2026 20:31
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact marked this pull request as ready for review July 7, 2026 22:37
@bact bact requested review from JPEWdev and Copilot and removed request for Copilot July 7, 2026 22:38
JPEWdev
JPEWdev previously approved these changes Jul 8, 2026
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact

bact commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@JPEWdev sorry, minor change - commit 0831f23 . I have updated templates it to put {{ disclaimer }} in newline instead, unless the first line could went over.

from

Package {{ package_name }}: {{ disclaimer }}

to

Package {{ package_name }}:
{{ disclaimer }}

Passed locally (only ran on test_golang.py). Will wait for CI to finished the full tests (now including the newly merged C++ static analysis).

@bact

bact commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

Tests on Python 3.9 failed not because of our code but because of pyshacl 0.40.0 (released few hours before the previous commit) no longer support Python 3.9 (it uses language construct that Python 3.9 runtime doesn't support).

Fix by pin pyshacl at < 0.40.0.

@bact bact requested a review from JPEWdev July 8, 2026 23:59
@bact bact added this to the 1.2.0 milestone Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests, test spec, test data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants