-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds summary stats about found violations
Fixes: #2110
- Loading branch information
Showing
5 changed files
with
129 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
- hosts: localhost | ||
- name: Example | ||
hosts: localhost | ||
tasks: | ||
- shell: | ||
cmd: | | ||
if [ $FOO != false ]; then | ||
- name: Play name | ||
debug: | ||
msg: "Hello {{ ansible_facts.env | list }}!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Module hosting functionality about reporting.""" | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
|
||
|
||
@dataclass(order=True) | ||
class TagStats: | ||
"""Tag statistics.""" | ||
|
||
order: int = 0 # to be computed based on rule's profile | ||
tag: str = "" # rule effective id (can be multiple tags per rule id) | ||
count: int = 0 # total number of occurrences | ||
warning: bool = False # set true if listed in warn_list | ||
profile: str = "" | ||
associated_tags: list[str] = field(default_factory=list) | ||
|
||
|
||
class SummarizedResults: | ||
"""The statistics about an ansible-lint run.""" | ||
|
||
failures: int = 0 | ||
warnings: int = 0 | ||
fixed_failures: int = 0 | ||
fixed_warnings: int = 0 | ||
tag_stats: dict[str, TagStats] = {} | ||
passed_profile: str = "" | ||
|
||
@property | ||
def fixed(self) -> int: | ||
"""Get total fixed count.""" | ||
return self.fixed_failures + self.fixed_warnings | ||
|
||
def sort(self) -> None: | ||
"""Sort tag stats by tag name.""" | ||
self.tag_stats = dict(sorted(self.tag_stats.items(), key=lambda t: t[1])) |