Skip to content

Commit ae8a7f0

Browse files
committed
Removed unnecessary fmt.*printf
1 parent 4d5a472 commit ae8a7f0

File tree

35 files changed

+300
-337
lines changed

35 files changed

+300
-337
lines changed

arduino/builder/compilation_database.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ func LoadCompilationDatabase(file *paths.Path) (*CompilationDatabase, error) {
6060
// see https://clang.llvm.org/docs/JSONCompilationDatabase.html
6161
func (db *CompilationDatabase) SaveToFile() {
6262
if jsonContents, err := json.MarshalIndent(db.Contents, "", " "); err != nil {
63-
fmt.Printf(tr("Error serializing compilation database: %s"), err)
63+
fmt.Println(tr("Error serializing compilation database: %s", err))
6464
return
6565
} else if err := db.File.WriteFile(jsonContents); err != nil {
66-
fmt.Printf(tr("Error writing compilation database: %s"), err)
66+
fmt.Println(tr("Error writing compilation database: %s", err))
6767
}
6868
}
6969

@@ -75,7 +75,7 @@ func dirForCommand(command *exec.Cmd) string {
7575
}
7676
dir, err := os.Getwd()
7777
if err != nil {
78-
fmt.Printf(tr("Error getting current directory for compilation database: %s"), err)
78+
fmt.Println(tr("Error getting current directory for compilation database: %s", err))
7979
return ""
8080
}
8181
return dir

arduino/discovery/discovery.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ type discoveryMessage struct {
7171
func (msg discoveryMessage) String() string {
7272
s := fmt.Sprintf("type: %s", msg.EventType)
7373
if msg.Message != "" {
74-
s = fmt.Sprintf(tr("%[1]s, message: %[2]s"), s, msg.Message)
74+
s = tr("%[1]s, message: %[2]s", s, msg.Message)
7575
}
7676
if msg.ProtocolVersion != 0 {
77-
s = fmt.Sprintf(tr("%[1]s, protocol version: %[2]d"), s, msg.ProtocolVersion)
77+
s = tr("%[1]s, protocol version: %[2]d", s, msg.ProtocolVersion)
7878
}
7979
if len(msg.Ports) > 0 {
80-
s = fmt.Sprintf(tr("%[1]s, ports: %[2]s"), s, msg.Ports)
80+
s = tr("%[1]s, ports: %[2]s", s, msg.Ports)
8181
}
8282
if msg.Port != nil {
83-
s = fmt.Sprintf(tr("%[1]s, port: %[2]s"), s, msg.Port)
83+
s = tr("%[1]s, port: %[2]s", s, msg.Port)
8484
}
8585
return s
8686
}

arduino/libraries/librariesmanager/librariesmanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ var tr = i18n.Tr
6262
// Add adds a library to the alternatives
6363
func (alts *LibraryAlternatives) Add(library *libraries.Library) {
6464
if len(alts.Alternatives) > 0 && alts.Alternatives[0].Name != library.Name {
65-
panic(fmt.Sprintf(tr("the library name is different from the set (%[1]s != %[2]s)"), alts.Alternatives[0].Name, library.Name))
65+
panic(fmt.Sprintf("the library name is different from the set (%[1]s != %[2]s)", alts.Alternatives[0].Name, library.Name))
6666
}
6767
alts.Alternatives = append(alts.Alternatives, library)
6868
}

arduino/serialutils/serialutils.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ func Reset(portToTouch string, wait bool, cb *ResetProgressCallbacks, dryRun boo
130130
// do nothing!
131131
} else {
132132
if err := TouchSerialPortAt1200bps(portToTouch); err != nil {
133-
fmt.Printf(tr("TOUCH: error during reset: %s"), err)
134-
fmt.Println()
133+
fmt.Println(tr("TOUCH: error during reset: %s", err))
135134
}
136135
}
137136
}

arduino/sketch/sketch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ type InvalidSketchFolderNameError struct {
256256
}
257257

258258
func (e *InvalidSketchFolderNameError) Error() string {
259-
return fmt.Sprintf(tr("no valid sketch found in %[1]s: missing %[2]s"), e.SketchFolder, e.SketchFile)
259+
return tr("no valid sketch found in %[1]s: missing %[2]s", e.SketchFolder, e.SketchFile)
260260
}
261261

262262
// CheckForPdeFiles returns all files ending with .pde extension

cli/board/attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func initAttachCommand() *cobra.Command {
4242
Run: runAttachCommand,
4343
}
4444
attachCommand.Flags().StringVar(&attachFlags.searchTimeout, "timeout", "5s",
45-
fmt.Sprintf(tr("The connected devices search timeout, raise it if your board doesn't show up (e.g. to %s)."), "10s"))
45+
tr("The connected devices search timeout, raise it if your board doesn't show up (e.g. to %s).", "10s"))
4646
return attachCommand
4747
}
4848

