Skip to content

Inconsistent output from ansible-review for some rules #84

Description

@ansiblejunky

The output from ansible-review shows some inconsistent formatting. For example, some internal WARN messages are shown without a rule number reference. I believe all WARN and ERROR messages should produce the same formatted output and contain:

  • tag (WARN or ERROR)
  • description
  • unique rule number (for reference purposes)
  • line number
  • specific info (e.g... variable X is declared twice)

Most of the lint rules follow this concept. Here are some internal rules that do not.

From init.py. Two warnings are raised in this code but again they should follow the same output requirements as described above:

    if not candidate.version:
        candidate.version = standards_latest(standards.standards)
        if candidate.expected_version:
            if isinstance(candidate, ansiblereview.RoleFile):
                warn("%s %s is in a role that contains a meta/main.yml without a declared "
                     "standards version. "
                     "Using latest standards version %s" %
                     (type(candidate).__name__, candidate.path, candidate.version),
                     settings)
            else:
                warn("%s %s does not present standards version. "
                     "Using latest standards version %s" %
                     (type(candidate).__name__, candidate.path, candidate.version),
                     settings)

They produce messages like this:

WARN: RoleVars vars/main.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1
WARN: Task tasks/main.yml is in a role that contains a meta/main.yml without a declared standards version. Using latest standards version 0.1

Also, another example is the following rule that checks YAML indentation. Here is the rule output:

WARN: Best practice "YAML should be correctly indented" not met:
vars/main.yml:4: indentation should increase by 2 chars

However, there is no rule number in the output.

Recommended changes:

  • modify the internal warn() and error() functions so that you can provide all of this info when these are raised internally.
  • modify the lint rules to include the right info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions