Skip to content

Commit 77a9203

Browse files
committed
Removed function alias for i18n.Tr
This allows a deeper lint-check of printf style functions, like: commands/instances.go:344:46: printf: github.com/arduino/arduino-cli/internal/i18n.Tr format %v reads arg #1, but call has 0 args (govet) s := status.Newf(codes.FailedPrecondition, i18n.Tr("Loading index file: %v"), err)
1 parent 24e5ce2 commit 77a9203

File tree

140 files changed

+1092
-1080
lines changed

Some content is hidden

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

140 files changed

+1092
-1080
lines changed

commands/cmderrors/cmderrors.go

+38-40
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import (
2626
"google.golang.org/grpc/status"
2727
)
2828

29-
var tr = i18n.Tr
30-
3129
func composeErrorMsg(msg string, cause error) string {
3230
if cause == nil {
3331
return msg
@@ -45,7 +43,7 @@ type CommandError interface {
4543
type InvalidInstanceError struct{}
4644

4745
func (e *InvalidInstanceError) Error() string {
48-
return tr("Invalid instance")
46+
return i18n.Tr("Invalid instance")
4947
}
5048

5149
// GRPCStatus converts the error into a *status.Status
@@ -59,7 +57,7 @@ type InvalidFQBNError struct {
5957
}
6058

6159
func (e *InvalidFQBNError) Error() string {
62-
return composeErrorMsg(tr("Invalid FQBN"), e.Cause)
60+
return composeErrorMsg(i18n.Tr("Invalid FQBN"), e.Cause)
6361
}
6462

6563
// GRPCStatus converts the error into a *status.Status
@@ -77,7 +75,7 @@ type InvalidURLError struct {
7775
}
7876

7977
func (e *InvalidURLError) Error() string {
80-
return composeErrorMsg(tr("Invalid URL"), e.Cause)
78+
return composeErrorMsg(i18n.Tr("Invalid URL"), e.Cause)
8179
}
8280

8381
// GRPCStatus converts the error into a *status.Status
@@ -95,7 +93,7 @@ type InvalidLibraryError struct {
9593
}
9694

9795
func (e *InvalidLibraryError) Error() string {
98-
return composeErrorMsg(tr("Invalid library"), e.Cause)
96+
return composeErrorMsg(i18n.Tr("Invalid library"), e.Cause)
9997
}
10098

10199
// GRPCStatus converts the error into a *status.Status
@@ -113,7 +111,7 @@ type InvalidVersionError struct {
113111
}
114112

115113
func (e *InvalidVersionError) Error() string {
116-
return composeErrorMsg(tr("Invalid version"), e.Cause)
114+
return composeErrorMsg(i18n.Tr("Invalid version"), e.Cause)
117115
}
118116

119117
// GRPCStatus converts the error into a *status.Status
@@ -132,7 +130,7 @@ type NoBoardsDetectedError struct {
132130
}
133131

134132
func (e *NoBoardsDetectedError) Error() string {
135-
return tr(
133+
return i18n.Tr(
136134
"Please specify an FQBN. The board on port %[1]s with protocol %[2]s can't be identified",
137135
e.Port.GetAddress(),
138136
e.Port.GetProtocol(),
@@ -152,7 +150,7 @@ type MultipleBoardsDetectedError struct {
152150
}
153151

154152
func (e *MultipleBoardsDetectedError) Error() string {
155-
return tr(
153+
return i18n.Tr(
156154
"Please specify an FQBN. Multiple possible boards detected on port %[1]s with protocol %[2]s",
157155
e.Port.GetAddress(),
158156
e.Port.GetProtocol(),
@@ -168,7 +166,7 @@ func (e *MultipleBoardsDetectedError) GRPCStatus() *status.Status {
168166
type MissingFQBNError struct{}
169167

170168
func (e *MissingFQBNError) Error() string {
171-
return tr("Missing FQBN (Fully Qualified Board Name)")
169+
return i18n.Tr("Missing FQBN (Fully Qualified Board Name)")
172170
}
173171

174172
// GRPCStatus converts the error into a *status.Status
@@ -182,7 +180,7 @@ type UnknownFQBNError struct {
182180
}
183181

184182
func (e *UnknownFQBNError) Error() string {
185-
return composeErrorMsg(tr("Unknown FQBN"), e.Cause)
183+
return composeErrorMsg(i18n.Tr("Unknown FQBN"), e.Cause)
186184
}
187185

188186
func (e *UnknownFQBNError) Unwrap() error {
@@ -201,7 +199,7 @@ type UnknownProfileError struct {
201199
}
202200

203201
func (e *UnknownProfileError) Error() string {
204-
return composeErrorMsg(tr("Profile '%s' not found", e.Profile), e.Cause)
202+
return composeErrorMsg(i18n.Tr("Profile '%s' not found", e.Profile), e.Cause)
205203
}
206204

207205
func (e *UnknownProfileError) Unwrap() error {
@@ -219,7 +217,7 @@ type InvalidProfileError struct {
219217
}
220218

221219
func (e *InvalidProfileError) Error() string {
222-
return composeErrorMsg(tr("Invalid profile"), e.Cause)
220+
return composeErrorMsg(i18n.Tr("Invalid profile"), e.Cause)
223221
}
224222

225223
func (e *InvalidProfileError) Unwrap() error {
@@ -235,7 +233,7 @@ func (e *InvalidProfileError) GRPCStatus() *status.Status {
235233
type MissingPortAddressError struct{}
236234

237235
func (e *MissingPortAddressError) Error() string {
238-
return tr("Missing port address")
236+
return i18n.Tr("Missing port address")
239237
}
240238

241239
// GRPCStatus converts the error into a *status.Status
@@ -247,7 +245,7 @@ func (e *MissingPortAddressError) GRPCStatus() *status.Status {
247245
type MissingPortProtocolError struct{}
248246

249247
func (e *MissingPortProtocolError) Error() string {
250-
return tr("Missing port protocol")
248+
return i18n.Tr("Missing port protocol")
251249
}
252250

253251
// GRPCStatus converts the error into a *status.Status
@@ -259,7 +257,7 @@ func (e *MissingPortProtocolError) GRPCStatus() *status.Status {
259257
type MissingPortError struct{}
260258

261259
func (e *MissingPortError) Error() string {
262-
return tr("Missing port")
260+
return i18n.Tr("Missing port")
263261
}
264262

265263
// GRPCStatus converts the error into a *status.Status
@@ -273,7 +271,7 @@ type NoMonitorAvailableForProtocolError struct {
273271
}
274272

275273
func (e *NoMonitorAvailableForProtocolError) Error() string {
276-
return tr("No monitor available for the port protocol %s", e.Protocol)
274+
return i18n.Tr("No monitor available for the port protocol %s", e.Protocol)
277275
}
278276

279277
// GRPCStatus converts the error into a *status.Status
@@ -285,7 +283,7 @@ func (e *NoMonitorAvailableForProtocolError) GRPCStatus() *status.Status {
285283
type MissingProgrammerError struct{}
286284

287285
func (e *MissingProgrammerError) Error() string {
288-
return tr("Missing programmer")
286+
return i18n.Tr("Missing programmer")
289287
}
290288

291289
// GRPCStatus converts the error into a *status.Status
@@ -298,7 +296,7 @@ func (e *MissingProgrammerError) GRPCStatus() *status.Status {
298296
type ProgrammerRequiredForUploadError struct{}
299297

300298
func (e *ProgrammerRequiredForUploadError) Error() string {
301-
return tr("A programmer is required to upload")
299+
return i18n.Tr("A programmer is required to upload")
302300
}
303301

304302
// GRPCStatus converts the error into a *status.Status
@@ -338,7 +336,7 @@ type ProgrammerNotFoundError struct {
338336
}
339337

340338
func (e *ProgrammerNotFoundError) Error() string {
341-
return composeErrorMsg(tr("Programmer '%s' not found", e.Programmer), e.Cause)
339+
return composeErrorMsg(i18n.Tr("Programmer '%s' not found", e.Programmer), e.Cause)
342340
}
343341

344342
func (e *ProgrammerNotFoundError) Unwrap() error {
@@ -357,7 +355,7 @@ type MonitorNotFoundError struct {
357355
}
358356

359357
func (e *MonitorNotFoundError) Error() string {
360-
return composeErrorMsg(tr("Monitor '%s' not found", e.Monitor), e.Cause)
358+
return composeErrorMsg(i18n.Tr("Monitor '%s' not found", e.Monitor), e.Cause)
361359
}
362360

363361
func (e *MonitorNotFoundError) Unwrap() error {
@@ -376,7 +374,7 @@ type InvalidPlatformPropertyError struct {
376374
}
377375

378376
func (e *InvalidPlatformPropertyError) Error() string {
379-
return tr("Invalid '%[1]s' property: %[2]s", e.Property, e.Value)
377+
return i18n.Tr("Invalid '%[1]s' property: %[2]s", e.Property, e.Value)
380378
}
381379

382380
// GRPCStatus converts the error into a *status.Status
@@ -390,7 +388,7 @@ type MissingPlatformPropertyError struct {
390388
}
391389

392390
func (e *MissingPlatformPropertyError) Error() string {
393-
return tr("Property '%s' is undefined", e.Property)
391+
return i18n.Tr("Property '%s' is undefined", e.Property)
394392
}
395393

396394
// GRPCStatus converts the error into a *status.Status
@@ -405,7 +403,7 @@ type PlatformNotFoundError struct {
405403
}
406404

407405
func (e *PlatformNotFoundError) Error() string {
408-
return composeErrorMsg(tr("Platform '%s' not found", e.Platform), e.Cause)
406+
return composeErrorMsg(i18n.Tr("Platform '%s' not found", e.Platform), e.Cause)
409407
}
410408

411409
// GRPCStatus converts the error into a *status.Status
@@ -423,7 +421,7 @@ type PlatformLoadingError struct {
423421
}
424422

425423
func (e *PlatformLoadingError) Error() string {
426-
return composeErrorMsg(tr("Error loading hardware platform"), e.Cause)
424+
return composeErrorMsg(i18n.Tr("Error loading hardware platform"), e.Cause)
427425
}
428426

429427
// GRPCStatus converts the error into a *status.Status
@@ -444,7 +442,7 @@ type LibraryNotFoundError struct {
444442
}
445443

446444
func (e *LibraryNotFoundError) Error() string {
447-
return composeErrorMsg(tr("Library '%s' not found", e.Library), e.Cause)
445+
return composeErrorMsg(i18n.Tr("Library '%s' not found", e.Library), e.Cause)
448446
}
449447

450448
// GRPCStatus converts the error into a *status.Status
@@ -463,7 +461,7 @@ type LibraryDependenciesResolutionFailedError struct {
463461
}
464462

465463
func (e *LibraryDependenciesResolutionFailedError) Error() string {
466-
return composeErrorMsg(tr("No valid dependencies solution found"), e.Cause)
464+
return composeErrorMsg(i18n.Tr("No valid dependencies solution found"), e.Cause)
467465
}
468466

469467
// GRPCStatus converts the error into a *status.Status
@@ -481,7 +479,7 @@ type PlatformAlreadyAtTheLatestVersionError struct {
481479
}
482480

483481
func (e *PlatformAlreadyAtTheLatestVersionError) Error() string {
484-
return tr("Platform '%s' is already at the latest version", e.Platform)
482+
return i18n.Tr("Platform '%s' is already at the latest version", e.Platform)
485483
}
486484

487485
// GRPCStatus converts the error into a *status.Status
@@ -496,7 +494,7 @@ func (e *PlatformAlreadyAtTheLatestVersionError) GRPCStatus() *status.Status {
496494
type MissingSketchPathError struct{}
497495

498496
func (e *MissingSketchPathError) Error() string {
499-
return tr("Missing sketch path")
497+
return i18n.Tr("Missing sketch path")
500498
}
501499

502500
// GRPCStatus converts the error into a *status.Status
@@ -510,7 +508,7 @@ type CantCreateSketchError struct {
510508
}
511509

512510
func (e *CantCreateSketchError) Error() string {
513-
return composeErrorMsg(tr("Can't create sketch"), e.Cause)
511+
return composeErrorMsg(i18n.Tr("Can't create sketch"), e.Cause)
514512
}
515513

516514
func (e *CantCreateSketchError) Unwrap() error {
@@ -523,7 +521,7 @@ type CantUpdateSketchError struct {
523521
}
524522

525523
func (e *CantUpdateSketchError) Error() string {
526-
return composeErrorMsg(tr("Can't update sketch"), e.Cause)
524+
return composeErrorMsg(i18n.Tr("Can't update sketch"), e.Cause)
527525
}
528526

529527
func (e *CantUpdateSketchError) Unwrap() error {
@@ -536,7 +534,7 @@ type CantOpenSketchError struct {
536534
}
537535

538536
func (e *CantOpenSketchError) Error() string {
539-
return composeErrorMsg(tr("Can't open sketch"), e.Cause)
537+
return composeErrorMsg(i18n.Tr("Can't open sketch"), e.Cause)
540538
}
541539

542540
func (e *CantOpenSketchError) Unwrap() error {
@@ -573,7 +571,7 @@ type FailedLibraryInstallError struct {
573571
}
574572

575573
func (e *FailedLibraryInstallError) Error() string {
576-
return composeErrorMsg(tr("Library install failed"), e.Cause)
574+
return composeErrorMsg(i18n.Tr("Library install failed"), e.Cause)
577575
}
578576

579577
func (e *FailedLibraryInstallError) Unwrap() error {
@@ -667,7 +665,7 @@ type FailedMonitorError struct {
667665
}
668666

669667
func (e *FailedMonitorError) Error() string {
670-
return composeErrorMsg(tr("Port monitor error"), e.Cause)
668+
return composeErrorMsg(i18n.Tr("Port monitor error"), e.Cause)
671669
}
672670

673671
func (e *FailedMonitorError) Unwrap() error {
@@ -780,7 +778,7 @@ type TempDirCreationFailedError struct {
780778
}
781779

782780
func (e *TempDirCreationFailedError) Error() string {
783-
return composeErrorMsg(tr("Cannot create temp dir"), e.Cause)
781+
return composeErrorMsg(i18n.Tr("Cannot create temp dir"), e.Cause)
784782
}
785783

786784
func (e *TempDirCreationFailedError) Unwrap() error {
@@ -798,7 +796,7 @@ type TempFileCreationFailedError struct {
798796
}
799797

800798
func (e *TempFileCreationFailedError) Error() string {
801-
return composeErrorMsg(tr("Cannot create temp file"), e.Cause)
799+
return composeErrorMsg(i18n.Tr("Cannot create temp file"), e.Cause)
802800
}
803801

804802
func (e *TempFileCreationFailedError) Unwrap() error {
@@ -817,7 +815,7 @@ type SignatureVerificationFailedError struct {
817815
}
818816

819817
func (e *SignatureVerificationFailedError) Error() string {
820-
return composeErrorMsg(tr("'%s' has an invalid signature", e.File), e.Cause)
818+
return composeErrorMsg(i18n.Tr("'%s' has an invalid signature", e.File), e.Cause)
821819
}
822820

823821
func (e *SignatureVerificationFailedError) Unwrap() error {
@@ -838,7 +836,7 @@ type MultiplePlatformsError struct {
838836
}
839837

840838
func (e *MultiplePlatformsError) Error() string {
841-
return tr("Found %d platforms matching \"%s\": %s",
839+
return i18n.Tr("Found %d platforms matching \"%s\": %s",
842840
len(e.Platforms), e.UserPlatform, strings.Join(e.Platforms, ", "))
843841
}
844842

@@ -857,7 +855,7 @@ type MultipleLibraryInstallDetected struct {
857855
}
858856

859857
func (e *MultipleLibraryInstallDetected) Error() string {
860-
res := tr("The library %s has multiple installations:", e.LibName) + "\n"
858+
res := i18n.Tr("The library %s has multiple installations:", e.LibName) + "\n"
861859
for _, lib := range e.LibsDir {
862860
res += fmt.Sprintf("- %s\n", lib)
863861
}
@@ -875,7 +873,7 @@ type InstanceNeedsReinitialization struct {
875873
}
876874

877875
func (e *InstanceNeedsReinitialization) Error() string {
878-
return tr("The instance is no longer valid and needs to be reinitialized")
876+
return i18n.Tr("The instance is no longer valid and needs to be reinitialized")
879877
}
880878

881879
// GRPCStatus converts the error into a *status.Status

0 commit comments

Comments
 (0)