Skip to content

Commit

Permalink
gps: remove wcIgnoreSuffix const
Browse files Browse the repository at this point in the history
It's clearer just to use the string literal in this case.
  • Loading branch information
sdboyer committed Oct 14, 2017
1 parent 50326d7 commit da9b750
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 0 additions & 2 deletions internal/gps/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"strings"
)

const wcIgnoreSuffix = "*"

// string headers used to demarcate sections in hash input creation
const (
hhConstraints = "-CONSTRAINTS-"
Expand Down
11 changes: 4 additions & 7 deletions internal/gps/pkgtree/pkgtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import (
"github.com/armon/go-radix"
)

// wildcard ignore suffix
const wcIgnoreSuffix = "*"

// Package represents a Go package. It contains a subset of the information
// go/build.Package does.
type Package struct {
Expand Down Expand Up @@ -1055,22 +1052,22 @@ func NewIgnoredRuleset(ig []string) *IgnoredRuleset {
sort.Strings(ig)
for _, i := range ig {
// Skip global ignore and empty string.
if i == wcIgnoreSuffix || i == "" {
if i == "*" || i == "" {
continue
}

_, wildi, has := ir.t.LongestPrefix(i)
// We may not always have a value here, but if we do, then it's a bool.
wild, _ := wildi.(bool)
// Check if it's a wildcard ignore.
if strings.HasSuffix(i, wcIgnoreSuffix) {
if strings.HasSuffix(i, "*") {
// Check if it is ineffectual.
if has && wild {
// Skip ineffectual wildcard ignore.
continue
}
// Create the ignore prefix and insert in the radix tree.
ir.t.Insert(i[:len(i)-len(wcIgnoreSuffix)], true)
ir.t.Insert(i[:len(i)-1], true)
} else if !has || !wild {
ir.t.Insert(i, false)
}
Expand Down Expand Up @@ -1116,7 +1113,7 @@ func (ir *IgnoredRuleset) ToSlice() []string {
ir.t.Walk(func(s string, v interface{}) bool {
if s != "" {
if v.(bool) {
items = append(items, s+wcIgnoreSuffix)
items = append(items, s+"*")
} else {
items = append(items, s)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gps/pkgtree/pkgtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ func TestIgnoredRuleset(t *testing.T) {
}{
{
name: "only skip global ignore",
inputs: []string{wcIgnoreSuffix},
inputs: []string{"*"},
wantEmptyTree: true,
},
{
Expand Down

0 comments on commit da9b750

Please sign in to comment.