Skip to content

Commit

Permalink
SONARHTML-139 Should not raise issue on comments annotated with @elVa…
Browse files Browse the repository at this point in the history
…riable or @thymesVar (#221)
  • Loading branch information
thomas-serre-sonarsource committed Nov 23, 2022
1 parent 8695a22 commit 54ab508
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -19,6 +19,7 @@

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.sonar.check.Rule;
import org.sonar.plugins.html.checks.AbstractPageCheck;
Expand All @@ -40,6 +41,8 @@ public class AvoidCommentedOutCodeCheck extends AbstractPageCheck {

private static final CodeRecognizer CODE_RECOGNIZER = new CodeRecognizer(THRESHOLD, LANGUAGE_FOOTPRINT);

private static final List<String> IGNORED_COMMENT_ANNOTATIONS = Arrays.asList("@thymesVar", "@elvariable");

@Override
public void comment(CommentNode node) {
if (node.isHtml()) {
Expand All @@ -56,7 +59,9 @@ private static boolean isIgnored(String comment) {
// Conditional comments
|| comment.startsWith("<!--[if")
// Server Side Includes
|| comment.startsWith("<!--#");
|| comment.startsWith("<!--#")
// Annotated comments
|| IGNORED_COMMENT_ANNOTATIONS.stream().anyMatch(comment::contains);
}

}
Expand Up @@ -55,3 +55,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<!--/* @thymesVar id="users" type="java.util.List<my.namespace.User>" */-->

<!--@elvariable id="id" type="java.lang.String"-->

0 comments on commit 54ab508

Please sign in to comment.