From be3e74ca43525c8c4083804ffc426f810aeef722 Mon Sep 17 00:00:00 2001 From: Russell Stanley Date: Wed, 9 Feb 2022 12:06:28 +1030 Subject: [PATCH] code cleanup addressing comments on PR --- cmd/rv/probe.go | 7 +++---- cmd/rv/probe_circleci.go | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/rv/probe.go b/cmd/rv/probe.go index d58d92d9..c7a2c558 100644 --- a/cmd/rv/probe.go +++ b/cmd/rv/probe.go @@ -90,13 +90,13 @@ func (tp *turbidityProbe) Write(p []byte) (int, error) { file, err := os.CreateTemp("temp", "video*.h264") if err != nil { tp.log.Error("failed to create temp file", "error", err.Error()) - return len(p), err + return 0, err } defer os.Remove(file.Name()) - _, err = file.Write(p) + n, err := file.Write(p) if err != nil { tp.log.Error("failed to write to temporary file", "error", err.Error()) - return len(p), err + return n, err } // Read the file and store each frame. @@ -118,7 +118,6 @@ func (tp *turbidityProbe) Write(p []byte) (int, error) { tp.contrast = stat.Mean(res.Contrast, nil) tp.sharpness = stat.Mean(res.Sharpness, nil) default: - return len(p), nil } return len(p), nil } diff --git a/cmd/rv/probe_circleci.go b/cmd/rv/probe_circleci.go index 26175f3b..3c82038e 100644 --- a/cmd/rv/probe_circleci.go +++ b/cmd/rv/probe_circleci.go @@ -39,7 +39,7 @@ type turbidityProbe struct { sharpness, contrast float64 } -// NewTurbidityProbe returns a empty turbidity probe for CircleCI testing only. +// NewTurbidityProbe returns an empty turbidity probe for CircleCI testing only. func NewTurbidityProbe(log logger.Logger, delay time.Duration) (*turbidityProbe, error) { tp := new(turbidityProbe) return tp, nil @@ -47,7 +47,7 @@ func NewTurbidityProbe(log logger.Logger, delay time.Duration) (*turbidityProbe, // Write performs no operation for CircleCI testing only. func (tp *turbidityProbe) Write(p []byte) (int, error) { - return len(p), nil + return 0, nil } func (tp *turbidityProbe) Close() error {