From 0b6104c48893fd32c9650a9f179a561d3d837bba Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:14:18 +0000 Subject: [PATCH] refactor: replace empty slice literal with `var` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An empty slice can be represented by `nil` or an empty slice literal. They are functionally equivalent — their `len` and `cap` are both zero — but the `nil` slice is the preferred style. For more information about empty slices, see [Declaring Empty Slices](https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices). --- plugin/analyzer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/analyzer.go b/plugin/analyzer.go index 39b01d4..0358d35 100644 --- a/plugin/analyzer.go +++ b/plugin/analyzer.go @@ -36,7 +36,7 @@ type Diff struct { // Compare generates a list of diffs (incompatibility) between two descriptors func (d Descriptor) Compare(other Descriptor) []Diff { - diffs := []Diff{} + var diffs []Diff for pkgName, expectedVersion := range d.Deps { v, ok := other.Deps[pkgName] @@ -103,7 +103,8 @@ func cleanVersion(v string) string { } func parseSumFile(r io.Reader) ([]string, error) { - lines := []string{} + var lines []string + scanner := bufio.NewScanner(r) for scanner.Scan() { lines = append(lines, scanner.Text())