From 60f53036f41d3ac4744689200fb21c34e3084532 Mon Sep 17 00:00:00 2001 From: arshchimni Date: Wed, 3 Aug 2022 12:42:17 +0530 Subject: [PATCH 1/4] add minor version check --- constraints.go | 4 ++++ constraints_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/constraints.go b/constraints.go index 547613f..4926c3f 100644 --- a/constraints.go +++ b/constraints.go @@ -534,6 +534,10 @@ func constraintCaret(v *Version, c *constraint) (bool, error) { } return false, fmt.Errorf("%s does not have same minor version as %s. Expected minor versions to match when constraint major version is 0", v, c.orig) } + // ^ when the minor is 0 and minor > 0 is >=0.y.z < 0.y+1 + if c.con.Minor() == 0 && v.Minor() > 0 { + return false, fmt.Errorf("%s does not have same minor version as %s", v, c.orig) + } // At this point the major is 0 and the minor is 0 and not dirty. The patch // is not dirty so we need to check if they are equal. If they are not equal diff --git a/constraints_test.go b/constraints_test.go index 0504399..0dbf4b7 100644 --- a/constraints_test.go +++ b/constraints_test.go @@ -362,6 +362,8 @@ func TestConstraintsCheck(t *testing.T) { {"^1.x", "1.1.1-beta1", false}, {"^1.1.2-alpha", "1.2.1-beta1", true}, {"^1.2.x-alpha", "1.1.1-beta1", false}, + {"^0.0.1", "0.0.1", true}, + {"^0.0.1", "0.3.1", false}, {"~*", "2.1.1", true}, {"~1", "2.1.1", false}, {"~1", "1.3.5", true}, From b2d12cc30ed5c4398c77f2a2de58eb4e22bd96fd Mon Sep 17 00:00:00 2001 From: arshchimni Date: Wed, 3 Aug 2022 12:45:04 +0530 Subject: [PATCH 2/4] update comment --- constraints.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constraints.go b/constraints.go index 4926c3f..b7dd045 100644 --- a/constraints.go +++ b/constraints.go @@ -534,7 +534,7 @@ func constraintCaret(v *Version, c *constraint) (bool, error) { } return false, fmt.Errorf("%s does not have same minor version as %s. Expected minor versions to match when constraint major version is 0", v, c.orig) } - // ^ when the minor is 0 and minor > 0 is >=0.y.z < 0.y+1 + // ^ when the minor is 0 and minor > 0 is =0.0.z if c.con.Minor() == 0 && v.Minor() > 0 { return false, fmt.Errorf("%s does not have same minor version as %s", v, c.orig) } From 27a0910c7c6d603cf8482dbcfd0106539a32ac12 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 9 Aug 2022 10:55:55 -0400 Subject: [PATCH 3/4] Fix failing test on error message Signed-off-by: Matt Farina --- constraints_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constraints_test.go b/constraints_test.go index 0dbf4b7..6a75a16 100644 --- a/constraints_test.go +++ b/constraints_test.go @@ -600,7 +600,7 @@ func TestConstraintsValidate(t *testing.T) { {"^1.x", "2.1.1", "2.1.1 does not have same major version as 1.x"}, {"^0.2", "0.3.0", "0.3.0 does not have same minor version as 0.2. Expected minor versions to match when constraint major version is 0"}, {"^0.2", "0.1.1", "0.1.1 is less than 0.2"}, - {"^0.0.3", "0.1.1", "0.1.1 does not equal 0.0.3. Expect version and constraint to equal when major and minor versions are 0"}, + {"^0.0.3", "0.1.1", "0.1.1 does not have same minor version as 0.0.3"}, {"^0.0.3", "0.0.4", "0.0.4 does not equal 0.0.3. Expect version and constraint to equal when major and minor versions are 0"}, {"^0.0.3", "0.0.2", "0.0.2 is less than 0.0.3"}, {"~1", "2.1.2", "2.1.2 does not have same major version as 1"}, From 582a2587713da325dd68478f2edbdaf4e4a2c5b7 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 9 Aug 2022 11:06:58 -0400 Subject: [PATCH 4/4] Updating golangci-lint config To handle deprecated linter and testing duplication Signed-off-by: Matt Farina --- .golangci.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fdbdf14..c87d1c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,23 +4,27 @@ run: linters: disable-all: true enable: + - misspell + - structcheck + - govet + - staticcheck - deadcode - - dupl - errcheck - - gofmt - - goimports - - golint - - gosimple - - govet + - varcheck + - unparam - ineffassign - - misspell - nakedret - - structcheck + - gocyclo + - dupl + - goimports + - revive + - gosec + - gosimple + - typecheck - unused - - varcheck linters-settings: gofmt: simplify: true dupl: - threshold: 400 + threshold: 600