cli/cli.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ func createCliCommandTree(cmd *cobra.Command) {
103103
cmd.AddCommand(version.NewCommand())
104104

105105
cmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, tr("Print the logs on the standard output."))
106-
cmd.PersistentFlags().String("log-level", "", fmt.Sprintf(tr("Messages with this level and above will be logged. Valid levels are: %s, %s, %s, %s, %s, %s, %s"), "trace", "debug", "info", "warn", "error", "fatal", "panic"))
106+
cmd.PersistentFlags().String("log-level", "", tr("Messages with this level and above will be logged. Valid levels are: %s", "trace, debug, info, warn, error, fatal, panic"))
107107
cmd.PersistentFlags().String("log-file", "", tr("Path to the file where logs will be written."))
108-
cmd.PersistentFlags().String("log-format", "", fmt.Sprintf(tr("The output format for the logs, can be {%s|%s}."), "text", "json"))
109-
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", fmt.Sprintf(tr("The output format, can be {%s|%s}."), "text", "json"))
108+
cmd.PersistentFlags().String("log-format", "", tr("The output format for the logs, can be: %s", "text, json"))
109+
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", tr("The output format for the logs, can be: %s", "text, json"))
110110
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", tr("The custom config file (if not specified the default will be used)."))
111111
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, tr("Comma-separated list of additional URLs for the Boards Manager."))
112112
cmd.PersistentFlags().Bool("no-color", false, "Disable colored output.")
@@ -196,7 +196,7 @@ func preRun(cmd *cobra.Command, args []string) {
196196
if logFile != "" {
197197
file, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
198198
if err != nil {
199-
fmt.Printf(tr("Unable to open file for logging: %s"), logFile)
199+
fmt.Println(tr("Unable to open file for logging: %s", logFile))
200200
os.Exit(errorcodes.ErrBadCall)
201201
}
202202

cli/compile/compile.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"bytes"
2020
"context"
2121
"encoding/json"
22-
"fmt"
2322
"os"
2423

2524
"github.com/arduino/arduino-cli/arduino/discovery"
@@ -94,7 +93,7 @@ func NewCommand() *cobra.Command {
9493
command.Flags().StringArrayVar(&buildProperties, "build-property", []string{},
9594
tr("Override a build property with a custom value. Can be used multiple times for multiple properties."))
9695
command.Flags().StringVar(&warnings, "warnings", "none",
97-
fmt.Sprintf(tr(`Optional, can be "%[1]s", "%[2]s", "%[3]s" and "%[4]s". Defaults to "%[1]s". Used to tell gcc which warning level to use (-W flag).`), "none", "default", "more", "all"))
96+
tr(`Optional, can be: %s. Used to tell gcc which warning level to use (-W flag).`, "none, default, more, all"))
9897
command.Flags().BoolVarP(&verbose, "verbose", "v", false, tr("Optional, turns on verbose mode."))
9998
command.Flags().BoolVar(&quiet, "quiet", false, tr("Optional, suppresses almost every output."))
10099
command.Flags().BoolVarP(&uploadAfterCompile, "upload", "u", false, tr("Upload the binary after the compilation."))
@@ -215,7 +214,7 @@ func run(cmd *cobra.Command, args []string) {
215214

216215
fields := map[string]string{}
217216
if len(userFieldRes.UserFields) > 0 {
218-
feedback.Printf(tr("Uploading to specified board using %s protocol requires the following info:"), discoveryPort.Protocol)
217+
feedback.Print(tr("Uploading to specified board using %s protocol requires the following info:", discoveryPort.Protocol))
219218
fields = arguments.AskForUserFields(userFieldRes.UserFields)
220219
}
221220

cli/config/init.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package config
1717

1818
import (
19-
"fmt"
2019
"os"
2120

2221
"github.com/arduino/arduino-cli/cli/errorcodes"
@@ -107,7 +106,7 @@ func runInitCommand(cmd *cobra.Command, args []string) {
107106
os.Exit(errorcodes.ErrGeneric)
108107
}
109108

110-
msg := fmt.Sprintf(tr("Config file written to: %s"), configFileAbsPath.String())
109+
msg := tr("Config file written to: %s", configFileAbsPath.String())
111110
logrus.Info(msg)
112111
feedback.Print(msg)
113112
}

cli/core/download.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ import (
3333

3434
func initDownloadCommand() *cobra.Command {
3535
downloadCommand := &cobra.Command{
36-
Use: fmt.Sprintf(tr("download [%s:%s[@%s]]..."), tr("PACKAGER"), tr("ARCH"), tr("VERSION")),
36+
Use: fmt.Sprintf("download [%s:%s[@%s]]...", tr("PACKAGER"), tr("ARCH"), tr("VERSION")),
3737
Short: tr("Downloads one or more cores and corresponding tool dependencies."),
3838
Long: tr("Downloads one or more cores and corresponding tool dependencies."),
3939
Example: "" +
40-
" " + os.Args[0] + " core download arduino:samd # " + tr("to download the latest version of Arduino SAMD core.\n") +
41-
" " + os.Args[0] + " core download arduino:[email protected] # " + tr("for a specific version (in this case 1.6.9)."),
40+
" " + os.Args[0] + " core download arduino:samd # " + tr("download the latest version of Arduino SAMD core.") + "\n" +
41+
" " + os.Args[0] + " core download arduino:[email protected] # " + tr("download a specific version (in this case 1.6.9)."),
4242
Args: cobra.MinimumNArgs(1),
4343
Run: runDownloadCommand,
4444
}

0 commit comments

Comments
 (0)