Skip to content

Commit

Permalink
Fix linters checks
Browse files Browse the repository at this point in the history
Since we already have old-style unittest, leaving it as is till mass
migration to pytest. And ingoring raised by this choice warnings.
  • Loading branch information
Dmitriy Rabotyagov committed May 19, 2021
1 parent b8b427a commit 9c4f9fe
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .flake8
Expand Up @@ -94,6 +94,7 @@ per-file-ignores =
test/TestMetaTagValid.py: PT009 D100 D101 D102
test/TestMetaVideoLinks.py: PT009 D100 D101 D102
test/TestNoFormattingInWhenRule.py: PT009 D100 D101 D102
test/TestNoLogPasswordsRule.py: PT009 D100 D101 D102
test/TestOctalPermissions.py: PT009 D100 D101 D102
test/TestPackageIsNotLatest.py: PT009 D100 D101 D102
test/TestPretaskIncludePlaybook.py: D100 D103
Expand Down
5 changes: 3 additions & 2 deletions examples/playbooks/no-log-passwords-failure.yml
@@ -1,4 +1,5 @@
- tasks:
- hosts: localhost
tasks:
- name: Fail no_log isn't used
user:
name: bidule
Expand All @@ -7,7 +8,7 @@
- name: Fail when no_log is set to False
user:
name: bidule
password: "wow"
user_password: "wow"
state: absent
no_log: False
- name: Fail when no_log is set to no
Expand Down
5 changes: 3 additions & 2 deletions examples/playbooks/no-log-passwords-success.yml
@@ -1,4 +1,5 @@
- tasks:
- hosts: localhost
tasks:
- name: Succeed when no_log is set to yes
user:
name: bidule
Expand All @@ -8,6 +9,6 @@
- name: Succeed when no_log is set to True
user:
name: bidule
password: "wow"
user_password: "wow"
state: absent
no_log: True
4 changes: 3 additions & 1 deletion src/ansiblelint/rules/NoLogPasswordsRule.py
Expand Up @@ -48,4 +48,6 @@ def matchtask(
# No no_log and no_log: False behave the same way
# and should return a failure (return True), so we
# need to invert the boolean
return bool(has_password and not convert_to_boolean(task['action'].get('no_log', False)))
return bool(
has_password and not convert_to_boolean(task.get('no_log', False))
)
3 changes: 2 additions & 1 deletion test/TestNoLogPasswordsRule.py
@@ -1,8 +1,9 @@
# pylint: disable=preferred-module # FIXME: remove once migrated per GH-725
import unittest

from ansiblelint.rules import RulesCollection
from ansiblelint.runner import Runner
from ansiblelint.rules.NoLogPasswordsRule import NoLogPasswordsRule
from ansiblelint.runner import Runner


class TestNoLogPasswordsRule(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/TestRulesCollection.py
Expand Up @@ -128,4 +128,4 @@ def test_rules_id_format() -> None:
assert rule_id_re.match(
rule.id
), f"R rule id {rule.id} did not match our required format."
assert len(rules) == 39
assert len(rules) == 40

0 comments on commit 9c4f9fe

Please sign in to comment.