diff --git a/src/main/java/com/exxeta/iss/sonar/esql/check/AbstractNameCheck.java b/src/main/java/com/exxeta/iss/sonar/esql/check/AbstractNameCheck.java index 3dd91a93..3973421c 100644 --- a/src/main/java/com/exxeta/iss/sonar/esql/check/AbstractNameCheck.java +++ b/src/main/java/com/exxeta/iss/sonar/esql/check/AbstractNameCheck.java @@ -41,13 +41,17 @@ public void init() { public void visitNode(AstNode astNode) { for (AstNode nameNode : astNode.getChildren(EsqlGrammar.NAME)){ String name = nameNode.getTokenOriginalValue(); - if (!pattern.matcher(name).matches()) { + if (!isValidName(name)) { getContext().createLineViolation(this, "Rename {0} \"{1}\" to match the regular expression {2}.", nameNode, typeName(), name, getFormat()); } } } + + protected boolean isValidName(String nameToCheck){ + return pattern.matcher(nameToCheck).matches(); + } public abstract String typeName(); public abstract AstNodeType getType(); diff --git a/src/main/java/com/exxeta/iss/sonar/esql/check/FunctionNameCheck.java b/src/main/java/com/exxeta/iss/sonar/esql/check/FunctionNameCheck.java index 5bd09d72..9dc87e98 100644 --- a/src/main/java/com/exxeta/iss/sonar/esql/check/FunctionNameCheck.java +++ b/src/main/java/com/exxeta/iss/sonar/esql/check/FunctionNameCheck.java @@ -59,5 +59,13 @@ public AstNodeType getType() { } + @Override + protected boolean isValidName(String nameToCheck) { + //Issue 8 + if ("Main".equals(nameToCheck)){ + return true; + } + return super.isValidName(nameToCheck); + } }