Skip to content

Commit

Permalink
revert regex related linting (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysugimoto authored Jul 13, 2021
1 parent f37eb0a commit eca40c4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/fatih/color v1.12.0
github.com/goccy/go-yaml v1.8.9 // indirect
github.com/goccy/go-yaml v1.8.9
github.com/google/go-cmp v0.5.6
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/k0kubun/pp v2.4.0+incompatible
Expand Down
12 changes: 0 additions & 12 deletions linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package linter
import (
"fmt"
"net"
"regexp"
"strings"

"github.com/ysugimoto/falco/ast"
Expand Down Expand Up @@ -1196,17 +1195,6 @@ func (l *Linter) lintInfixExpression(exp *ast.InfixExpression, ctx *context.Cont
} else if !expectType(right, types.StringType, types.IPType, types.AclType) {
l.Error(InvalidTypeExpression(exp.GetMeta(), right, types.StringType, types.IPType, types.AclType).Match(OPERATOR_CONDITIONAL))
}
// And, if right expression is STRING, regex must be valid
if v, ok := exp.Right.(*ast.String); ok {
if _, err := regexp.Compile(v.Value); err != nil {
err := &LintError{
Severity: ERROR,
Token: exp.Right.GetMeta().Token,
Message: "regex string is invalid, " + err.Error(),
}
l.Error(err)
}
}
return types.BoolType
case "+":
// Plus operator behaves string concatenation.
Expand Down
10 changes: 0 additions & 10 deletions linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,13 +1238,3 @@ sub vcl_recv {
}`
assertNoError(t, input)
}

func TestRegexExpressionIsInvalid(t *testing.T) {
input := `
sub vcl_recv {
#Fastly recv
if (req.url ~ "/foo/(.+") {
}
}`
assertError(t, input)
}

0 comments on commit eca40c4

Please sign in to comment.