Skip to content

Commit 17f0189

Browse files
Update golangci-lint (#2378)
1 parent 10c1411 commit 17f0189

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+285
-284
lines changed

.github/workflows/check-go-task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
- name: golangci-lint
117117
uses: golangci/golangci-lint-action@v3
118118
with:
119-
version: v1.54
119+
version: v1.55
120120

121121
- name: Check style
122122
env:

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ linters:
2929
- tenv
3030
- typecheck
3131
- unconvert
32+
- protogetter
3233

3334
linters-settings:
3435
forbidigo:
@@ -55,7 +56,7 @@ linters-settings:
5556
- name: errorf
5657
- name: exported
5758
- name: increment-decrement
58-
- name: indent-error-flow
59+
#- name: indent-error-flow
5960
- name: package-comments
6061
- name: range
6162
- name: receiver-naming

arduino/cores/packagemanager/install_uninstall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func (pme *Explorer) IsToolRequired(toolRelease *cores.ToolRelease) bool {
448448

449449
func skipEmptyMessageTaskProgressCB(taskCB rpc.TaskProgressCB) rpc.TaskProgressCB {
450450
return func(msg *rpc.TaskProgress) {
451-
if msg != nil && len(msg.Message) == 0 {
451+
if msg != nil && len(msg.GetMessage()) == 0 {
452452
return
453453
}
454454
taskCB(msg)

arduino/discovery/discovery.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ func PortFromRPCPort(o *rpc.Port) (p *Port) {
125125
return nil
126126
}
127127
res := &Port{
128-
Address: o.Address,
129-
AddressLabel: o.Label,
130-
Protocol: o.Protocol,
131-
ProtocolLabel: o.ProtocolLabel,
132-
HardwareID: o.HardwareId,
133-
}
134-
if o.Properties != nil {
135-
res.Properties = properties.NewFromHashmap(o.Properties)
128+
Address: o.GetAddress(),
129+
AddressLabel: o.GetLabel(),
130+
Protocol: o.GetProtocol(),
131+
ProtocolLabel: o.GetProtocolLabel(),
132+
HardwareID: o.GetHardwareId(),
133+
}
134+
if o.GetProperties() != nil {
135+
res.Properties = properties.NewFromHashmap(o.GetProperties())
136136
}
137137
return res
138138
}

arduino/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ type NoBoardsDetectedError struct {
134134
func (e *NoBoardsDetectedError) Error() string {
135135
return tr(
136136
"Please specify an FQBN. The board on port %[1]s with protocol %[2]s can't be identified",
137-
e.Port.Address,
138-
e.Port.Protocol,
137+
e.Port.GetAddress(),
138+
e.Port.GetProtocol(),
139139
)
140140
}
141141

@@ -154,8 +154,8 @@ type MultipleBoardsDetectedError struct {
154154
func (e *MultipleBoardsDetectedError) Error() string {
155155
return tr(
156156
"Please specify an FQBN. Multiple possible boards detected on port %[1]s with protocol %[2]s",
157-
e.Port.Address,
158-
e.Port.Protocol,
157+
e.Port.GetAddress(),
158+
e.Port.GetProtocol(),
159159
)
160160
}
161161

client_example/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func createInstance(client rpc.ArduinoCoreServiceClient) *rpc.Instance {
330330
if err != nil {
331331
log.Fatalf("Error creating server instance: %s", err)
332332
}
333-
return res.Instance
333+
return res.GetInstance()
334334
}
335335

336336
func initInstance(client rpc.ArduinoCoreServiceClient, instance *rpc.Instance) {
@@ -521,8 +521,8 @@ func callBoardSearch(client rpc.ArduinoCoreServiceClient, instance *rpc.Instance
521521
log.Fatalf("Error getting board data: %s\n", err)
522522
}
523523

524-
for _, board := range res.Boards {
525-
log.Printf("Board Name: %s, Board Platform: %s\n", board.Name, board.Platform.Metadata.Id)
524+
for _, board := range res.GetBoards() {
525+
log.Printf("Board Name: %s, Board Platform: %s\n", board.GetName(), board.GetPlatform().GetMetadata().GetId())
526526
}
527527
}
528528

@@ -650,16 +650,16 @@ func callBoardListWatch(client rpc.ArduinoCoreServiceClient, instance *rpc.Insta
650650
} else if err != nil {
651651
log.Fatalf("Board list watch error: %s\n", err)
652652
}
653-
if res.EventType == "error" {
654-
log.Printf("res: %s\n", res.Error)
653+
if res.GetEventType() == "error" {
654+
log.Printf("res: %s\n", res.GetError())
655655
continue
656656
}
657657

658-
log.Printf("event: %s, address: %s\n", res.EventType, res.Port.Port.Address)
659-
if res.EventType == "add" {
660-
log.Printf("protocol: %s, ", res.Port.Port.Protocol)
661-
log.Printf("protocolLabel: %s, ", res.Port.Port.ProtocolLabel)
662-
log.Printf("boards: %s\n\n", res.Port.MatchingBoards)
658+
log.Printf("event: %s, address: %s\n", res.GetEventType(), res.GetPort().GetPort().GetAddress())
659+
if res.GetEventType() == "add" {
660+
log.Printf("protocol: %s, ", res.GetPort().GetPort().GetProtocol())
661+
log.Printf("protocolLabel: %s, ", res.GetPort().GetPort().GetProtocolLabel())
662+
log.Printf("boards: %s\n\n", res.GetPort().GetMatchingBoards())
663663
}
664664
}
665665
}()

commands/board/details.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
5252
details.Version = board.PlatformRelease.Version.String()
5353
details.IdentificationProperties = []*rpc.BoardIdentificationProperties{}
5454
for _, p := range board.GetIdentificationProperties() {
55-
details.IdentificationProperties = append(details.IdentificationProperties, &rpc.BoardIdentificationProperties{
55+
details.IdentificationProperties = append(details.GetIdentificationProperties(), &rpc.BoardIdentificationProperties{
5656
Properties: p.AsMap(),
5757
})
5858
}
5959
for _, k := range boardProperties.Keys() {
6060
v := boardProperties.Get(k)
61-
details.BuildProperties = append(details.BuildProperties, k+"="+v)
61+
details.BuildProperties = append(details.GetBuildProperties(), k+"="+v)
6262
}
6363
if !req.GetDoNotExpandBuildProperties() {
64-
details.BuildProperties, _ = utils.ExpandBuildProperties(details.BuildProperties)
64+
details.BuildProperties, _ = utils.ExpandBuildProperties(details.GetBuildProperties())
6565
}
6666

6767
details.DebuggingSupported = boardProperties.ContainsKey("debug.executable") ||
@@ -111,10 +111,10 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
111111
}
112112
configValue.Value = value
113113
configValue.ValueLabel = values.Get(value)
114-
configOption.Values = append(configOption.Values, configValue)
114+
configOption.Values = append(configOption.GetValues(), configValue)
115115
}
116116

117-
details.ConfigOptions = append(details.ConfigOptions, configOption)
117+
details.ConfigOptions = append(details.GetConfigOptions(), configOption)
118118
}
119119

120120
details.ToolsDependencies = []*rpc.ToolsDependencies{}
@@ -132,7 +132,7 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
132132
})
133133
}
134134
}
135-
details.ToolsDependencies = append(details.ToolsDependencies, &rpc.ToolsDependencies{
135+
details.ToolsDependencies = append(details.GetToolsDependencies(), &rpc.ToolsDependencies{
136136
Name: tool.ToolName,
137137
Packager: tool.ToolPackager,
138138
Version: tool.ToolVersion.String(),
@@ -142,7 +142,7 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
142142

143143
details.Programmers = []*rpc.Programmer{}
144144
for id, p := range boardPlatformRelease.Programmers {
145-
details.Programmers = append(details.Programmers, &rpc.Programmer{
145+
details.Programmers = append(details.GetProgrammers(), &rpc.Programmer{
146146
Platform: boardPlatformRelease.Name,
147147
Id: id,
148148
Name: p.Name,

commands/board/list.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port) ([]*rpc.BoardL
182182

183183
// Sort by FQBN alphabetically
184184
sort.Slice(boards, func(i, j int) bool {
185-
return strings.ToLower(boards[i].Fqbn) < strings.ToLower(boards[j].Fqbn)
185+
return strings.ToLower(boards[i].GetFqbn()) < strings.ToLower(boards[j].GetFqbn())
186186
})
187187

188188
// Put Arduino boards before others in case there are non Arduino boards with identical VID:PID combination
189189
sort.SliceStable(boards, func(i, j int) bool {
190-
if boards[i].Platform.Metadata.Maintainer == "Arduino" && boards[j].Platform.Metadata.Maintainer != "Arduino" {
190+
if boards[i].GetPlatform().GetMetadata().GetMaintainer() == "Arduino" && boards[j].GetPlatform().GetMetadata().GetMaintainer() != "Arduino" {
191191
return true
192192
}
193193
return false
@@ -246,8 +246,8 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError
246246
}
247247

248248
func hasMatchingBoard(b *rpc.DetectedPort, fqbnFilter *cores.FQBN) bool {
249-
for _, detectedBoard := range b.MatchingBoards {
250-
detectedFqbn, err := cores.ParseFQBN(detectedBoard.Fqbn)
249+
for _, detectedBoard := range b.GetMatchingBoards() {
250+
detectedFqbn, err := cores.ParseFQBN(detectedBoard.GetFqbn())
251251
if err != nil {
252252
continue
253253
}

commands/board/list_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func TestGetByVidPid(t *testing.T) {
5454
res, err := apiByVidPid("0xf420", "0XF069")
5555
require.Nil(t, err)
5656
require.Len(t, res, 1)
57-
require.Equal(t, "Arduino/Genuino MKR1000", res[0].Name)
58-
require.Equal(t, "arduino:samd:mkr1000", res[0].Fqbn)
57+
require.Equal(t, "Arduino/Genuino MKR1000", res[0].GetName())
58+
require.Equal(t, "arduino:samd:mkr1000", res[0].GetFqbn())
5959

6060
// wrong vid (too long), wrong pid (not an hex value)
6161
_, err = apiByVidPid("0xfffff", "0xDEFG")
@@ -156,8 +156,8 @@ func TestBoardIdentifySorting(t *testing.T) {
156156
require.Len(t, res, 4)
157157

158158
// Verify expected sorting
159-
require.Equal(t, res[0].Fqbn, "arduino:avr:assurdo")
160-
require.Equal(t, res[1].Fqbn, "arduino:avr:nessuno")
161-
require.Equal(t, res[2].Fqbn, "packager:platform:boardA")
162-
require.Equal(t, res[3].Fqbn, "packager:platform:boardB")
159+
require.Equal(t, res[0].GetFqbn(), "arduino:avr:assurdo")
160+
require.Equal(t, res[1].GetFqbn(), "arduino:avr:nessuno")
161+
require.Equal(t, res[2].GetFqbn(), "packager:platform:boardA")
162+
require.Equal(t, res[3].GetFqbn(), "packager:platform:boardB")
163163
}

commands/board/listall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListA
7171
continue
7272
}
7373

74-
list.Boards = append(list.Boards, &rpc.BoardListItem{
74+
list.Boards = append(list.GetBoards(), &rpc.BoardListItem{
7575
Name: board.Name(),
7676
Fqbn: board.FQBN(),
7777
IsHidden: board.IsHidden(),

0 commit comments

Comments
 (0)