Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit da9b750

Browse files
committed
gps: remove wcIgnoreSuffix const
It's clearer just to use the string literal in this case.
1 parent 50326d7 commit da9b750

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

internal/gps/hash.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"strings"
1414
)
1515

16-
const wcIgnoreSuffix = "*"
17-
1816
// string headers used to demarcate sections in hash input creation
1917
const (
2018
hhConstraints = "-CONSTRAINTS-"

internal/gps/pkgtree/pkgtree.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import (
2222
"github.com/armon/go-radix"
2323
)
2424

25-
// wildcard ignore suffix
26-
const wcIgnoreSuffix = "*"
27-
2825
// Package represents a Go package. It contains a subset of the information
2926
// go/build.Package does.
3027
type Package struct {
@@ -1055,22 +1052,22 @@ func NewIgnoredRuleset(ig []string) *IgnoredRuleset {
10551052
sort.Strings(ig)
10561053
for _, i := range ig {
10571054
// Skip global ignore and empty string.
1058-
if i == wcIgnoreSuffix || i == "" {
1055+
if i == "*" || i == "" {
10591056
continue
10601057
}
10611058

10621059
_, wildi, has := ir.t.LongestPrefix(i)
10631060
// We may not always have a value here, but if we do, then it's a bool.
10641061
wild, _ := wildi.(bool)
10651062
// Check if it's a wildcard ignore.
1066-
if strings.HasSuffix(i, wcIgnoreSuffix) {
1063+
if strings.HasSuffix(i, "*") {
10671064
// Check if it is ineffectual.
10681065
if has && wild {
10691066
// Skip ineffectual wildcard ignore.
10701067
continue
10711068
}
10721069
// Create the ignore prefix and insert in the radix tree.
1073-
ir.t.Insert(i[:len(i)-len(wcIgnoreSuffix)], true)
1070+
ir.t.Insert(i[:len(i)-1], true)
10741071
} else if !has || !wild {
10751072
ir.t.Insert(i, false)
10761073
}
@@ -1116,7 +1113,7 @@ func (ir *IgnoredRuleset) ToSlice() []string {
11161113
ir.t.Walk(func(s string, v interface{}) bool {
11171114
if s != "" {
11181115
if v.(bool) {
1119-
items = append(items, s+wcIgnoreSuffix)
1116+
items = append(items, s+"*")
11201117
} else {
11211118
items = append(items, s)
11221119
}

internal/gps/pkgtree/pkgtree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,7 @@ func TestIgnoredRuleset(t *testing.T) {
20502050
}{
20512051
{
20522052
name: "only skip global ignore",
2053-
inputs: []string{wcIgnoreSuffix},
2053+
inputs: []string{"*"},
20542054
wantEmptyTree: true,
20552055
},
20562056
{

0 commit comments

Comments
 (0)