From 2881292427531f06984f6b198aa72b4eba0bdc75 Mon Sep 17 00:00:00 2001 From: Ron Wolf Date: Thu, 13 Jun 2019 13:40:11 -0400 Subject: [PATCH 1/2] Remove redundant nil check Lack of JSON encode error will produce & return nil regardless --- pkg/cli/stats.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/cli/stats.go b/pkg/cli/stats.go index a9e72b82..6fa62b54 100644 --- a/pkg/cli/stats.go +++ b/pkg/cli/stats.go @@ -53,11 +53,8 @@ func stats(c *cli.Context) error { } if c.Bool("json") { - if err := json.NewEncoder(os.Stdout).Encode(result); err != nil { - return err - } - - return nil + err := json.NewEncoder(os.Stdout).Encode(result) + return err } fmt.Printf("%s - %s\n", start.Format("Jan 01, 2006"), end.Format("Jan 01, 2006")) From 5d8a7b3e3dda0c9a4886b93f99b82c67d29a4548 Mon Sep 17 00:00:00 2001 From: Ron Wolf Date: Fri, 19 Jun 2020 17:18:31 -0400 Subject: [PATCH 2/2] Remove redundant assignment Apply suggestions from code review Co-authored-by: Miguel Piedrafita --- pkg/cli/stats.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/cli/stats.go b/pkg/cli/stats.go index 6fa62b54..7ab15014 100644 --- a/pkg/cli/stats.go +++ b/pkg/cli/stats.go @@ -53,8 +53,7 @@ func stats(c *cli.Context) error { } if c.Bool("json") { - err := json.NewEncoder(os.Stdout).Encode(result) - return err + return json.NewEncoder(os.Stdout).Encode(result) } fmt.Printf("%s - %s\n", start.Format("Jan 01, 2006"), end.Format("Jan 01, 2006"))