Skip to content

Commit

Permalink
Merge pull request PaesslerAG#57 from Jacalz/staticcheck
Browse files Browse the repository at this point in the history
A few code cleanups as suggested by staticcheck
  • Loading branch information
generikvault committed Apr 29, 2021
2 parents 2271a5a + 7bc0058 commit 4f5f9c0
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions evaluable.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func regEx(a, b Evaluable) (Evaluable, error) {
return matched, err
}, nil
}
s, err := b.EvalString(nil, nil)
s, err := b.EvalString(context.TODO(), nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func notRegEx(a, b Evaluable) (Evaluable, error) {
return !matched, err
}, nil
}
s, err := b.EvalString(nil, nil)
s, err := b.EvalString(context.TODO(), nil)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions language.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ func (l *Language) makePrefixKey(key string) interface{} {
}

func (l *Language) makeInfixKey(key string) string {
runes := []rune(key)
for _, r := range runes {
for _, r := range key {
l.operatorSymbols[r] = struct{}{}
}
return key
Expand Down
1 change: 0 additions & 1 deletion operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (op *infix) initiate(name string) {
return f(a, b)
}, nil
}
return
}

type opFunc func(a, b interface{}) (interface{}, error)
Expand Down
3 changes: 1 addition & 2 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ func (p *Parser) parseOperator(c context.Context, stack *stageStack, eval Evalua
p.Camouflage("operator")
return stage{Evaluable: eval}, nil
}
operator, _ := p.operators[op]
switch operator := operator.(type) {
switch operator := p.operators[op].(type) {
case *infix:
return stage{
Evaluable: eval,
Expand Down
3 changes: 1 addition & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Parser struct {
func newParser(expression string, l Language) *Parser {
sc := scanner.Scanner{}
sc.Init(strings.NewReader(expression))
sc.Error = func(*scanner.Scanner, string) { return }
sc.Error = func(*scanner.Scanner, string) {}
sc.Filename = expression + "\t"
p := &Parser{scanner: sc, Language: l}
p.resetScannerProperties()
Expand Down Expand Up @@ -81,7 +81,6 @@ func (p *Parser) Camouflage(unit string, expected ...rune) {
panic(fmt.Errorf("can only Camouflage() after Scan(): %v", p.camouflage))
}
p.camouflage = p.Expected(unit, expected...)
return
}

// Peek returns the next Unicode character in the source without advancing
Expand Down
7 changes: 1 addition & 6 deletions random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var (
hello = "hello"
empty struct{}
empty2 *string
empty3 *int

values = []interface{}{
-1,
Expand Down Expand Up @@ -101,13 +100,9 @@ var (
"\n",
"\000",
}

panics = 0
)

const (
SEED = 1487873697990155515
)
const SEED = 1487873697990155515

func BenchmarkRandom(bench *testing.B) {
rand.Seed(SEED)
Expand Down

0 comments on commit 4f5f9c0

Please sign in to comment.