adhocteam / pushup

Pushup is for making modern, page-oriented web apps in Go
https://pushup.adhoc.dev
MIT License
844 stars 30 forks source link

fix staticcheck errors and run gofmt #69

Closed llimllib closed 1 year ago

llimllib commented 1 year ago

Before:

$ staticcheck . ./_runtime
_runtime/pushup_support.go:87:5: error var NotFound should have name of the form ErrFoo (ST1012)
_runtime/pushup_support.go:97:46: should use constant http.StatusMovedPermanently instead of numeric literal 301 (ST1013)
_runtime/pushup_support.go:180:6: func getParam is unused (U1000)
_runtime/pushup_support.go:189:5: var layouts is unused (U1000)
_runtime/pushup_support.go:191:6: func getLayout is unused (U1000)
_runtime/pushup_support.go:202:6: type nilLayout is unused (U1000)
_runtime/pushup_support.go:204:21: func (*nilLayout).Respond is unused (U1000)
_runtime/pushup_support.go:230:6: func printEscaped is unused (U1000)
_runtime/pushup_support.go:296:3: should use 'return route.path != mainRoute' instead of 'if route.path == mainRoute { return false }; return true' (S1008)
_runtime/pushup_support.go:314:3: should use 'return matchURLPathSegmentPrefix(match.route.regex, requestPath)' instead of 'if matchURLPathSegmentPrefix(match.route.regex, requestPath) { return true }; return false' (S1008)
_runtime/pushup_support.go:386:2: should use 'return len(segments) <= len(reSegments)' instead of 'if len(segments) > len(reSegments) { return false }; return true' (S1008)
main.go:17:2: \"io/ioutil\" has been deprecated since Go 1.16: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
main.go:566:24: func (*projectFiles).debug is unused (U1000)
main.go:843:3: this value of err is never used (SA4006)
main.go:850:3: this value of err is never used (SA4006)
main.go:871:2: should merge variable declaration with assignment on next line (S1021)
main.go:3683:22: func (*codeParser).offset is unused (U1000)
$ go vet . ./_runtime
# github.com/adhocteam/pushup/_runtime
_runtime/pushup_support.go:117:2: unreachable code

After:

$ staticcheck . ./_runtime
_runtime/pushup_support.go:179:6: func getParam is unused (U1000)
_runtime/pushup_support.go:188:5: var layouts is unused (U1000)
_runtime/pushup_support.go:190:6: func getLayout is unused (U1000)
_runtime/pushup_support.go:201:6: type nilLayout is unused (U1000)
_runtime/pushup_support.go:203:21: func (*nilLayout).Respond is unused (U1000)
_runtime/pushup_support.go:229:6: func printEscaped is unused (U1000)
main.go:565:24: func (*projectFiles).debug is unused (U1000)
main.go:3675:22: func (*codeParser).offset is unused (U1000)
$ go vet . ./_runtime
paulsmith commented 1 year ago

Running staticcheck on _runtime is a bit weird because it's sort of an incomplete templatized package. We should do it, and try to address issues that are not related to integrating it with generated Pushup code, but not block CI on it.