Skip to content

Commit 7c20ba9

Browse files
authored
fix err "non-constant format string in call to fmt.Fprintf" (#1760)
## Checklist - [X] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: #1759 - [ ] if you changed anything related to how experiments work and you need to reflect these changes in the ooni/spec repository, please link to the related ooni/spec pull request: <!-- add URL here --> - [ ] if you changed code inside an experiment, make sure you bump its version number <!-- Reminder: Location of the issue tracker: https://github.com/ooni/probe --> ## Description Fixes some format strings
1 parent 8fefed8 commit 7c20ba9

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

cmd/ooniprobe/internal/log/handlers/cli/cli.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ func logSectionTitle(w io.Writer, f log.Fields) error {
6666
colWidth := 24
6767

6868
title := f.Get("title").(string)
69-
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n")
69+
fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth+2))
7070
fmt.Fprintf(w, "┃ %s ┃\n", utils.RightPad(title, colWidth))
71-
fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n")
71+
fmt.Fprintf(w, "┗%s┛\n", strings.Repeat("━", colWidth+2))
7272
return nil
7373
}
7474

@@ -91,13 +91,13 @@ func logTable(w io.Writer, f log.Fields) error {
9191
}
9292
}
9393

94-
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n")
94+
fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth+2))
9595
for _, line := range lines {
9696
fmt.Fprintf(w, "┃ %s ┃\n",
9797
utils.RightPad(line, colWidth),
9898
)
9999
}
100-
fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n")
100+
fmt.Fprintf(w, "┗%s┛\n", strings.Repeat("━", colWidth+2))
101101
return nil
102102
}
103103

cmd/ooniprobe/internal/log/handlers/cli/measurements.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func logTestKeys(w io.Writer, testKeys string) error {
3434
testKeysLines[len(testKeysLines)-1] = testKeysLines[len(testKeysLines)-1] + "}"
3535
}
3636
for _, line := range testKeysLines {
37-
fmt.Fprintf(w, fmt.Sprintf("│ %s │\n",
37+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n",
3838
utils.RightPad(line, colWidth*2)))
3939
}
4040
return nil
@@ -61,30 +61,30 @@ func logMeasurementItem(w io.Writer, f log.Fields) error {
6161
isFirst := f.Get("is_first").(bool)
6262
isLast := f.Get("is_last").(bool)
6363
if isFirst {
64-
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth*2+2)+"┓\n")
64+
fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth*2+2))
6565
} else {
66-
fmt.Fprintf(w, "┢"+strings.Repeat("━", colWidth*2+2)+"┪\n")
66+
fmt.Fprintf(w, "┢%s┪\n", strings.Repeat("━", colWidth*2+2))
6767
}
6868

6969
anomalyStr := fmt.Sprintf("ok: %s", statusIcon(!isAnomaly))
7070
uploadStr := fmt.Sprintf("uploaded: %s", statusIcon(isUploaded))
7171
failureStr := fmt.Sprintf("success: %s", statusIcon(!isFailed))
7272

73-
fmt.Fprintf(w, fmt.Sprintf("│ %s │\n",
73+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n",
7474
utils.RightPad(
7575
fmt.Sprintf("#%d", rID), colWidth*2)))
7676

7777
if url != "" {
78-
fmt.Fprintf(w, fmt.Sprintf("│ %s │\n",
78+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s │\n",
7979
utils.RightPad(
8080
fmt.Sprintf("%s (%s)", url, urlCategoryCode), colWidth*2)))
8181
}
8282

83-
fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n",
83+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n",
8484
utils.RightPad(testName, colWidth),
8585
utils.RightPad(anomalyStr, colWidth)))
8686

87-
fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n",
87+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n",
8888
utils.RightPad(failureStr, colWidth),
8989
utils.RightPad(uploadStr, colWidth)))
9090

cmd/ooniprobe/internal/log/handlers/cli/results.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,27 @@ func logResultItem(w io.Writer, f log.Fields) error {
103103
index := f.Get("index").(int)
104104
totalCount := f.Get("total_count").(int)
105105
if index == 0 {
106-
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth*2+2)+"┓\n")
106+
fmt.Fprintf(w, "┏%s┓\n", strings.Repeat("━", colWidth*2+2))
107107
} else {
108-
fmt.Fprintf(w, "┢"+strings.Repeat("━", colWidth*2+2)+"┪\n")
108+
fmt.Fprintf(w, "┢%s┪\n", strings.Repeat("━", colWidth*2+2))
109109
}
110110

111111
firstRow := utils.RightPad(fmt.Sprintf("#%d - %s", rID, startTime.Format(time.RFC822)), colWidth*2)
112-
fmt.Fprintf(w, "┃ "+firstRow+"\n")
113-
fmt.Fprintf(w, "┡"+strings.Repeat("━", colWidth*2+2)+"┩\n")
112+
fmt.Fprintf(w, "┃ %s\n", firstRow)
113+
fmt.Fprintf(w, "┡%s┩\n",strings.Repeat("━", colWidth*2+2))
114114

115115
summary := makeSummary(name,
116116
f.Get("measurement_count").(uint64),
117117
f.Get("measurement_anomaly_count").(uint64),
118118
f.Get("test_keys").(string))
119119

120-
fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n",
120+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n",
121121
utils.RightPad(name, colWidth),
122122
utils.RightPad(summary[0], colWidth)))
123-
fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n",
123+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n",
124124
utils.RightPad(networkName, colWidth),
125125
utils.RightPad(summary[1], colWidth)))
126-
fmt.Fprintf(w, fmt.Sprintf("│ %s %s│\n",
126+
fmt.Fprintf(w, "%s", fmt.Sprintf("│ %s %s│\n",
127127
utils.RightPad(asn, colWidth),
128128
utils.RightPad(summary[2], colWidth)))
129129

0 commit comments

Comments
 (0)