Skip to content

Commit

Permalink
Delint'd.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkw31 committed Oct 28, 2024
1 parent e5cfddb commit 5ccb031
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ import (
"github.com/wtsi-ssg/wrstat/v5/internal/encode"
)

const (
statsColumn = 0
byUserGroupColumn = 2
)

// chtsvCmd represents the chtsv command.
var decodeCmd = &cobra.Command{
Use: "decode",
Expand All @@ -52,7 +57,7 @@ Files with names ending in '.gz' will be decompressed before printing.
Other files are simply copied to stdout.
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
for _, file := range args {
if err := decodeFile(file); err != nil {
die("%s", err)
Expand Down Expand Up @@ -88,8 +93,10 @@ func decodeFile(file string) error {
var col int

if strings.HasSuffix(file, ".byusergroup") {

Check failure on line 95 in cmd/decode.go

View workflow job for this annotation

GitHub Actions / lint

ifElseChain: rewrite if-else to switch statement (gocritic)
col = 2
} else if !strings.HasSuffix(file, ".stats") {
col = byUserGroupColumn
} else if strings.HasSuffix(file, ".stats") {
col = statsColumn
} else {
_, err = io.Copy(os.Stdout, r)

return err
Expand All @@ -115,7 +122,9 @@ func decodeColumn(r io.Reader, col int) error {
}

if line == "\n" {
w.WriteString(line)
if _, err := w.WriteString(line); err != nil {

Check failure on line 125 in cmd/decode.go

View workflow job for this annotation

GitHub Actions / lint

shadow: declaration of "err" shadows declaration at line 115 (govet)
return err
}

continue
}
Expand Down

0 comments on commit 5ccb031

Please sign in to comment.