Skip to content

Commit 73765a7

Browse files
SCANPY-237 Removed redundancy in the output (validation results in dry run mode)
1 parent da4d005 commit 73765a7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/pysonar_scanner/dry_run_reporter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ def report_validation_results(validation_result: "ValidationResult") -> int:
9292
logging.info("=" * 80)
9393

9494
if validation_result.is_valid():
95+
for info in validation_result.infos:
96+
logging.info(f"✓ {info}")
9597
for warning in validation_result.warnings:
96-
logging.warning(f" {warning}")
98+
logging.warning(f"• {warning}")
9799
logging.info("✓ Configuration validation PASSED")
98100
logging.info("=" * 80)
99101
return 0
@@ -130,6 +132,7 @@ class ValidationResult:
130132
def __init__(self):
131133
self.errors: list[str] = []
132134
self.warnings: list[str] = []
135+
self.infos: list[str] = []
133136

134137
def add_error(self, message: str) -> None:
135138
"""Add a validation error."""
@@ -139,6 +142,10 @@ def add_warning(self, message: str) -> None:
139142
"""Add a validation warning."""
140143
self.warnings.append(message)
141144

145+
def add_info(self, message: str) -> None:
146+
"""Add a validation info message."""
147+
self.infos.append(message)
148+
142149
def is_valid(self) -> bool:
143150
"""Check if validation passed (no errors)."""
144151
return len(self.errors) == 0
@@ -197,7 +204,7 @@ def _validate_single_report(report_path: str, base_path: Path, validation_result
197204
f"Coverage report root element is '{root.tag}', expected 'coverage' (Cobertura format)"
198205
)
199206
else:
200-
logging.info(f"Coverage report is valid Cobertura XML: {report_path}")
207+
validation_result.add_info(f"Coverage report is valid Cobertura XML: {report_path}")
201208
except PermissionError:
202209
validation_result.add_error(f"Coverage report is not readable (permission denied): {report_path}")
203210
except UnicodeDecodeError:

tests/unit/test_dry_run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ def test_validate_single_report_valid_cobertura(self, mock_logging):
172172

173173
assert result.is_valid()
174174
assert len(result.warnings) == 0
175-
logged_messages = [str(c) for c in mock_logging.info.call_args_list]
176-
joined = " ".join(logged_messages)
177-
assert "valid Cobertura XML" in joined
175+
assert len(result.infos) == 1
176+
assert "valid Cobertura XML" in result.infos[0]
178177

179178
def test_validate_multiple_coverage_reports(self):
180179
self.fs.create_dir("/project")

0 commit comments

Comments
 (0)