Skip to content

Commit

Permalink
refactor: use a clearer name for nextIfValid
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Nov 7, 2024
1 parent 0ec86a4 commit 22a69e7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/spdx/satisfies.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ var allowed = map[string][]string{
"END": {},
}

// nextIfValid returns the next token if it is valid, otherwise returns an error
func (ts *tokens) nextIfValid() (string, error) {
// nextAndIsNextNextValid returns both the next token, and checks if the token after that one is valid
func (ts *tokens) nextAndIsNextNextValid() (string, error) {
next := ts.next()

return next, ts.isNextValid(next)
Expand Down Expand Up @@ -165,7 +165,7 @@ func parseOr(tokens *tokens) (node, error) {
}

for tokens.peek() == "OR" {
operator, err := tokens.nextIfValid()
operator, err := tokens.nextAndIsNextNextValid()
if err != nil {
return nil, err
}
Expand All @@ -192,7 +192,7 @@ func parseAnd(tokens *tokens) (node, error) {
}

for tokens.peek() == "AND" {
operator, err := tokens.nextIfValid()
operator, err := tokens.nextAndIsNextNextValid()
if err != nil {
return nil, err
}
Expand All @@ -213,7 +213,7 @@ func parseAnd(tokens *tokens) (node, error) {
}

func parseExpression(tokens *tokens) (node, error) {
next, err := tokens.nextIfValid()
next, err := tokens.nextAndIsNextNextValid()
if err != nil {
return nil, err
}
Expand All @@ -228,7 +228,7 @@ func parseExpression(tokens *tokens) (node, error) {
return nil, errors.New("missing closing bracket")
}

_, err = tokens.nextIfValid()
_, err = tokens.nextAndIsNextNextValid()
if err != nil {
return nil, err
}
Expand All @@ -238,7 +238,7 @@ func parseExpression(tokens *tokens) (node, error) {

// currently WITH expressions are just treated as part of the license
if tokens.peek() == "WITH" {
nex2, err := tokens.nextIfValid()
nex2, err := tokens.nextAndIsNextNextValid()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 22a69e7

Please sign in to comment.