Skip to content

Commit 91290a4

Browse files
FedeBevdaveshanley
authored andcommitted
fix argument err is overwritten before first use
1 parent e6b83ec commit 91290a4

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

cmd/console.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func GetConsoleCommand() *cobra.Command {
204204
return err
205205
}
206206
p = args[1]
207-
f, err = os.Stat(filepath.Join(repo, p))
207+
_, err = os.Stat(filepath.Join(repo, p))
208208
if err != nil {
209209
pterm.Error.Printf("Cannot open file/repository: '%s'\n", args[1])
210210
return err

cmd/html_report.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func GetHTMLReportCommand() *cobra.Command {
180180
if len(report) <= 0 && er != nil {
181181
return er[0]
182182
}
183-
return writeReportFile(err, reportFile, report)
183+
return writeReportFile(reportFile, report)
184184
}
185185

186186
} else {
@@ -215,7 +215,7 @@ func GetHTMLReportCommand() *cobra.Command {
215215
return err
216216
}
217217
p = args[1]
218-
f, err = os.Stat(filepath.Join(repo, p))
218+
_, err = os.Stat(filepath.Join(repo, p))
219219
if err != nil {
220220
pterm.Error.Printf("Cannot open file/repository: '%s'\n\n", args[1])
221221
return err
@@ -232,7 +232,7 @@ func GetHTMLReportCommand() *cobra.Command {
232232
return er[0]
233233
}
234234

235-
writeErr := writeReportFile(err, reportFile, report)
235+
writeErr := writeReportFile(reportFile, report)
236236

237237
return writeErr
238238

@@ -262,7 +262,7 @@ func GetHTMLReportCommand() *cobra.Command {
262262
return errors.New("unable to process specifications")
263263
}
264264

265-
return writeReportFile(err, reportFile, report)
265+
return writeReportFile(reportFile, report)
266266
}
267267
}
268268
pterm.Error.Println("wrong number of arguments, expecting two (2)")
@@ -276,8 +276,8 @@ func GetHTMLReportCommand() *cobra.Command {
276276
return cmd
277277
}
278278

279-
func writeReportFile(err error, reportFile string, report []byte) error {
280-
err = os.WriteFile(reportFile, report, 0744)
279+
func writeReportFile(reportFile string, report []byte) error {
280+
err := os.WriteFile(reportFile, report, 0744)
281281
if err != nil {
282282
pterm.Error.Println(err.Error())
283283
return err

cmd/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func GetReportCommand() *cobra.Command {
151151
return err
152152
}
153153
p = args[1]
154-
f, err = os.Stat(filepath.Join(repo, p))
154+
_, err = os.Stat(filepath.Join(repo, p))
155155
if err != nil {
156156
pterm.Error.Printf("Cannot open file/repository: '%s'\n", args[1])
157157
return err

cmd/summary.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func GetSummaryCommand() *cobra.Command {
230230
return err
231231
}
232232
p = args[1]
233-
f, err = os.Stat(filepath.Join(repo, p))
233+
_, err = os.Stat(filepath.Join(repo, p))
234234
if err != nil {
235235
pterm.Error.Printf("Cannot open file/repository: '%s'", args[1])
236236
return err

0 commit comments

Comments
 (0)