summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/stats.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:56 +0000
commitd964cec5e6aa807b75c7a4e7cdc5f11e54b2eda2 (patch)
tree794bc3738a00b5e599f06d1f2f6d79048d87ff8e /src/ansiblelint/stats.py
parentInitial commit. (diff)
downloadansible-lint-upstream.tar.xz
ansible-lint-upstream.zip
Adding upstream version 6.13.1.upstream/6.13.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ansiblelint/stats.py')
-rw-r--r--src/ansiblelint/stats.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ansiblelint/stats.py b/src/ansiblelint/stats.py
new file mode 100644
index 0000000..67320b8
--- /dev/null
+++ b/src/ansiblelint/stats.py
@@ -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]))