Skip to content

Commit

Permalink
Make staticcheck do a recursive check (#639)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wenovus authored Apr 13, 2022
1 parent 2f44f5b commit c15884d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@ jobs:
run: |
checkstr=""
for i in util ygot ygen ytypes ygot/pathtranslate testutil testcmp ypathgen; do
checkstr="$checkstr github.com/openconfig/ygot/$i"
checkstr="$checkstr github.com/openconfig/ygot/$i/..."
done
staticcheck $checkstr
12 changes: 6 additions & 6 deletions ygot/schema_tests/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"reflect"
"testing"

"github.com/golang/protobuf/proto"
"github.com/google/go-cmp/cmp"
"github.com/kylelemons/godebug/pretty"
"github.com/openconfig/gnmi/errdiff"
Expand All @@ -32,6 +31,7 @@ import (
"github.com/openconfig/ygot/testutil"
"github.com/openconfig/ygot/uexampleoc"
"github.com/openconfig/ygot/ygot"
"google.golang.org/protobuf/encoding/prototext"

gnmipb "github.com/openconfig/gnmi/proto/gnmi"
)
Expand Down Expand Up @@ -293,8 +293,8 @@ func mustTypedValue(i interface{}) *gnmipb.TypedValue {
func TestDiff(t *testing.T) {
tests := []struct {
desc string
inOrig ygot.GoStruct
inMod ygot.GoStruct
inOrig ygot.ValidatedGoStruct
inMod ygot.ValidatedGoStruct
want *gnmipb.Notification
wantErrSubstring string
}{{
Expand Down Expand Up @@ -377,7 +377,7 @@ func TestDiff(t *testing.T) {
}

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

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

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

if !testutil.NotificationSetEqual(gotSet, []*gnmipb.Notification{wantNoti}) {
diff, err := testutil.GenerateUnifiedDiff(proto.MarshalTextString(wantNoti), proto.MarshalTextString(gotSet[0]))
diff, err := testutil.GenerateUnifiedDiff(prototext.Format(wantNoti), prototext.Format(gotSet[0]))
if err != nil {
t.Errorf("cannot diff generated protobufs, %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion ypathgen/path_tests/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"reflect"
"testing"

"github.com/golang/protobuf/proto"
"github.com/google/go-cmp/cmp"
oc "github.com/openconfig/ygot/exampleoc"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ypathgen"
"google.golang.org/protobuf/proto"
)

// The device ID used throughout this test file.
Expand Down
2 changes: 1 addition & 1 deletion ytypes/schema_tests/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestGetNodeFull(t *testing.T) {
rootSchema := oc.SchemaTree[reflect.TypeOf(oc.Device{}).Name()]
tests := []struct {
name string
inRoot ygot.GoStruct
inRoot ygot.ValidatedGoStruct
inSchema *yang.Entry
inPath *gpb.Path
inOpts []ytypes.GetNodeOpt
Expand Down

0 comments on commit c15884d

Please sign in to comment.