Skip to content

Commit

Permalink
Made empty-string-compare rule opt-in (#1953)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Mar 5, 2022
1 parent 1440ed1 commit 3032f5e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ skip_list:
# Any rule that has the 'opt-in' tag will not be loaded unless its 'id' is
# mentioned in the enable_list:
enable_list:
- empty-string-compare # opt-in
- no-log-password # opt-in
- no-same-owner # opt-in
# add yaml here if you want to avoid ignoring yaml checks when yamllint
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/ComparisonToEmptyStringRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ComparisonToEmptyStringRule(AnsibleLintRule):
'conversely ``when: var|length == 0`` rather than ``when: var == ""``)'
)
severity = "HIGH"
tags = ["idiom"]
tags = ["idiom", "opt-in"]
version_added = "v4.0.0"

empty_string_compare = re.compile("[=!]= ?(\"{2}|'{2})")
Expand Down
2 changes: 1 addition & 1 deletion test/TestRulesCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ def test_rules_id_format() -> None:
assert rule_id_re.match(
rule.id
), f"Rule id {rule.id} did not match our required format."
assert len(rules) == 41
assert len(rules) == 40

0 comments on commit 3032f5e

Please sign in to comment.