Skip to content

SCANPY-237 Add dry run mode to Pysonar scanner#301

Open
marc-jasper-sonarsource wants to merge 6 commits intomasterfrom
MJ/SCANPY-237
Open

SCANPY-237 Add dry run mode to Pysonar scanner#301
marc-jasper-sonarsource wants to merge 6 commits intomasterfrom
MJ/SCANPY-237

Conversation

@marc-jasper-sonarsource
Copy link
Contributor

No description provided.

@sonar-review-alpha
Copy link

sonar-review-alpha bot commented Mar 18, 2026

Summary

Adds dry-run mode to the Pysonar scanner, allowing users to validate configuration without connecting to a SonarQube server or submitting analysis. The feature includes configuration reporting, coverage report validation with detailed error messages, and exit codes for CI/CD integration. Enabled via --dry-run flag, property -Dsonar.scanner.dryRun=true, or environment variable SONAR_SCANNER_DRY_RUN=true.

What reviewers should know

Start by reading DRY_RUN_MODE.md to understand the user-facing feature. The implementation has three main components: (1) entry point in __main__.py:run_dry_run() checks if dry-run is enabled and exits early, (2) dry_run_reporter.py provides the core logic—DryRunReporter formats output, ValidationResult tracks errors/warnings, and CoverageReportValidator checks coverage files for existence, readability, and Cobertura XML format, (3) configuration plumbing in cli.py and properties.py adds the flag. The validation provides clear, actionable error messages (not found, not readable, invalid XML, wrong root element) which is critical for the stated use case of troubleshooting configuration. Tests in test_dry_run.py cover all validators and the integration path; also update existing configuration loader tests to expect the new property.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 18, 2026

SCANPY-237

Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conclusion: There's one clear user-facing bug that needs fixing before merge — warnings are silently dropped when validation passes — and a minor TOCTOU issue in the file-open logic.

🗣️ Give feedback

Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

🗣️ Give feedback

@sonarqube-next
Copy link

Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

🗣️ Give feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant