Skip to content

Pass of lint for .proto files #1223

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

Merged
merged 17 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed FIELD_LOWER_SNAKE_CASE lint warning
  • Loading branch information
cmaglie committed Mar 24, 2021
commit 34e70b851168d37faa46a85cfbbeab6ff4a8cd29
6 changes: 3 additions & 3 deletions cli/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ func (dr detailsResult) String() string {
for i, idp := range details.IdentificationPref {
if i == 0 {
t.AddRow() // get some space from above
t.AddRow(tr("Identification properties:"), "VID:"+idp.UsbID.VID+" PID:"+idp.UsbID.PID)
t.AddRow(tr("Identification properties:"), "VID:"+idp.UsbId.Vid+" PID:"+idp.UsbId.Pid)
continue
}
t.AddRow("", "VID:"+idp.UsbID.VID+" PID:"+idp.UsbID.PID)
t.AddRow("", "VID:"+idp.UsbId.Vid+" PID:"+idp.UsbId.Pid)
}

t.AddRow() // get some space from above
addIfNotEmpty(tr("Package name:"), details.Package.Name)
addIfNotEmpty(tr("Package maintainer:"), details.Package.Maintainer)
addIfNotEmpty(tr("Package URL:"), details.Package.Url)
addIfNotEmpty(tr("Package website:"), details.Package.WebsiteURL)
addIfNotEmpty(tr("Package website:"), details.Package.WebsiteUrl)
addIfNotEmpty(tr("Package online help:"), details.Package.Help.Online)

t.AddRow() // get some space from above
Expand Down
8 changes: 4 additions & 4 deletions cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ func (dr result) String() string {
if boards := port.GetBoards(); len(boards) > 0 {
sort.Slice(boards, func(i, j int) bool {
x, y := boards[i], boards[j]
return x.GetName() < y.GetName() || (x.GetName() == y.GetName() && x.GetFQBN() < y.GetFQBN())
return x.GetName() < y.GetName() || (x.GetName() == y.GetName() && x.GetFqbn() < y.GetFqbn())
})
for _, b := range boards {
board := b.GetName()

// to improve the user experience, show on a dedicated column
// the name of the core supporting the board detected
var coreName = ""
fqbn, err := cores.ParseFQBN(b.GetFQBN())
fqbn, err := cores.ParseFQBN(b.GetFqbn())
if err == nil {
coreName = fmt.Sprintf("%s:%s", fqbn.Package, fqbn.PlatformArch)
}
Expand Down Expand Up @@ -206,15 +206,15 @@ func (dr watchEvent) String() string {
if boards := dr.Boards; len(boards) > 0 {
sort.Slice(boards, func(i, j int) bool {
x, y := boards[i], boards[j]
return x.GetName() < y.GetName() || (x.GetName() == y.GetName() && x.GetFQBN() < y.GetFQBN())
return x.GetName() < y.GetName() || (x.GetName() == y.GetName() && x.GetFqbn() < y.GetFqbn())
})
for _, b := range boards {
board := b.GetName()

// to improve the user experience, show on a dedicated column
// the name of the core supporting the board detected
var coreName = ""
fqbn, err := cores.ParseFQBN(b.GetFQBN())
fqbn, err := cores.ParseFQBN(b.GetFqbn())
if err == nil {
coreName = fmt.Sprintf("%s:%s", fqbn.Package, fqbn.PlatformArch)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (dr resultAll) String() string {
if item.IsHidden {
hidden = "(hidden)"
}
t.AddRow(item.GetName(), item.GetFQBN(), hidden)
t.AddRow(item.GetName(), item.GetFqbn(), hidden)
}
return t.Render()
}
2 changes: 1 addition & 1 deletion cli/board/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r searchResults) String() string {
if item.IsHidden {
hidden = "(hidden)"
}
t.AddRow(item.GetName(), item.GetFQBN(), item.Platform.ID, hidden)
t.AddRow(item.GetName(), item.GetFqbn(), item.Platform.Id, hidden)
}
return t.Render()
}
4 changes: 2 additions & 2 deletions cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ func (ir installedResult) String() string {
t := table.New()
t.SetHeader("ID", "Installed", "Latest", "Name")
sort.Slice(ir.platforms, func(i, j int) bool {
return ir.platforms[i].ID < ir.platforms[j].ID
return ir.platforms[i].Id < ir.platforms[j].Id
})
for _, p := range ir.platforms {
t.AddRow(p.ID, p.Installed, p.Latest, p.Name)
t.AddRow(p.Id, p.Installed, p.Latest, p.Name)
}

return t.Render()
Expand Down
4 changes: 2 additions & 2 deletions cli/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ func (sr searchResults) String() string {
t := table.New()
t.SetHeader("ID", "Version", "Name")
sort.Slice(sr.platforms, func(i, j int) bool {
return sr.platforms[i].ID < sr.platforms[j].ID
return sr.platforms[i].Id < sr.platforms[j].Id
})
for _, item := range sr.platforms {
t.AddRow(item.GetID(), item.GetLatest(), item.GetName())
t.AddRow(item.GetId(), item.GetLatest(), item.GetName())
}
return t.Render()
}
Expand Down
2 changes: 1 addition & 1 deletion cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
}

for _, t := range targets {
args = append(args, t.ID)
args = append(args, t.Id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions commands/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
details.Package = &rpc.Package{
Name: boardPackage.Name,
Maintainer: boardPackage.Maintainer,
WebsiteURL: boardPackage.WebsiteURL,
WebsiteUrl: boardPackage.WebsiteURL,
Email: boardPackage.Email,
Help: &rpc.Help{Online: boardPackage.Help.Online},
Url: boardPackage.URL,
Expand All @@ -85,7 +85,7 @@ func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetai
pids := board.Properties.SubTree("pid")
for id, vid := range vids.AsMap() {
if pid, ok := pids.GetOk(id); ok {
idPref := rpc.IdentificationPref{UsbID: &rpc.USBID{VID: vid, PID: pid}}
idPref := rpc.IdentificationPref{UsbId: &rpc.USBID{Vid: vid, Pid: pid}}
details.IdentificationPref = append(details.IdentificationPref, &idPref)
}
}
Expand Down
12 changes: 6 additions & 6 deletions commands/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {

retVal = append(retVal, &rpc.BoardListItem{
Name: name,
FQBN: fqbn,
VID: vid,
PID: pid,
Fqbn: fqbn,
Vid: vid,
Pid: pid,
})
} else {
return nil, errors.Wrap(err, "error querying Arduino Cloud Api")
Expand Down Expand Up @@ -119,9 +119,9 @@ func identify(pm *packagemanager.PackageManager, port *commands.BoardPort) ([]*r
for _, board := range pm.IdentifyBoard(port.IdentificationPrefs) {
boards = append(boards, &rpc.BoardListItem{
Name: board.Name(),
FQBN: board.FQBN(),
VID: port.IdentificationPrefs.Get("vid"),
PID: port.IdentificationPrefs.Get("pid"),
Fqbn: board.FQBN(),
Vid: port.IdentificationPrefs.Get("vid"),
Pid: port.IdentificationPrefs.Get("pid"),
})
}

Expand Down
6 changes: 3 additions & 3 deletions commands/board/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func TestGetByVidPid(t *testing.T) {
require.Nil(t, err)
require.Len(t, res, 1)
require.Equal(t, "Arduino/Genuino MKR1000", res[0].Name)
require.Equal(t, "arduino:samd:mkr1000", res[0].FQBN)
require.Equal(t, "0xf420", res[0].VID)
require.Equal(t, "0XF069", res[0].PID)
require.Equal(t, "arduino:samd:mkr1000", res[0].Fqbn)
require.Equal(t, "0xf420", res[0].Vid)
require.Equal(t, "0XF069", res[0].Pid)

// wrong vid (too long), wrong pid (not an hex value)
res, err = apiByVidPid("0xfffff", "0xDEFG")
Expand Down
4 changes: 2 additions & 2 deletions commands/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListA
}

rpcPlatform := &rpc.Platform{
ID: platform.String(),
Id: platform.String(),
Installed: installedVersion,
Latest: latestVersion,
Name: platform.Name,
Expand Down Expand Up @@ -108,7 +108,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListA

list.Boards = append(list.Boards, &rpc.BoardListItem{
Name: board.Name(),
FQBN: board.FQBN(),
Fqbn: board.FQBN(),
IsHidden: board.IsHidden(),
Platform: rpcPlatform,
})
Expand Down
4 changes: 2 additions & 2 deletions commands/board/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchR
}

rpcPlatform := &rpc.Platform{
ID: platform.String(),
Id: platform.String(),
Installed: installedVersion,
Latest: latestPlatformRelease.Version.String(),
Name: platform.Name,
Expand Down Expand Up @@ -98,7 +98,7 @@ func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchR

res.Boards = append(res.Boards, &rpc.BoardListItem{
Name: board.Name(),
FQBN: board.FQBN(),
Fqbn: board.FQBN(),
IsHidden: board.IsHidden(),
Platform: rpcPlatform,
})
Expand Down
2 changes: 1 addition & 1 deletion commands/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
}

result := &rpc.Platform{
ID: platformRelease.Platform.String(),
Id: platformRelease.Platform.String(),
Name: platformRelease.Platform.Name,
Maintainer: platformRelease.Platform.Package.Maintainer,
Website: platformRelease.Platform.Package.WebsiteURL,
Expand Down
22 changes: 11 additions & 11 deletions commands/core/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestPlatformSearch(t *testing.T) {

require.Len(t, res.SearchOutput, 2)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.5",
Name: "RK002",
Expand All @@ -65,7 +65,7 @@ func TestPlatformSearch(t *testing.T) {
Boards: []*commands.Board{{Name: "RK002"}},
})
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.6",
Name: "RK002",
Expand All @@ -84,7 +84,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 1)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.6",
Name: "RK002",
Expand All @@ -104,7 +104,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 2)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.5",
Name: "RK002",
Expand All @@ -114,7 +114,7 @@ func TestPlatformSearch(t *testing.T) {
Boards: []*commands.Board{{Name: "RK002"}},
})
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.6",
Name: "RK002",
Expand All @@ -134,7 +134,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 2)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.5",
Name: "RK002",
Expand All @@ -144,7 +144,7 @@ func TestPlatformSearch(t *testing.T) {
Boards: []*commands.Board{{Name: "RK002"}},
})
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.6",
Name: "RK002",
Expand All @@ -164,7 +164,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 2)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.5",
Name: "RK002",
Expand All @@ -174,7 +174,7 @@ func TestPlatformSearch(t *testing.T) {
Boards: []*commands.Board{{Name: "RK002"}},
})
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "Retrokits-RK002:arm",
Id: "Retrokits-RK002:arm",
Installed: "",
Latest: "1.0.6",
Name: "RK002",
Expand All @@ -194,7 +194,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 1)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "arduino:avr",
Id: "arduino:avr",
Installed: "",
Latest: "1.8.3",
Name: "Arduino AVR Boards",
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestPlatformSearch(t *testing.T) {
require.NotNil(t, res)
require.Len(t, res.SearchOutput, 1)
require.Contains(t, res.SearchOutput, &commands.Platform{
ID: "arduino:avr",
Id: "arduino:avr",
Installed: "",
Latest: "1.8.3",
Name: "Arduino AVR Boards",
Expand Down
2 changes: 1 addition & 1 deletion commands/daemon/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *MonitorService) StreamingOpen(stream rpc.MonitorService_StreamingOpenSe
}

// ensure it's a config message and not data
config := msg.GetMonitorConfig()
config := msg.GetConfig()
if config == nil {
return errors.New("first message must contain monitor configuration, not data")
}
Expand Down
10 changes: 0 additions & 10 deletions rpc/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ lint:
ENUM_ZERO_VALUE_SUFFIX:
- commands/lib.proto
- monitor/monitor.proto
FIELD_LOWER_SNAKE_CASE:
- commands/board.proto
- commands/commands.proto
- commands/common.proto
- commands/compile.proto
- commands/core.proto
- commands/lib.proto
- debug/debug.proto
- monitor/monitor.proto
- settings/settings.proto
PACKAGE_DIRECTORY_MATCH:
- commands/board.proto
- commands/commands.proto
Expand Down
Loading