Skip to content

Add rule-based false positive report with enhanced analytics#2

Merged
roberto-luzardo-sonarsource merged 2 commits into
mainfrom
add-quality-gate-and-profiles
Feb 11, 2026
Merged

Add rule-based false positive report with enhanced analytics#2
roberto-luzardo-sonarsource merged 2 commits into
mainfrom
add-quality-gate-and-profiles

Conversation

@roberto-luzardo-sonarsource

Copy link
Copy Markdown
Owner

Summary

This PR enhances the SonarQube False Positive Issues Reporter to generate two comprehensive CSV reports instead of one, providing deeper insights into false positive patterns.

Changes Made

New Features

  • Rule-Based Report: New CSV file aggregating false positives by rule with:

    • Rule ID
    • False positive count per rule
    • Rule severity
    • Software qualities impacted (MAINTAINABILITY, RELIABILITY, SECURITY)
  • Enhanced Project Report: Added percentage column showing the ratio of false positives to total issues

Improvements

  • Fetches all issues globally for comprehensive rule analysis
  • Removed quality gate and quality profiles columns from project report for cleaner output
  • Added new command-line argument --rule-output / -r for specifying rule report filename

Technical Changes

  • Added get_all_false_positive_issues() method to fetch all FP issues across projects
  • Added get_total_issues_count() method to calculate FP percentages
  • Added get_rule_details() method to fetch rule severity and software qualities
  • Added count_false_positives_by_rule() function for rule-based analysis
  • Added export_rule_counts_to_csv() function for rule report generation

Documentation

  • Updated README with new features, usage examples, and sample outputs
  • Added comprehensive examples for both CSV report formats

Output Files

The script now generates two CSV files:

  1. Project-based report (default: sonarqube_false_positives.csv)
  2. Rule-based report (default: false_positives_by_rule.csv)

Usage Example

python sonarqube_false_positives.py -u https://sonarqube.example.com -t mytoken -o projects.csv -r rules.csv

This commit enhances the SonarQube false positive reporter to include:
- Quality gate used by each project
- Quality profiles containing the rules that generated false positive issues

New API methods added:
- get_project_quality_gate(): Fetches the quality gate for a project
- get_quality_profiles_for_project(): Retrieves all quality profiles associated with a project

The CSV output now includes two additional columns:
- Quality Gate: The name of the quality gate assigned to the project
- Quality Profiles: A semicolon-separated list of language:profile pairs

Updated README with the new features and sample output.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add new CSV report showing false positives aggregated by rule
- Include rule severity and software qualities in rule report
- Add percentage column to project report showing FP ratio
- Fetch all issues across projects for comprehensive rule analysis
- Remove quality gate and quality profiles from project report
- Update README with new features and usage examples
@robertosonartest

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
1 New issue
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

@roberto-luzardo-sonarsource
roberto-luzardo-sonarsource merged commit ca546f9 into main Feb 11, 2026
2 of 3 checks passed
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