Address golangci-lint warnings in unmarshal_imported_test.go (#493)
* refactor(tracker): Remove unreachable return * refactor(unmarshal_imported_test): Mark unused camelCase test golangci-lint indicates `TestUnmarshalCamelCaseKey` as unused (it's currently skipped). * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `customPointerMarshaler` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `textPointerMarshaler` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `precedentMarshaler` and its methods as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `testDurationToml2` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `testBadDuration` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `testDurationToml` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `testDuration` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `testDocCustomTag` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `testDocCustomTagData` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `testDocBasicsCustomTag` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `testDocBasicToml` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint indicates `structArrayNoTag` as unused. * refactor(unmarshal_imported_test): Mark unused type golangci-lint incorrectly indicates `check` as unused. * refactor(unmarshal_imported_test): Mark unused struct field golangci-lint indicates `testDoc.err` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `customMultilineTagTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `customCommentedTagTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `customCommentTagTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `customTagTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `mapsTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `mapsTestData` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `commentTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `nestedCustomMarshalerToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `nestedCustomMarshalerData` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `customMarshalerToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `mapTestDoc` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `quotedKeyMarshalTestToml` as unused. * refactor(unmarshal_imported_test): Mark unused var golangci-lint indicates `quotedKeyMarshalTestData` as unused.
This commit is contained in:
@@ -149,6 +149,8 @@ type quotedKeyMarshalTestStruct struct {
|
|||||||
SubList []basicMarshalTestSubStruct `toml:"W.sublist-𝟘"`
|
SubList []basicMarshalTestSubStruct `toml:"W.sublist-𝟘"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var quotedKeyMarshalTestData = quotedKeyMarshalTestStruct{
|
var quotedKeyMarshalTestData = quotedKeyMarshalTestStruct{
|
||||||
String: "Hello",
|
String: "Hello",
|
||||||
Float: 3.5,
|
Float: 3.5,
|
||||||
@@ -156,6 +158,8 @@ var quotedKeyMarshalTestData = quotedKeyMarshalTestStruct{
|
|||||||
SubList: []basicMarshalTestSubStruct{{"Two"}, {"Three"}},
|
SubList: []basicMarshalTestSubStruct{{"Two"}, {"Three"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var quotedKeyMarshalTestToml = []byte(`"Yfloat-𝟘" = 3.5
|
var quotedKeyMarshalTestToml = []byte(`"Yfloat-𝟘" = 3.5
|
||||||
"Z.string-àéù" = "Hello"
|
"Z.string-àéù" = "Hello"
|
||||||
|
|
||||||
@@ -177,7 +181,7 @@ type testDoc struct {
|
|||||||
Subdocs testDocSubs `toml:"subdoc"`
|
Subdocs testDocSubs `toml:"subdoc"`
|
||||||
Basics testDocBasics `toml:"basic"`
|
Basics testDocBasics `toml:"basic"`
|
||||||
SubDocList []testSubDoc `toml:"subdoclist"`
|
SubDocList []testSubDoc `toml:"subdoclist"`
|
||||||
err int `toml:"shouldntBeHere"`
|
err int `toml:"shouldntBeHere"` // nolint:structcheck,unused
|
||||||
unexported int `toml:"shouldntBeHere"`
|
unexported int `toml:"shouldntBeHere"`
|
||||||
Unexported2 int `toml:"-"`
|
Unexported2 int `toml:"-"`
|
||||||
}
|
}
|
||||||
@@ -264,6 +268,8 @@ var docData = testDoc{
|
|||||||
SubDocPtrs: []*testSubDoc{&subdoc},
|
SubDocPtrs: []*testSubDoc{&subdoc},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var mapTestDoc = testMapDoc{
|
var mapTestDoc = testMapDoc{
|
||||||
Title: "TOML Marshal Testing",
|
Title: "TOML Marshal Testing",
|
||||||
BasicMap: map[string]string{
|
BasicMap: map[string]string{
|
||||||
@@ -573,11 +579,20 @@ func (c customMarshaler) MarshalTOML() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var customMarshalerData = customMarshaler{FirstName: "Sally", LastName: "Fields"}
|
var customMarshalerData = customMarshaler{FirstName: "Sally", LastName: "Fields"}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var customMarshalerToml = []byte(`Sally Fields`)
|
var customMarshalerToml = []byte(`Sally Fields`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var nestedCustomMarshalerData = customMarshalerParent{
|
var nestedCustomMarshalerData = customMarshalerParent{
|
||||||
Self: customMarshaler{FirstName: "Maiku", LastName: "Suteda"},
|
Self: customMarshaler{FirstName: "Maiku", LastName: "Suteda"},
|
||||||
Friends: []customMarshaler{customMarshalerData},
|
Friends: []customMarshaler{customMarshalerData},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var nestedCustomMarshalerToml = []byte(`friends = ["Sally Fields"]
|
var nestedCustomMarshalerToml = []byte(`friends = ["Sally Fields"]
|
||||||
me = "Maiku Suteda"
|
me = "Maiku Suteda"
|
||||||
`)
|
`)
|
||||||
@@ -626,38 +641,50 @@ func TestUnmarshalTextMarshaler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type and methods are used by a test
|
||||||
|
//nolint:unused
|
||||||
type precedentMarshaler struct {
|
type precedentMarshaler struct {
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func (m precedentMarshaler) MarshalText() ([]byte, error) {
|
func (m precedentMarshaler) MarshalText() ([]byte, error) {
|
||||||
return []byte("shadowed"), nil
|
return []byte("shadowed"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func (m precedentMarshaler) MarshalTOML() ([]byte, error) {
|
func (m precedentMarshaler) MarshalTOML() ([]byte, error) {
|
||||||
fullName := fmt.Sprintf("%s %s", m.FirstName, m.LastName)
|
fullName := fmt.Sprintf("%s %s", m.FirstName, m.LastName)
|
||||||
return []byte(fullName), nil
|
return []byte(fullName), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type and method are used by a test
|
||||||
|
//nolint:unused
|
||||||
type customPointerMarshaler struct {
|
type customPointerMarshaler struct {
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func (m *customPointerMarshaler) MarshalTOML() ([]byte, error) {
|
func (m *customPointerMarshaler) MarshalTOML() ([]byte, error) {
|
||||||
return []byte(`"hidden"`), nil
|
return []byte(`"hidden"`), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type and method are used by a test
|
||||||
|
//nolint:unused
|
||||||
type textPointerMarshaler struct {
|
type textPointerMarshaler struct {
|
||||||
FirstName string
|
FirstName string
|
||||||
LastName string
|
LastName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func (m *textPointerMarshaler) MarshalText() ([]byte, error) {
|
func (m *textPointerMarshaler) MarshalText() ([]byte, error) {
|
||||||
return []byte("hidden"), nil
|
return []byte("hidden"), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var commentTestToml = []byte(`
|
var commentTestToml = []byte(`
|
||||||
# it's a comment on type
|
# it's a comment on type
|
||||||
[postgres]
|
[postgres]
|
||||||
@@ -693,6 +720,8 @@ type mapsTestStruct struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var mapsTestData = mapsTestStruct{
|
var mapsTestData = mapsTestStruct{
|
||||||
Simple: map[string]string{
|
Simple: map[string]string{
|
||||||
"one plus one": "two",
|
"one plus one": "two",
|
||||||
@@ -713,6 +742,9 @@ var mapsTestData = mapsTestStruct{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var mapsTestToml = []byte(`
|
var mapsTestToml = []byte(`
|
||||||
[Other]
|
[Other]
|
||||||
"testing" = 3.9999
|
"testing" = 3.9999
|
||||||
@@ -733,6 +765,8 @@ var mapsTestToml = []byte(`
|
|||||||
"is.Nested" = true
|
"is.Nested" = true
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type is used by a test
|
||||||
|
//nolint:deadcode,unused
|
||||||
type structArrayNoTag struct {
|
type structArrayNoTag struct {
|
||||||
A struct {
|
A struct {
|
||||||
B []int64
|
B []int64
|
||||||
@@ -740,6 +774,8 @@ type structArrayNoTag struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var customTagTestToml = []byte(`
|
var customTagTestToml = []byte(`
|
||||||
[postgres]
|
[postgres]
|
||||||
password = "bvalue"
|
password = "bvalue"
|
||||||
@@ -752,6 +788,8 @@ var customTagTestToml = []byte(`
|
|||||||
My = "Baar"
|
My = "Baar"
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var customCommentTagTestToml = []byte(`
|
var customCommentTagTestToml = []byte(`
|
||||||
# db connection
|
# db connection
|
||||||
[postgres]
|
[postgres]
|
||||||
@@ -763,6 +801,8 @@ var customCommentTagTestToml = []byte(`
|
|||||||
user = "avalue"
|
user = "avalue"
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var customCommentedTagTestToml = []byte(`
|
var customCommentedTagTestToml = []byte(`
|
||||||
[postgres]
|
[postgres]
|
||||||
# password = "bvalue"
|
# password = "bvalue"
|
||||||
@@ -815,6 +855,8 @@ func TestUnmarshalTabInStringAndQuotedKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var customMultilineTagTestToml = []byte(`int_slice = [
|
var customMultilineTagTestToml = []byte(`int_slice = [
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
@@ -822,6 +864,8 @@ var customMultilineTagTestToml = []byte(`int_slice = [
|
|||||||
]
|
]
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var testDocBasicToml = []byte(`
|
var testDocBasicToml = []byte(`
|
||||||
[document]
|
[document]
|
||||||
bool_val = true
|
bool_val = true
|
||||||
@@ -832,9 +876,14 @@ var testDocBasicToml = []byte(`
|
|||||||
uint_val = 5001
|
uint_val = 5001
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type is used by a test
|
||||||
|
//nolint:deadcode
|
||||||
type testDocCustomTag struct {
|
type testDocCustomTag struct {
|
||||||
Doc testDocBasicsCustomTag `file:"document"`
|
Doc testDocBasicsCustomTag `file:"document"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type is used by a test
|
||||||
|
//nolint:deadcode
|
||||||
type testDocBasicsCustomTag struct {
|
type testDocBasicsCustomTag struct {
|
||||||
Bool bool `file:"bool_val"`
|
Bool bool `file:"bool_val"`
|
||||||
Date time.Time `file:"date_val"`
|
Date time.Time `file:"date_val"`
|
||||||
@@ -845,6 +894,8 @@ type testDocBasicsCustomTag struct {
|
|||||||
unexported int `file:"shouldntBeHere"`
|
unexported int `file:"shouldntBeHere"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,varcheck
|
||||||
var testDocCustomTagData = testDocCustomTag{
|
var testDocCustomTagData = testDocCustomTag{
|
||||||
Doc: testDocBasicsCustomTag{
|
Doc: testDocBasicsCustomTag{
|
||||||
Bool: true,
|
Bool: true,
|
||||||
@@ -922,6 +973,8 @@ func TestUnmarshalInvalidPointerKind(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused
|
||||||
type testDuration struct {
|
type testDuration struct {
|
||||||
Nanosec time.Duration `toml:"nanosec"`
|
Nanosec time.Duration `toml:"nanosec"`
|
||||||
Microsec1 time.Duration `toml:"microsec1"`
|
Microsec1 time.Duration `toml:"microsec1"`
|
||||||
@@ -934,6 +987,8 @@ type testDuration struct {
|
|||||||
AString string `toml:"a_string"`
|
AString string `toml:"a_string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var testDurationToml = []byte(`
|
var testDurationToml = []byte(`
|
||||||
nanosec = "1ns"
|
nanosec = "1ns"
|
||||||
microsec1 = "1us"
|
microsec1 = "1us"
|
||||||
@@ -946,6 +1001,8 @@ mixed = "1h1m1s1ms1µs1ns"
|
|||||||
a_string = "15s"
|
a_string = "15s"
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once var is used by a test
|
||||||
|
//nolint:deadcode,unused,varcheck
|
||||||
var testDurationToml2 = []byte(`a_string = "15s"
|
var testDurationToml2 = []byte(`a_string = "15s"
|
||||||
hour = "1h0m0s"
|
hour = "1h0m0s"
|
||||||
microsec1 = "1µs"
|
microsec1 = "1µs"
|
||||||
@@ -957,12 +1014,16 @@ nanosec = "1ns"
|
|||||||
sec = "1s"
|
sec = "1s"
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO: Remove nolint once type is used by a test
|
||||||
|
//nolint:deadcode,unused
|
||||||
type testBadDuration struct {
|
type testBadDuration struct {
|
||||||
Val time.Duration `toml:"val"`
|
Val time.Duration `toml:"val"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCamelCaseKeyToml = []byte(`fooBar = 10`)
|
// TODO: add back camelCase test
|
||||||
|
var testCamelCaseKeyToml = []byte(`fooBar = 10`) //nolint:unused
|
||||||
|
|
||||||
|
//nolint:unused
|
||||||
func TestUnmarshalCamelCaseKey(t *testing.T) {
|
func TestUnmarshalCamelCaseKey(t *testing.T) {
|
||||||
t.Skipf("don't know if it is a good idea to automatically convert like that yet")
|
t.Skipf("don't know if it is a good idea to automatically convert like that yet")
|
||||||
var x struct {
|
var x struct {
|
||||||
@@ -981,7 +1042,7 @@ func TestUnmarshalCamelCaseKey(t *testing.T) {
|
|||||||
|
|
||||||
func TestUnmarshalNegativeUint(t *testing.T) {
|
func TestUnmarshalNegativeUint(t *testing.T) {
|
||||||
t.Skipf("not sure if we this should always error")
|
t.Skipf("not sure if we this should always error")
|
||||||
type check struct{ U uint }
|
type check struct{ U uint } // nolint:unused
|
||||||
err := toml.Unmarshal([]byte("U = -1"), &check{})
|
err := toml.Unmarshal([]byte("U = -1"), &check{})
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (s *Seen) CheckExpression(node ast.Node) error {
|
|||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("this should not be a top level node type: %s", node.Kind))
|
panic(fmt.Errorf("this should not be a top level node type: %s", node.Kind))
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
func (s *Seen) checkTable(node ast.Node) error {
|
func (s *Seen) checkTable(node ast.Node) error {
|
||||||
s.current = s.root
|
s.current = s.root
|
||||||
|
|||||||
Reference in New Issue
Block a user