diff --git a/docs/rules.rst b/docs/rules.rst index bcf39a93d5..10048f9f82 100644 --- a/docs/rules.rst +++ b/docs/rules.rst @@ -26,26 +26,11 @@ for each available rule, use the ``-T`` option. The following shows the available tags in an example set of rules, and the rules associated with each tag: -.. code-block:: console - $ ansible-lint -v -T - - behaviour ['[503]'] - bug ['[304]'] - command-shell ['[305]', '[302]', '[304]', '[306]', '[301]', '[303]'] - deprecations ['[105]', '[104]', '[103]', '[101]', '[102]'] - experimental ['[208]'] - formatting ['[104]', '[203]', '[201]', '[204]', '[206]', '[205]', '[202]'] - idempotency ['[301]'] - idiom ['[601]', '[602]'] - metadata ['[701]', '[704]', '[703]', '[702]'] - module ['[404]', '[401]', '[403]', '[402]'] - oddity ['[501]'] - readability ['[502]'] - repeatability ['[401]', '[403]', '[402]'] - resources ['[302]', '[303]'] - safety ['[305]'] - task ['[502]', '[503]', '[504]', '[501]'] +.. command-output:: ansible-lint -v -T + :cwd: .. + :returncode: 0 + :nostderr: To run just the *idempotency* rules, for example, run the following: @@ -56,20 +41,13 @@ To run just the *idempotency* rules, for example, run the following: Excluding Rules ``````````````` -To exclude rules from the available set of rules, use the ``-x SKIP_LIST`` +To exclude rules using their identificators or tags, use the ``-x SKIP_LIST`` option. For example, the following runs all of the rules except those with the -tags *readability* and *safety*: - -.. code-block:: bash - - $ ansible-lint -x readability,safety playbook.yml - -It's also possible to skip specific rules by passing the rule ID. For example, -the following excludes rule *502*: +tags *formatting* and *metadata*: .. code-block:: bash - $ ansible-lint -x 502 playbook.yml + $ ansible-lint -x formatting,metadata playbook.yml Ignoring Rules `````````````` diff --git a/src/ansiblelint/_internal/rules.py b/src/ansiblelint/_internal/rules.py index f3e7294b15..9bc1e256eb 100644 --- a/src/ansiblelint/_internal/rules.py +++ b/src/ansiblelint/_internal/rules.py @@ -71,7 +71,7 @@ def __lt__(self, other: "BaseRule") -> bool: class RuntimeErrorRule(BaseRule): """Used to identify errors.""" - id = '999' + id = 'internal-error' shortdesc = 'Unexpected internal error' description = ( 'This error can be caused by internal bugs but also by ' @@ -86,7 +86,7 @@ class RuntimeErrorRule(BaseRule): class AnsibleParserErrorRule(BaseRule): """Used to mark errors received from Ansible.""" - id = '998' + id = 'parser-error' shortdesc = 'AnsibleParserError' description = ( 'Ansible parser fails, this usually indicate invalid file.') @@ -98,7 +98,7 @@ class AnsibleParserErrorRule(BaseRule): class LoadingFailureRule(BaseRule): """File loading failure.""" - id = '901' + id = 'load-failure' shortdesc = 'Failed to load or parse file' description = 'Linter failed to process a YAML file, possible not an Ansible file.' severity = 'VERY_HIGH' diff --git a/src/ansiblelint/generate_docs.py b/src/ansiblelint/generate_docs.py index 7a022d85e6..a9af1d3582 100644 --- a/src/ansiblelint/generate_docs.py +++ b/src/ansiblelint/generate_docs.py @@ -30,26 +30,14 @@ def rules_as_rst(rules: RulesCollection) -> str: r = DOC_HEADER for d in rules: - if not hasattr(d, 'id'): - _logger.warning( - "Rule %s skipped from being documented as it does not have an `id` attribute.", - d.__class__.__name__) - continue - if d.id.endswith('01'): - - section = '{} Rules ({}xx)'.format( - d.tags[0].title(), - d.id[-3:-2]) - r += f'\n\n{section}\n{ "-" * len(section) }' - - title = f"{d.id}: {d.shortdesc}" + title = f"{d.id}" description = d.description if d.link: description += " `(more) <%s>`_" % d.link - r += f"\n\n.. _{d.id}:\n\n{title}\n{'*' * len(title)}\n\n{description}" + r += f"\n\n.. _{d.id}:\n\n{title}\n{'*' * len(title)}\n\n{d.shortdesc}\n\n{description}" return r diff --git a/src/ansiblelint/rules/AnsibleSyntaxCheckRule.py b/src/ansiblelint/rules/AnsibleSyntaxCheckRule.py index 6e55c7e587..ad3766a096 100644 --- a/src/ansiblelint/rules/AnsibleSyntaxCheckRule.py +++ b/src/ansiblelint/rules/AnsibleSyntaxCheckRule.py @@ -24,7 +24,7 @@ class AnsibleSyntaxCheckRule(AnsibleLintRule): """Ansible syntax check report failure.""" - id = "911" + id = "syntax-check" shortdesc = "Ansible syntax check failed" description = "Running ansible-playbook --syntax-check ... reported an error." severity = "VERY_HIGH" diff --git a/src/ansiblelint/rules/BecomeUserWithoutBecomeRule.py b/src/ansiblelint/rules/BecomeUserWithoutBecomeRule.py index 15b32d5135..cf32541d31 100644 --- a/src/ansiblelint/rules/BecomeUserWithoutBecomeRule.py +++ b/src/ansiblelint/rules/BecomeUserWithoutBecomeRule.py @@ -74,11 +74,11 @@ def _become_user_without_become(becomeuserabove: bool, data: "odict[str, Any]") class BecomeUserWithoutBecomeRule(AnsibleLintRule): - id = '501' + id = 'partial-become' shortdesc = 'become_user requires become to work as expected' description = '``become_user`` without ``become`` will not actually change user' severity = 'VERY_HIGH' - tags = ['task', 'unpredictability'] + tags = ['unpredictability'] version_added = 'historic' def matchplay(self, file: "Lintable", data: "odict[str, Any]") -> List["MatchError"]: diff --git a/src/ansiblelint/rules/CommandHasChangesCheckRule.py b/src/ansiblelint/rules/CommandHasChangesCheckRule.py index 83ac6d71bc..1677a830f3 100644 --- a/src/ansiblelint/rules/CommandHasChangesCheckRule.py +++ b/src/ansiblelint/rules/CommandHasChangesCheckRule.py @@ -24,7 +24,7 @@ class CommandHasChangesCheckRule(AnsibleLintRule): - id = '301' + id = 'no-changed-when' shortdesc = 'Commands should not change things if nothing needs doing' description = ( 'Commands should either read information (and thus set ' diff --git a/src/ansiblelint/rules/CommandsInsteadOfArgumentsRule.py b/src/ansiblelint/rules/CommandsInsteadOfArgumentsRule.py index c77966e361..26da570aa8 100644 --- a/src/ansiblelint/rules/CommandsInsteadOfArgumentsRule.py +++ b/src/ansiblelint/rules/CommandsInsteadOfArgumentsRule.py @@ -26,14 +26,14 @@ class CommandsInsteadOfArgumentsRule(AnsibleLintRule): - id = '302' + id = 'deprecated-command-syntax' shortdesc = 'Using command rather than an argument to e.g. file' description = ( 'Executing a command when there are arguments to modules ' 'is generally a bad idea' ) severity = 'VERY_HIGH' - tags = ['command-shell', 'resources'] + tags = ['command-shell', 'deprecations'] version_added = 'historic' _commands = ['command', 'shell', 'raw'] diff --git a/src/ansiblelint/rules/CommandsInsteadOfModulesRule.py b/src/ansiblelint/rules/CommandsInsteadOfModulesRule.py index 721ed7d88f..cc7e64153d 100644 --- a/src/ansiblelint/rules/CommandsInsteadOfModulesRule.py +++ b/src/ansiblelint/rules/CommandsInsteadOfModulesRule.py @@ -26,14 +26,14 @@ class CommandsInsteadOfModulesRule(AnsibleLintRule): - id = '303' + id = 'command-instead-of-module' shortdesc = 'Using command rather than module' description = ( 'Executing a command when there is an Ansible module ' 'is generally a bad idea' ) severity = 'HIGH' - tags = ['command-shell', 'resources'] + tags = ['command-shell', 'idiom'] version_added = 'historic' _commands = ['command', 'shell'] diff --git a/src/ansiblelint/rules/ComparisonToEmptyStringRule.py b/src/ansiblelint/rules/ComparisonToEmptyStringRule.py index df27c0132b..1b6faa9759 100644 --- a/src/ansiblelint/rules/ComparisonToEmptyStringRule.py +++ b/src/ansiblelint/rules/ComparisonToEmptyStringRule.py @@ -8,7 +8,7 @@ class ComparisonToEmptyStringRule(AnsibleLintRule): - id = '602' + id = 'empty-string-compare' shortdesc = "Don't compare to empty string" description = ( 'Use ``when: var|length > 0`` rather than ``when: var != ""`` (or ' diff --git a/src/ansiblelint/rules/ComparisonToLiteralBoolRule.py b/src/ansiblelint/rules/ComparisonToLiteralBoolRule.py index e34125bc9b..4b574d064c 100644 --- a/src/ansiblelint/rules/ComparisonToLiteralBoolRule.py +++ b/src/ansiblelint/rules/ComparisonToLiteralBoolRule.py @@ -7,7 +7,7 @@ class ComparisonToLiteralBoolRule(AnsibleLintRule): - id = '601' + id = 'literal-compare' shortdesc = "Don't compare to literal True/False" description = ( 'Use ``when: var`` rather than ``when: var == True`` ' diff --git a/src/ansiblelint/rules/DeprecatedModuleRule.py b/src/ansiblelint/rules/DeprecatedModuleRule.py index 8225ffbd0e..701be85f42 100644 --- a/src/ansiblelint/rules/DeprecatedModuleRule.py +++ b/src/ansiblelint/rules/DeprecatedModuleRule.py @@ -6,7 +6,7 @@ class DeprecatedModuleRule(AnsibleLintRule): - id = '105' + id = 'deprecated-module' shortdesc = 'Deprecated module' description = ( 'These are deprecated modules, some modules are kept ' diff --git a/src/ansiblelint/rules/EnvVarsInCommandRule.py b/src/ansiblelint/rules/EnvVarsInCommandRule.py index bad9f2207b..36d14ec56f 100644 --- a/src/ansiblelint/rules/EnvVarsInCommandRule.py +++ b/src/ansiblelint/rules/EnvVarsInCommandRule.py @@ -25,14 +25,14 @@ class EnvVarsInCommandRule(AnsibleLintRule): - id = '304' + id = 'inline-env-var' shortdesc = "Command module does not accept setting environment variables inline" description = ( 'Use ``environment:`` to set environment variables ' 'or use ``shell`` module which accepts both' ) severity = 'VERY_HIGH' - tags = ['command-shell', 'bug'] + tags = ['command-shell', 'idiom'] version_added = 'historic' expected_args = ['chdir', 'creates', 'executable', 'removes', 'stdin', 'warn', diff --git a/src/ansiblelint/rules/GitHasVersionRule.py b/src/ansiblelint/rules/GitHasVersionRule.py index e4102fad73..94ff7a3665 100644 --- a/src/ansiblelint/rules/GitHasVersionRule.py +++ b/src/ansiblelint/rules/GitHasVersionRule.py @@ -24,14 +24,14 @@ class GitHasVersionRule(AnsibleLintRule): - id = '401' + id = 'git-latest' shortdesc = 'Git checkouts must contain explicit version' description = ( 'All version control checkouts must point to ' 'an explicit commit or tag, not just ``latest``' ) severity = 'MEDIUM' - tags = ['module', 'repeatability'] + tags = ['idempotency'] version_added = 'historic' def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: diff --git a/src/ansiblelint/rules/IncludeMissingFileRule.py b/src/ansiblelint/rules/IncludeMissingFileRule.py index 9042cbd07c..b7e13e82a9 100644 --- a/src/ansiblelint/rules/IncludeMissingFileRule.py +++ b/src/ansiblelint/rules/IncludeMissingFileRule.py @@ -17,15 +17,15 @@ class IncludeMissingFileRule(AnsibleLintRule): - id = '505' + id = 'missing-import' shortdesc = 'referenced files must exist' description = ( - 'All files referenced by by include / import tasks ' + 'All files referenced by include / import tasks ' 'must exist. The check excludes files with jinja2 ' 'templates in the filename.' ) severity = 'MEDIUM' - tags = ['task', 'bug'] + tags = ['idiom'] version_added = 'v4.3.0' def matchplay(self, file: "Lintable", data: "odict[str, Any]") -> List["MatchError"]: diff --git a/src/ansiblelint/rules/MercurialHasRevisionRule.py b/src/ansiblelint/rules/MercurialHasRevisionRule.py index a0ef8ff84b..d2d69f849a 100644 --- a/src/ansiblelint/rules/MercurialHasRevisionRule.py +++ b/src/ansiblelint/rules/MercurialHasRevisionRule.py @@ -24,14 +24,14 @@ class MercurialHasRevisionRule(AnsibleLintRule): - id = '402' + id = 'hg-latest' shortdesc = 'Mercurial checkouts must contain explicit revision' description = ( 'All version control checkouts must point to ' 'an explicit commit or tag, not just ``latest``' ) severity = 'MEDIUM' - tags = ['module', 'repeatability'] + tags = ['idempotency'] version_added = 'historic' def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: diff --git a/src/ansiblelint/rules/MetaChangeFromDefaultRule.py b/src/ansiblelint/rules/MetaChangeFromDefaultRule.py index 37e979adfd..40caa639e9 100644 --- a/src/ansiblelint/rules/MetaChangeFromDefaultRule.py +++ b/src/ansiblelint/rules/MetaChangeFromDefaultRule.py @@ -13,7 +13,7 @@ class MetaChangeFromDefaultRule(AnsibleLintRule): - id = '703' + id = 'meta-incorrect' shortdesc = 'meta/main.yml default values should be changed' field_defaults = [ ('author', 'your name'), diff --git a/src/ansiblelint/rules/MetaMainHasInfoRule.py b/src/ansiblelint/rules/MetaMainHasInfoRule.py index 70c00a4e3e..3271372306 100644 --- a/src/ansiblelint/rules/MetaMainHasInfoRule.py +++ b/src/ansiblelint/rules/MetaMainHasInfoRule.py @@ -52,7 +52,7 @@ def _galaxy_info_errors_itr( class MetaMainHasInfoRule(AnsibleLintRule): - id = '701' + id = 'meta-no-info' shortdesc = 'meta/main.yml should contain relevant info' str_info = META_STR_INFO info = META_INFO diff --git a/src/ansiblelint/rules/MetaTagValidRule.py b/src/ansiblelint/rules/MetaTagValidRule.py index f79391559f..8fe731f703 100644 --- a/src/ansiblelint/rules/MetaTagValidRule.py +++ b/src/ansiblelint/rules/MetaTagValidRule.py @@ -15,7 +15,7 @@ class MetaTagValidRule(AnsibleLintRule): - id = '702' + id = 'meta-no-tags' shortdesc = 'Tags must contain lowercase letters and digits only' description = ( 'Tags must contain lowercase letters and digits only, ' diff --git a/src/ansiblelint/rules/MetaVideoLinksRule.py b/src/ansiblelint/rules/MetaVideoLinksRule.py index 16daae01ee..a783424a95 100644 --- a/src/ansiblelint/rules/MetaVideoLinksRule.py +++ b/src/ansiblelint/rules/MetaVideoLinksRule.py @@ -14,7 +14,7 @@ class MetaVideoLinksRule(AnsibleLintRule): - id = '704' + id = 'meta-video-links' shortdesc = "meta/main.yml video_links should be formatted correctly" description = ( 'Items in ``video_links`` in meta/main.yml should be ' diff --git a/src/ansiblelint/rules/MissingFilePermissionsRule.py b/src/ansiblelint/rules/MissingFilePermissionsRule.py index 1cca5ca397..1aae5d2753 100644 --- a/src/ansiblelint/rules/MissingFilePermissionsRule.py +++ b/src/ansiblelint/rules/MissingFilePermissionsRule.py @@ -29,7 +29,7 @@ class MissingFilePermissionsRule(AnsibleLintRule): - id = "208" + id = "risky-file-permisions" shortdesc = 'File permissions unset or incorrect' description = ( "Missing or unsupported mode parameter can cause unexpected file " diff --git a/src/ansiblelint/rules/NestedJinjaRule.py b/src/ansiblelint/rules/NestedJinjaRule.py index 64dadbbb66..73792ae00e 100644 --- a/src/ansiblelint/rules/NestedJinjaRule.py +++ b/src/ansiblelint/rules/NestedJinjaRule.py @@ -28,7 +28,7 @@ class NestedJinjaRule(AnsibleLintRule): - id = '207' + id = 'no-jinja-nesting' shortdesc = 'Nested jinja pattern' description = ( "There should not be any nested jinja pattern. " diff --git a/src/ansiblelint/rules/NoFormattingInWhenRule.py b/src/ansiblelint/rules/NoFormattingInWhenRule.py index c684c834e2..eb3e978030 100644 --- a/src/ansiblelint/rules/NoFormattingInWhenRule.py +++ b/src/ansiblelint/rules/NoFormattingInWhenRule.py @@ -9,7 +9,7 @@ class NoFormattingInWhenRule(AnsibleLintRule): - id = '102' + id = 'no-jinja-when' shortdesc = 'No Jinja2 in when' description = '``when`` is a raw Jinja2 expression, remove redundant {{ }} from variable(s).' severity = 'HIGH' diff --git a/src/ansiblelint/rules/NoTabsRule.py b/src/ansiblelint/rules/NoTabsRule.py index c576cea997..a44fc142a9 100644 --- a/src/ansiblelint/rules/NoTabsRule.py +++ b/src/ansiblelint/rules/NoTabsRule.py @@ -7,7 +7,7 @@ class NoTabsRule(AnsibleLintRule): - id = '203' + id = 'no-tabs' shortdesc = 'Most files should not contain tabs' description = 'Tabs can cause unexpected display issues, use spaces' severity = 'LOW' diff --git a/src/ansiblelint/rules/OctalPermissionsRule.py b/src/ansiblelint/rules/OctalPermissionsRule.py index 6ad7fd37b7..b514dc213d 100644 --- a/src/ansiblelint/rules/OctalPermissionsRule.py +++ b/src/ansiblelint/rules/OctalPermissionsRule.py @@ -24,7 +24,7 @@ class OctalPermissionsRule(AnsibleLintRule): - id = '202' + id = 'risky-octal' shortdesc = 'Octal file permissions must contain leading zero or be a string' description = ( 'Numeric file permissions without leading zero can behave ' diff --git a/src/ansiblelint/rules/PackageIsNotLatestRule.py b/src/ansiblelint/rules/PackageIsNotLatestRule.py index 18a902b537..ddf61c14c2 100644 --- a/src/ansiblelint/rules/PackageIsNotLatestRule.py +++ b/src/ansiblelint/rules/PackageIsNotLatestRule.py @@ -24,14 +24,14 @@ class PackageIsNotLatestRule(AnsibleLintRule): - id = '403' + id = 'package-latest' shortdesc = 'Package installs should not use latest' description = ( 'Package installs should use ``state=present`` ' 'with or without a version' ) severity = 'VERY_LOW' - tags = ['module', 'repeatability'] + tags = ['idempotency'] version_added = 'historic' _package_managers = [ diff --git a/src/ansiblelint/rules/PlaybookExtension.py b/src/ansiblelint/rules/PlaybookExtension.py index 5996ad6cac..a49376377b 100644 --- a/src/ansiblelint/rules/PlaybookExtension.py +++ b/src/ansiblelint/rules/PlaybookExtension.py @@ -10,7 +10,7 @@ class PlaybookExtension(AnsibleLintRule): - id = '205' + id = 'playbook-extension' shortdesc = 'Use ".yml" or ".yaml" playbook extension' description = 'Playbooks should have the ".yml" or ".yaml" extension' severity = 'MEDIUM' diff --git a/src/ansiblelint/rules/RoleLoopVarPrefix.py b/src/ansiblelint/rules/RoleLoopVarPrefix.py index 1905dc9608..ac2ca3576d 100644 --- a/src/ansiblelint/rules/RoleLoopVarPrefix.py +++ b/src/ansiblelint/rules/RoleLoopVarPrefix.py @@ -25,7 +25,7 @@ class RoleLoopVarPrefix(AnsibleLintRule): Looping inside roles has the risk of clashing with loops from user-playbooks.\ """ - tags = ['no-loop-var-prefix', 'safety'] + tags = ['idiom'] prefix = "" severity = 'MEDIUM' diff --git a/src/ansiblelint/rules/RoleNames.py b/src/ansiblelint/rules/RoleNames.py index eeae96819b..71a0c6c236 100644 --- a/src/ansiblelint/rules/RoleNames.py +++ b/src/ansiblelint/rules/RoleNames.py @@ -39,7 +39,7 @@ def _remove_prefix(text: str, prefix: str) -> str: class RoleNames(AnsibleLintRule): - id = '106' + id = 'role-name' shortdesc = ( "Role name {0} does not match ``%s`` pattern" % ROLE_NAME_REGEX ) diff --git a/src/ansiblelint/rules/RoleRelativePath.py b/src/ansiblelint/rules/RoleRelativePath.py index 7a5c5793ac..06f58328f2 100644 --- a/src/ansiblelint/rules/RoleRelativePath.py +++ b/src/ansiblelint/rules/RoleRelativePath.py @@ -7,11 +7,11 @@ class RoleRelativePath(AnsibleLintRule): - id = '404' + id = 'no-relative-paths' shortdesc = "Doesn't need a relative path in role" description = '``copy`` and ``template`` do not need to use relative path for ``src``' severity = 'HIGH' - tags = ['module'] + tags = ['idiom'] version_added = 'v4.0.0' _module_to_path_folder = { diff --git a/src/ansiblelint/rules/ShellWithoutPipefail.py b/src/ansiblelint/rules/ShellWithoutPipefail.py index 373b4c081c..801f9a2d63 100644 --- a/src/ansiblelint/rules/ShellWithoutPipefail.py +++ b/src/ansiblelint/rules/ShellWithoutPipefail.py @@ -5,7 +5,7 @@ class ShellWithoutPipefail(AnsibleLintRule): - id = '306' + id = 'risky-shell-pipe' shortdesc = 'Shells that use pipes should set the pipefail option' description = ( 'Without the pipefail option set, a shell command that ' diff --git a/src/ansiblelint/rules/TaskHasNameRule.py b/src/ansiblelint/rules/TaskHasNameRule.py index f4ee1bbdea..5f1ebc772e 100644 --- a/src/ansiblelint/rules/TaskHasNameRule.py +++ b/src/ansiblelint/rules/TaskHasNameRule.py @@ -24,14 +24,14 @@ class TaskHasNameRule(AnsibleLintRule): - id = '502' + id = 'unamed-task' shortdesc = 'All tasks should be named' description = ( 'All tasks should have a distinct name for readability ' 'and for ``--start-at-task`` to work' ) severity = 'MEDIUM' - tags = ['task', 'readability'] + tags = ['idiom'] version_added = 'historic' _nameless_tasks = ['meta', 'debug', 'include_role', 'import_role', diff --git a/src/ansiblelint/rules/TaskNoLocalAction.py b/src/ansiblelint/rules/TaskNoLocalAction.py index 96b9e279fe..04afaa13ad 100644 --- a/src/ansiblelint/rules/TaskNoLocalAction.py +++ b/src/ansiblelint/rules/TaskNoLocalAction.py @@ -5,11 +5,11 @@ class TaskNoLocalAction(AnsibleLintRule): - id = '504' + id = 'deprecated-local-action' shortdesc = "Do not use 'local_action', use 'delegate_to: localhost'" description = 'Do not use ``local_action``, use ``delegate_to: localhost``' severity = 'MEDIUM' - tags = ['task'] + tags = ['deprecations'] version_added = 'v4.0.0' def match(self, line: str) -> bool: diff --git a/src/ansiblelint/rules/UseCommandInsteadOfShellRule.py b/src/ansiblelint/rules/UseCommandInsteadOfShellRule.py index f22a3e15bb..221fa58a67 100644 --- a/src/ansiblelint/rules/UseCommandInsteadOfShellRule.py +++ b/src/ansiblelint/rules/UseCommandInsteadOfShellRule.py @@ -24,7 +24,7 @@ class UseCommandInsteadOfShellRule(AnsibleLintRule): - id = '305' + id = 'command-instead-of-shell' shortdesc = 'Use shell only when shell functionality is required' description = ( 'Shell should only be used when piping, redirecting ' @@ -32,7 +32,7 @@ class UseCommandInsteadOfShellRule(AnsibleLintRule): 'for some of those!)' ) severity = 'HIGH' - tags = ['command-shell', 'safety'] + tags = ['command-shell', 'idiom'] version_added = 'historic' def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: diff --git a/src/ansiblelint/rules/UseHandlerRatherThanWhenChangedRule.py b/src/ansiblelint/rules/UseHandlerRatherThanWhenChangedRule.py index 44bd9e4279..b34fdf93f9 100644 --- a/src/ansiblelint/rules/UseHandlerRatherThanWhenChangedRule.py +++ b/src/ansiblelint/rules/UseHandlerRatherThanWhenChangedRule.py @@ -31,14 +31,14 @@ def _changed_in_when(item: str) -> bool: class UseHandlerRatherThanWhenChangedRule(AnsibleLintRule): - id = '503' + id = 'no-handler' shortdesc = 'Tasks that run when changed should likely be handlers' description = ( 'If a task has a ``when: result.changed`` setting, it is effectively ' 'acting as a handler' ) severity = 'MEDIUM' - tags = ['task', 'behaviour'] + tags = ['idiom'] version_added = 'historic' def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: diff --git a/src/ansiblelint/rules/UsingBareVariablesIsDeprecatedRule.py b/src/ansiblelint/rules/UsingBareVariablesIsDeprecatedRule.py index 12110c7021..06f108643c 100644 --- a/src/ansiblelint/rules/UsingBareVariablesIsDeprecatedRule.py +++ b/src/ansiblelint/rules/UsingBareVariablesIsDeprecatedRule.py @@ -26,7 +26,7 @@ class UsingBareVariablesIsDeprecatedRule(AnsibleLintRule): - id = '104' + id = 'deprecated-bare-vars' shortdesc = 'Using bare variables is deprecated' description = ( 'Using bare variables is deprecated. Update your ' @@ -34,7 +34,7 @@ class UsingBareVariablesIsDeprecatedRule(AnsibleLintRule): 'syntax ``{{ your_variable }}``' ) severity = 'VERY_HIGH' - tags = ['deprecations', 'formatting'] + tags = ['deprecations'] version_added = 'historic' _jinja = re.compile(r"{{.*}}", re.DOTALL) diff --git a/src/ansiblelint/rules/VariableHasSpacesRule.py b/src/ansiblelint/rules/VariableHasSpacesRule.py index 1f15da0740..a822d5109c 100644 --- a/src/ansiblelint/rules/VariableHasSpacesRule.py +++ b/src/ansiblelint/rules/VariableHasSpacesRule.py @@ -10,7 +10,7 @@ class VariableHasSpacesRule(AnsibleLintRule): - id = '206' + id = 'var-spacing' base_msg = 'Variables should have spaces before and after: ' shortdesc = base_msg + ' {{ var_name }}' description = 'Variables should have spaces before and after: ``{{ var_name }}``' diff --git a/src/ansiblelint/rules/YamllintRule.py b/src/ansiblelint/rules/YamllintRule.py index 0d076d5fa8..76bc987bd8 100644 --- a/src/ansiblelint/rules/YamllintRule.py +++ b/src/ansiblelint/rules/YamllintRule.py @@ -42,11 +42,11 @@ class YamllintRule(AnsibleLintRule): - id = 'YAML' + id = 'yaml' shortdesc = 'Violations reported by yamllint' description = DESCRIPTION severity = 'VERY_LOW' - tags = ['formatting', 'experimental', 'yamllint'] + tags = ['formatting', 'yaml'] version_added = 'v5.0.0' config = None if "yamllint.config" in sys.modules: diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index b3b309f41f..a0c45fa470 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -251,7 +251,6 @@ def __repr__(self) -> str: def listtags(self) -> str: tag_desc = { "behaviour": "Indicates a bad practice or behavior", - "bug": "Likely wrong usage pattern", "command-shell": "Specific to use of command and shell modules", "core": "Related to internal implementation of the linter", "deprecations": "Indicate use of features that are removed from Ansible", @@ -261,25 +260,21 @@ def listtags(self) -> str: "Possible indication that consequent runs would produce different results", "idiom": "Anti-pattern detected, likely to cause undesired behavior", "metadata": "Invalid metadata, likely related to galaxy, collections or roles", - "module": "Incorrect module usage", - "readability": "Reduce code readability", - "repeatability": "Action that may produce different result between runs", - "resources": "Unoptimal feature use", - "safety": "Increase security risk", - "task": "Rules specific to tasks", - "unpredictability": "This will produce unexpected behavior when run", + "yaml": "External linter which will also produce its own rule codes." } tags = defaultdict(list) for rule in self.rules: for tag in rule.tags: tags[tag].append(rule.id) - result = "# List of tags and how they are used\n" + result = "# List of tags and rules they cover\n" for tag in sorted(tags): desc = tag_desc.get(tag, None) if desc: result += f"{tag}: # {desc}\n" else: result += f"{tag}:\n" - result += f" rules: [{', '.join(tags[tag])}]\n" + # result += f" rules:\n" + for id in tags[tag]: + result += f" - {id}\n" return result