You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just realized that the project does not run any code linters, when I noticed that some variables in encode_string.go were not used. Some of these are frivolous, but the amount of unused code kind of worries me.
Can we add a Github action to run golangci-lint? I can create a PR.
Meanwhile, here's the current status
% golangci-lint run ./...
decode_string.go:153:6: `appendCoerceInvalidUTF8` is unused (deadcode)
func appendCoerceInvalidUTF8(b []byte, s []byte) []byte {
^
encode.go:44:2: `opCodeEscapedType` is unused (deadcode)
opCodeEscapedType = iota
^
encode.go:45:2: `opCodeEscapedIndentType` is unused (deadcode)
opCodeEscapedIndentType
^
encode.go:46:2: `opCodeNoEscapeType` is unused (deadcode)
opCodeNoEscapeType
^
encode.go:47:2: `opCodeNoEscapeIndentType` is unused (deadcode)
opCodeNoEscapeIndentType
^
encode.go:73:2: `codePool` is unused (deadcode)
codePool sync.Pool
^
encode.go:372:6: `encodeBytes` is unused (deadcode)
func encodeBytes(dst []byte, src []byte) []byte {
^
encode_string.go:357:5: `htmlSafeSet` is unused (deadcode)
var htmlSafeSet = [256]bool{
^
encode_string.go:590:5: `safeSet` is unused (deadcode)
var safeSet = [utf8.RuneSelf]bool{
^
encode_string.go:722:6: `escapeIndexWithHTMLEscape` is unused (deadcode)
func escapeIndexWithHTMLEscape(s string) int {
^
decode_test.go:2085:5: `interfaceSetTests` is unused (deadcode)
var interfaceSetTests = []struct {
^
decode_test.go:2314:5: `decodeTypeErrorTests` is unused (deadcode)
var decodeTypeErrorTests = []struct {
^
decode_test.go:2479:5: `invalidUnmarshalTests` is unused (deadcode)
var invalidUnmarshalTests = []struct {
^
decode_test.go:2504:5: `invalidUnmarshalTextTests` is unused (deadcode)
var invalidUnmarshalTextTests = []struct {
^
stream_test.go:325:5: `tokenStreamCases` is unused (deadcode)
var tokenStreamCases = []tokenStreamCase{
^
cover_helper_test.go:29:12: Error return value of `enc.Encode` is not checked (errcheck)
enc.Encode(data)
^
decode_test.go:2736:16: Error return value of `json.Unmarshal` is not checked (errcheck)
json.Unmarshal([]byte("{}"), &unmarshalPanic{})
^
encode_test.go:830:14: Error return value of `json.Marshal` is not checked (errcheck)
json.Marshal(&marshalPanic{})
^
example_test.go:262:13: Error return value of `json.Indent` is not checked (errcheck)
json.Indent(&out, b, "=", "\t")
^
example_test.go:263:13: Error return value of `out.WriteTo` is not checked (errcheck)
out.WriteTo(os.Stdout)
^
example_test.go:310:13: Error return value of `out.WriteTo` is not checked (errcheck)
out.WriteTo(os.Stdout)
^
stream_test.go:88:13: Error return value of `enc.Encode` is not checked (errcheck)
enc.Encode(v)
^
stream_test.go:303:13: Error return value of `w.Write` is not checked (errcheck)
go w.Write([]byte(enc))
^
stream_test.go:438:10: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(raw))
^
decode_map.go:154:3: ineffectual assignment to `cursor` (ineffassign)
cursor = valueCursor
^
decode_stream.go:19:2: `readPos` is unused (structcheck)
readPos int64
^
decode.go:25:2: `disallowUnknownFields` is unused (structcheck)
disallowUnknownFields bool
^
encode_context.go:31:2: `iter` is unused (structcheck)
iter unsafe.Pointer
^
decode_test.go:423:2: `x` is unused (structcheck)
x int
^
decode_test.go:1366:2: `unexported` is unused (structcheck)
unexported int
^
decode_test.go:2363:2: `m` is unused (structcheck)
m map[string]interface{} `json:"-"`
^
decode_test.go:2364:2: `m2` is unused (structcheck)
m2 map[string]interface{} `json:"abcd"`
^
decode_test.go:2366:2: `s` is unused (structcheck)
s []int `json:"-"`
^
stream_test.go:317:2: `json` is unused (structcheck)
json string
^
stream_test.go:318:2: `expTokens` is unused (structcheck)
expTokens []interface{}
^
decode_test.go:221:4: S1021: should merge variable declaration with assignment on next line (gosimple)
var v interface{}
^
struct_field.go:25:2: S1008: should use 'return tag == "-"' instead of 'if tag == "-" { return true }; return false' (gosimple)
if tag == "-" {
^
encode_test.go:107:4: structtag: struct field a has json tag but is not exported (govet)
a int `json:"aa"` // private field
^
encode_test.go:440:4: structtag: struct field a has json tag but is not exported (govet)
a int `json:"aa"` // private field
^
tagkey_test.go:62:2: structtag: struct field tag `:"BadFormat"` not compatible with reflect.StructTag.Get: bad syntax for struct tag key (govet)
Y string `:"BadFormat"`
^
decode.go:248:2: unreachable: unreachable code (govet)
return nil, io.EOF
^
decode_bytes.go:150:4: unreachable: unreachable code (govet)
return nil, 0, errUnexpectedEndOfJSON("[]byte", cursor)
^
decode_context.go:145:2: unreachable: unreachable code (govet)
return cursor, errUnexpectedEndOfJSON("value of object", cursor)
^
encode_string.go:771:37: unsafeptr: possible misuse of reflect.SliceHeader (govet)
return *(*[]uint64)(unsafe.Pointer(&reflect.SliceHeader{
^
encode_compile.go:648:4: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
break
^
encode_compile.go:772:4: SA4004: the surrounding loop is unconditionally terminated (staticcheck)
break
^
encode.go:136:2: SA9003: empty branch (staticcheck)
if err := setupOpcodeSets(); err != nil {
^
cover_float32_test.go:1207:7: SA5008: the JSON string option only applies to fields of type string, floating point, integer or bool, or pointers to those (staticcheck)
} `json:",string"`
^
cover_float32_test.go:1781:7: SA5008: the JSON string option only applies to fields of type string, floating point, integer or bool, or pointers to those (staticcheck)
} `json:",string"`
^
cover_float32_test.go:1784:7: SA5008: the JSON string option only applies to fields of type string, floating point, integer or bool, or pointers to those (staticcheck)
} `json:",string"`
^
decode_test.go:1317:14: SA5008: unknown JSON option "dummyopt" (staticcheck)
Foo2 string `json:"bar2,dummyopt"`
^
encode_test.go:1585:15: SA5008: unknown JSON option "random" (staticcheck)
Slr []string `json:"slr,random"`
^
stream_test.go:113:15: SA5008: invalid JSON field name "\\" (staticcheck)
Invalid int `json:"\\"`
^
tagkey_test.go:66:11: SA5008: invalid JSON field name " !\"#&'()*+" (staticcheck)
Z string `json:" !\"#&'()*+,."`
^
encode_opcode.go:250:18: func `(*opcode).dumpKey` is unused (unused)
decode_test.go:1931:6: type `Xint` is unused (unused)
decode_test.go:589:6: type `XYZ` is unused (unused)
encode_opcode.go:263:18: func `(*opcode).dumpValue` is unused (unused)
decode_test.go:595:6: type `unexportedWithMethods` is unused (unused)
encode_opcode.go:217:18: func `(*opcode).dumpElem` is unused (unused)
encode_opcode.go:205:18: func `(*opcode).dumpMapEnd` is unused (unused)
decode_test.go:645:6: type `byteWithPtrMarshalText` is unused (unused)
encode_opcode.go:237:18: func `(*opcode).dumpField` is unused (unused)
encode_opcode.go:191:18: func `(*opcode).dumpMapHead` is unused (unused)
encode_vm.go:9388:19: func `(*Encoder).ptrToByte` is unused (unused)
encode_opcode.go:274:18: func `(*opcode).dump` is unused (unused)
decode_test.go:1618:6: type `NullTest` is unused (unused)
encode_opcode.go:172:18: func `(*opcode).dumpHead` is unused (unused)
The text was updated successfully, but these errors were encountered:
I just realized that the project does not run any code linters, when I noticed that some variables in encode_string.go were not used. Some of these are frivolous, but the amount of unused code kind of worries me.
Can we add a Github action to run golangci-lint? I can create a PR.
Meanwhile, here's the current status
The text was updated successfully, but these errors were encountered: