Skip to content

Commit

Permalink
Skip checking for regex patterns of variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed May 13, 2024
1 parent 110fb6d commit ca30569
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions jsonte/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/MCDevKit/jsonte/jsonte/utils"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"regexp"
"strconv"
"strings"
)
Expand Down Expand Up @@ -145,7 +144,7 @@ var reservedNames = []string{
"do",
}

const variableNamePattern = "^[a-zA-Z_$][a-zA-Z0-9_$]*$"
//const variableNamePattern = "^[a-zA-Z_$][a-zA-Z0-9_$]*$"

func VerifyReservedNames(o *types.JsonObject, path string) error {
for _, key := range o.Value.Keys() {
Expand Down Expand Up @@ -196,14 +195,5 @@ func verifyReservedName(key string, path string) error {
//return utils.WrappedJsonErrorf(path, "The key %s is a reserved name", key)
}
}
matched, err := regexp.Match(variableNamePattern, []byte(key))
if err != nil {
return burrito.WrappedErrorf("Failed to match the variable name %s: %s", key, err)
}
if !matched {
// For now only warn about reserved names
utils.Logger.Warnf("The key %s at %s is not a valid variable name. Valid names should match ^[a-zA-Z_$][a-zA-Z0-9_$]*$ regex pattern. In the future versions, this will fail the compilation.", key, path)
//return utils.WrappedJsonErrorf(path, "The key %s is not a valid variable name. Valid names should match ^[a-zA-Z_$][a-zA-Z0-9_$]*$ regex pattern.", key)
}
return nil
}

0 comments on commit ca30569

Please sign in to comment.