Measuring Team Engagement with PR Decoration Feedback on Test Coverage

Hi everyone,

We’re exploring whether there’s a way to measure how teams are engaging with the PR decoration comments—particularly those related to test coverage.

We’ve set up PR decoration to provide feedback on code quality, and one of our key goals is encouraging strong unit test coverage from the outset. Ideally, we’d like to understand how often teams respond directly to this feedback within the same pull request (e.g., by adding tests immediately) versus deferring improvements to a follow-up PR.

Is there an existing metric or best practice for tracking this kind of engagement? Would love to hear how others approach this or if there’s a way SonarQube can help us analyze this behavior quantitatively.

Thanks!

Hey @lpcruz

Since SonarQube doesn’t keep the history of a PR (it only keeps the latest analysis results), this might be a little hard to measure.

Still, I think you might be able to use Webhooks to track the history of PRs. The webhook body contains all QG conditions.

{
  "serverUrl": "http://localhost:9000",
  "taskId": "3905411e-f679-472e-958f-e2d155c65b67",
  "status": "SUCCESS",
  "analysedAt": "2025-05-26T14:24:02+0200",
  "revision": "73cecbab30d0252d5bf1b4832020dbe1388a0fe0",
  "changedAt": "2025-05-26T14:24:02+0200",
  "project": {
    "key": "colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813",
    "name": "python-flask-demo",
    "url": "http://localhost:9000/dashboard?id=colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813"
  },
  "branch": {
    "name": "1",
    "type": "PULL_REQUEST",
    "isMain": false,
    "url": "http://localhost:9000/dashboard?id=colin-sonarsource_python-flask-demo_24c71932-54a1-44de-aa0c-9c433e0bc813&pullRequest=1"
  },
  "qualityGate": {
    "name": "Sonar way w/ SCA",
    "status": "OK",
    "conditions": [
      {
        "metric": "new_coverage",
        "operator": "LESS_THAN",
        "status": "NO_VALUE",
        "errorThreshold": "80"
      },
      {
        "metric": "new_duplicated_lines_density",
        "operator": "GREATER_THAN",
        "status": "NO_VALUE",
        "errorThreshold": "3"
      },
      {
        "metric": "new_security_hotspots_reviewed",
        "operator": "LESS_THAN",
        "status": "NO_VALUE",
        "errorThreshold": "100"
      },
      {
        "metric": "new_violations",
        "operator": "GREATER_THAN",
        "value": "0",
        "status": "OK",
        "errorThreshold": "0"
      }
    ]
  },
  "properties": {
    "sonar.analysis.detectedscm": "git",
    "sonar.analysis.detectedci": "undetected"
  }
}

You’d have to set something up to catch those webhooks and then process the data, but it’s definitely possible.