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

Make profile information on summary line more clear #3545

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/ansiblelint/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def report_outcome(
return RC.SUCCESS
return RC.VIOLATIONS_FOUND

def report_summary( # pylint: disable=too-many-locals
def report_summary( # pylint: disable=too-many-locals # noqa: C901
self,
summary: SummarizedResults,
changed_files_count: int,
Expand Down Expand Up @@ -311,26 +311,31 @@ def report_summary( # pylint: disable=too-many-locals
# rate stars for the top 5 profiles (min would not get
rating = 5 - (len(PROFILES.keys()) - passed_profile_count)
if 0 < rating < 6:
stars = f", {rating}/5 star rating"
stars = f" Rating: {rating}/5 star"

console_stderr.print(table)
console_stderr.print()

if is_success:
msg = "[green]Passed[/] with "
else:
msg = "[red][bold]Failed[/][/] after "

if summary.passed_profile:
msg += f"[bold]{summary.passed_profile}[/] profile"
if stars:
msg += stars
msg = "[green]Passed[/]" if is_success else "[red][bold]Failed[/][/]"

msg += f": {summary.failures} failure(s), {summary.warnings} warning(s)"
if summary.fixed:
msg += f", and fixed {summary.fixed} issue(s)"
msg += f" on {files_count} files."

# Now we add some information about required and passed profile
if self.options.profile:
msg += f" Profile '{self.options.profile}' was required"
if summary.passed_profile:
msg += f", but only '{summary.passed_profile}' profile passed."
else:
msg += "."
elif summary.passed_profile:
msg += f" Last profile that met the validation criteria was '{summary.passed_profile}'."

if stars:
msg += stars

# on offline mode and when run under pre-commit we do not want to
# check for updates.
if not self.options.offline and os.environ.get("PRE_COMMIT", "0") != "1":
Expand Down