Skip to content

Commit c15884d

Browse files
authored
Make staticcheck do a recursive check (#639)
* Don't prepend module name for in-namespace fields of a non-root-level GoStruct For details see #637 Fixes #637 * Remove generated proto files * re-add proto files * Update ValidatedGoStruct and deprecate GoStruct * Remove != nil check since method is nil tolerant * Fully deprecate GoStruct * Make staticcheck do a recursive check
1 parent 2f44f5b commit c15884d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,6 @@ jobs:
170170
run: |
171171
checkstr=""
172172
for i in util ygot ygen ytypes ygot/pathtranslate testutil testcmp ypathgen; do
173-
checkstr="$checkstr github.com/openconfig/ygot/$i"
173+
checkstr="$checkstr github.com/openconfig/ygot/$i/..."
174174
done
175175
staticcheck $checkstr

ygot/schema_tests/schema_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"reflect"
2222
"testing"
2323

24-
"github.com/golang/protobuf/proto"
2524
"github.com/google/go-cmp/cmp"
2625
"github.com/kylelemons/godebug/pretty"
2726
"github.com/openconfig/gnmi/errdiff"
@@ -32,6 +31,7 @@ import (
3231
"github.com/openconfig/ygot/testutil"
3332
"github.com/openconfig/ygot/uexampleoc"
3433
"github.com/openconfig/ygot/ygot"
34+
"google.golang.org/protobuf/encoding/prototext"
3535

3636
gnmipb "github.com/openconfig/gnmi/proto/gnmi"
3737
)
@@ -293,8 +293,8 @@ func mustTypedValue(i interface{}) *gnmipb.TypedValue {
293293
func TestDiff(t *testing.T) {
294294
tests := []struct {
295295
desc string
296-
inOrig ygot.GoStruct
297-
inMod ygot.GoStruct
296+
inOrig ygot.ValidatedGoStruct
297+
inMod ygot.ValidatedGoStruct
298298
want *gnmipb.Notification
299299
wantErrSubstring string
300300
}{{
@@ -377,7 +377,7 @@ func TestDiff(t *testing.T) {
377377
}
378378

379379
if !testutil.NotificationSetEqual([]*gnmipb.Notification{got}, []*gnmipb.Notification{tt.want}) {
380-
diff, err := testutil.GenerateUnifiedDiff(proto.MarshalTextString(got), proto.MarshalTextString(tt.want))
380+
diff, err := testutil.GenerateUnifiedDiff(prototext.Format(got), prototext.Format(tt.want))
381381
if err != nil {
382382
diff = "unable to produce diff"
383383
}
@@ -505,7 +505,7 @@ func TestNotificationOutput(t *testing.T) {
505505
}
506506

507507
wantNoti := &gnmipb.Notification{}
508-
if err := proto.UnmarshalText(string(wantTxtpb), wantNoti); err != nil {
508+
if err := prototext.Unmarshal(wantTxtpb, wantNoti); err != nil {
509509
t.Fatalf("cannot unmarshal wanted textproto, %v", err)
510510
}
511511

@@ -517,7 +517,7 @@ func TestNotificationOutput(t *testing.T) {
517517
}
518518

519519
if !testutil.NotificationSetEqual(gotSet, []*gnmipb.Notification{wantNoti}) {
520-
diff, err := testutil.GenerateUnifiedDiff(proto.MarshalTextString(wantNoti), proto.MarshalTextString(gotSet[0]))
520+
diff, err := testutil.GenerateUnifiedDiff(prototext.Format(wantNoti), prototext.Format(gotSet[0]))
521521
if err != nil {
522522
t.Errorf("cannot diff generated protobufs, %v", err)
523523
}

ypathgen/path_tests/path_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818
"reflect"
1919
"testing"
2020

21-
"github.com/golang/protobuf/proto"
2221
"github.com/google/go-cmp/cmp"
2322
oc "github.com/openconfig/ygot/exampleoc"
2423
"github.com/openconfig/ygot/ygot"
2524
"github.com/openconfig/ygot/ypathgen"
25+
"google.golang.org/protobuf/proto"
2626
)
2727

2828
// The device ID used throughout this test file.

ytypes/schema_tests/get_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestGetNodeFull(t *testing.T) {
4242
rootSchema := oc.SchemaTree[reflect.TypeOf(oc.Device{}).Name()]
4343
tests := []struct {
4444
name string
45-
inRoot ygot.GoStruct
45+
inRoot ygot.ValidatedGoStruct
4646
inSchema *yang.Entry
4747
inPath *gpb.Path
4848
inOpts []ytypes.GetNodeOpt

0 commit comments

Comments
 (0)