Skip to content

Commit 4b393e7

Browse files
simonLeary42pre-commit-ci[bot]cidrblock
authored
Exclude non-linted files in summary (#4725)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bradley A. Thornton <[email protected]>
1 parent e8d9d85 commit 4b393e7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ansiblelint/app.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ def count_results(self, matches: list[MatchError]) -> SummarizedResults:
167167
return result
168168

169169
@staticmethod
170-
def count_lintables(files: set[Lintable]) -> tuple[int, int]:
170+
def count_lintables(files: set[Lintable]) -> tuple[int, int, int]:
171171
"""Count total and modified files."""
172172
files_count = len(files)
173+
linted_files_count = len([file for file in files if file.kind])
173174
changed_files_count = len([file for file in files if file.updated])
174-
return files_count, changed_files_count
175+
return files_count, linted_files_count, changed_files_count
175176

176177
@staticmethod
177178
def _get_matched_skippable_rules(
@@ -202,7 +203,9 @@ def report_outcome(
202203
msg = ""
203204

204205
summary = self.count_results(result.matches)
205-
files_count, changed_files_count = self.count_lintables(result.files)
206+
files_count, linted_files_count, changed_files_count = self.count_lintables(
207+
result.files
208+
)
206209

207210
matched_rules = self._get_matched_skippable_rules(result.matches)
208211

@@ -253,6 +256,7 @@ def report_outcome(
253256
self.report_summary(
254257
summary,
255258
changed_files_count,
259+
linted_files_count,
256260
files_count,
257261
is_success=mark_as_success,
258262
)
@@ -272,6 +276,7 @@ def report_summary( # pylint: disable=too-many-locals # noqa: C901
272276
self,
273277
summary: SummarizedResults,
274278
changed_files_count: int,
279+
linted_files_count: int,
275280
files_count: int,
276281
is_success: bool,
277282
) -> None:
@@ -328,7 +333,7 @@ def report_summary( # pylint: disable=too-many-locals # noqa: C901
328333
msg += f": {summary.failures} failure(s), {summary.warnings} warning(s)"
329334
if summary.fixed:
330335
msg += f", and fixed {summary.fixed} issue(s)"
331-
msg += f" on {files_count} files."
336+
msg += f" in {linted_files_count} files processed of {files_count} encountered."
332337

333338
# Now we add some information about required and passed profile
334339
if self.options.profile:

0 commit comments

Comments
 (0)