diff --git a/bundle/regal/main.rego b/bundle/regal/main.rego index e92e206b..3d56e078 100644 --- a/bundle/regal/main.rego +++ b/bundle/regal/main.rego @@ -156,12 +156,10 @@ ignore_directives[row] := rules if { some comment in ast.comments_decoded text := trim_space(comment.Text) - startswith(text, "regal") - - i := indexof(text, "ignore:") + i := indexof(text, "regal ignore:") i != -1 - list := regex.replace(substring(text, i + 7, -1), `\s`, "") + list := regex.replace(substring(text, i + 13, -1), `\s`, "") row := comment.Location.row + 1 rules := split(list, ",") diff --git a/bundle/regal/main_test.rego b/bundle/regal/main_test.rego index c0339015..f80c7d82 100644 --- a/bundle/regal/main_test.rego +++ b/bundle/regal/main_test.rego @@ -82,6 +82,28 @@ test_main_ignore_directive_success_same_line if { count(report) == 0 } +test_main_ignore_directive_success_same_line_trailing_directive if { + policy := `package p + + camelCase := "yes" # camelCase is nice! # regal ignore:prefer-snake-case + ` + report := main.report with input as regal.parse_module("p.rego", policy) + with config.merged_config as {"rules": {"style": {"prefer-snake-case": {"level": "error"}}}} + + count(report) == 0 +} + +test_main_ignore_directive_success_same_line_todo_comment if { + policy := `package p + + camelCase := "yes" # TODO! camelCase isn't nice! # regal ignore:todo-comment + ` + report := main.report with input as regal.parse_module("p.rego", policy) + with config.merged_config as {"rules": {"style": {"todo-comment": {"level": "error"}}}} + + count(report) == 0 +} + test_main_ignore_directive_multiple_success if { policy := `package p diff --git a/bundle/regal/rules/style/todo_comment.rego b/bundle/regal/rules/style/todo_comment.rego index 3bd08d7d..53bab13a 100644 --- a/bundle/regal/rules/style/todo_comment.rego +++ b/bundle/regal/rules/style/todo_comment.rego @@ -7,7 +7,7 @@ import rego.v1 import data.regal.ast import data.regal.result -# For comments, OPA uses capital-cases Text and Location rather +# For comments, OPA uses capital-cased Text and Location rather # than text and location. As fixing this would potentially break # things, we need to take it into consideration here.