-
Notifications
You must be signed in to change notification settings - Fork 8
add lint action #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add lint action #324
Changes from all commits
c98755d
3f77377
b4dcb2f
deb7bf0
cfc7dc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Go Checks | ||
|
|
||
| on: | ||
| pull_request: {} | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| golangci: | ||
| name: lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
| - name: golangci-lint | ||
| uses: golangci/golangci-lint-action@v8 | ||
| with: | ||
| version: v2.4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,8 +73,8 @@ func printDataStoreTable(rsp *sdcpb.GetDataStoreResponse) { | |
| table := tablewriter.NewWriter(os.Stdout) | ||
| table.Header([]string{"Name", "Schema", "Protocol", "Address", "State"}) | ||
| table.Options(tablewriter.WithAlignment(tw.Alignment{tw.AlignLeft})) | ||
| table.Bulk(toTableData(rsp)) | ||
| table.Render() | ||
| _ = table.Bulk(toTableData(rsp)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here again, maybe you want to check the returned error here. |
||
| _ = table.Render() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here (error check). |
||
| } | ||
|
|
||
| func toTableData(rsp *sdcpb.GetDataStoreResponse) [][]string { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,6 @@ func printDataStoresTable(rsp *sdcpb.ListDataStoreResponse) { | |
| table := tablewriter.NewWriter(os.Stdout) | ||
| table.Header([]string{"Name", "Schema", "Protocol", "Address", "State", "Candidate (C/O/P)"}) | ||
| table.Options(tablewriter.WithAlignment(tw.Alignment{tw.AlignLeft})) | ||
| table.Bulk(tableData) | ||
| table.Render() | ||
| _ = table.Bulk(tableData) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error check |
||
| _ = table.Render() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error check |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,8 +57,8 @@ func init() { | |
| func createDataClient(ctx context.Context, addr string) (sdcpb.DataServerClient, error) { | ||
| ctx, cancel := context.WithTimeout(ctx, 10*time.Second) | ||
| defer cancel() | ||
| cc, err := grpc.DialContext(ctx, addr, | ||
| grpc.WithBlock(), | ||
| cc, err := grpc.DialContext(ctx, addr, //nolint:staticcheck | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added nolint for this deprecated call for now. At the same time I've opened the issue #377 that is about changing this to the NewClient() call.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, works for me. |
||
| grpc.WithBlock(), //nolint:staticcheck | ||
| grpc.WithTransportCredentials( | ||
| insecure.NewCredentials(), | ||
| ), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package gnmi | |
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "sync" | ||
| "time" | ||
|
|
||
|
|
@@ -209,7 +210,7 @@ func (s *StreamSync) gnmiSubscribe(subReq *gnmi.SubscribeRequest, updChan chan<- | |
| syncResponse <- struct{}{} | ||
|
|
||
| case *gnmi.SubscribeResponse_Error: | ||
| log.Error(nil, "gnmi subscription error", "error", r.Error.Message) | ||
| log.Error(fmt.Errorf("%s", r.Error.Message), "gnmi subscription error") //nolint:staticcheck | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is linting disabled? |
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,7 +130,7 @@ func (t *ncTarget) internalGet(ctx context.Context, req *sdcpb.GetDataRequest) ( | |
| ncResponse, err := t.driver.GetConfig(source, filterDoc) | ||
| if err != nil { | ||
| if strings.Contains(err.Error(), "EOF") { | ||
| t.Close(ctx) | ||
| _ = t.Close(ctx) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the underlying channel and transport can not be closed cleanly, this may lead to other problems. You should check (or at least log) whether there was an error here and process it. |
||
| go t.reconnect(ctx) | ||
| } | ||
| return nil, err | ||
|
|
@@ -261,7 +261,7 @@ func (t *ncTarget) setToDevice(ctx context.Context, commitDatastore string, sour | |
| if err != nil { | ||
| log.Error(err, "failed during edit-config") | ||
| if strings.Contains(err.Error(), "EOF") { | ||
| t.Close(ctx) | ||
| _ = t.Close(ctx) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again check the returned error and log/process it. |
||
| go t.reconnect(ctx) | ||
| return nil, err | ||
| } | ||
|
|
@@ -288,7 +288,7 @@ func (t *ncTarget) setToDevice(ctx context.Context, commitDatastore string, sour | |
| err = t.driver.Commit() | ||
| if err != nil { | ||
| if strings.Contains(err.Error(), "EOF") { | ||
| t.Close(ctx) | ||
| _ = t.Close(ctx) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again: log/process returned error. |
||
| go t.reconnect(ctx) | ||
| } | ||
| return nil, err | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,7 +290,7 @@ func TestLeafList(t *testing.T) { | |
| HonorNamespace: true, | ||
| }) | ||
|
|
||
| xmlBuilder.AddValue(ctx, &sdcpb.Path{ | ||
| _ = xmlBuilder.AddValue(ctx, &sdcpb.Path{ | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Elem: []*sdcpb.PathElem{ | ||
| { | ||
| Name: "leaflist", | ||
|
|
@@ -367,7 +367,10 @@ func Test_filterRPCErrors(t *testing.T) { | |
| ` | ||
|
|
||
| doc := etree.NewDocument() | ||
| doc.ReadFromString(xml) | ||
| err := doc.ReadFromString(xml) | ||
| if err != nil { | ||
| t.Error(err) | ||
| } | ||
|
|
||
| type args struct { | ||
| xml *etree.Document | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,8 +50,8 @@ func (t *noopTarget) AddSyncs(ctx context.Context, sps ...*config.SyncProtocol) | |
| } | ||
|
|
||
| func (t *noopTarget) Get(ctx context.Context, req *sdcpb.GetDataRequest) (*sdcpb.GetDataResponse, error) { | ||
| log := logf.FromContext(ctx).WithName("Get") | ||
| ctx = logf.IntoContext(ctx, log) | ||
| // log := logf.FromContext(ctx).WithName("Get") | ||
| // ctx = logf.IntoContext(ctx, log) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can those comments be removed?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
|
|
||
| result := &sdcpb.GetDataResponse{ | ||
| Notification: make([]*sdcpb.Notification, 0, len(req.GetPath())), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're not using a simple printf, you may want to check the return error of the function at least.