Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent output from ansible-review for some rules #84

Open
ansiblejunky opened this issue Sep 13, 2019 · 0 comments
Open

Inconsistent output from ansible-review for some rules #84

ansiblejunky opened this issue Sep 13, 2019 · 0 comments

Comments

@ansiblejunky
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant