For the complete documentation index, see llms.txt. This page is also available as Markdown.

Monitor projects with AI code

This page explains the internal and external AI Code Assurance labels and badges you have to mark your SonarQube Cloud projects.

Monitoring projects containing AI code is the final step in ensuring that your projects in SonarQube Cloud meet your AI Code Assurance standards.

Sonar’s AI Code Assurance helps you ensure security and code quality within projects containing AI-generated code. By utilizing project labels, custom quality gate certification and marking, and dynamic project badge publishing, you can maintain high standards and confidently assure the quality of your projects.

By now, you’ve likely completed the first two steps to qualify your projects as AI Code Assured:

You should be able to see your projects’ AI Code Assurance status on the Summary page of your project (Main, Pull Requests, and Branches).

With those objectives in place, you can publish dynamic AI Code Assurance badges to your external websites to monitor projects.

Understanding your AI Code Assurance labels

Your Project Information page show labels highlighting the state of AI Code Assurance. These labels provide a quick visual reference of your project’s state of AI Code Assurance status, including the state of containing AI-generated code and the status of your project’s quality gate.

Internal AI Code Assurance status

Here’s what each AI Code Assurance label represents, and what you can do to update the status.

$contains-ai-code: Defined by a Project Admin that the project contains AI-generated code.

  • Go to Project settings > AI-generated code or use the API to activate and deactivate this label.

$in-shield-success AI Code Assurance passed: Your code is passing the quality gate qualified for AI-generated code.

  • Run a new analysis to check your code against the quality gate.

$in-shield-error AI Code Assurance failed: Your code is not passing the quality gate qualified for AI-generated code.

  • Address the issues in your code to meet the standards defined by your quality gate.

$in-shield-on AI Code Assurance is on: Your code uses a quality gate qualified for AI-generated code and the quality gate status has not been computed.

  • Run a new analysis to update the status of your quality gate.

$in-shield-off/disabled AI Code Assurance is off: Your code is not marked as containing AI code or is not using a quality gate qualified for AI-generated code.

  • Check that your project is marked as Contains AI-Generated Code,

  • assign a quality gate qualified for AI-generated code,

  • then run an analysis to update the quality gate status.

Using the AI Code Assurance badge

To complete the final objective for AI Code Assurance, add a dynamic AI Code Assurance badge to monitor the current status of your AI Code Assured projects on your web pages. This badge works like other SonarQube external badges and can be used by any team member with project access.

See the documentation on Using a project badge for instructions on how to publish SonarQube badges externally.

External AI Code Assurance badges

Here’s what each AI Code Assurance badge represents, and what you should do to update the status.

$AI Code Assurance [sonar] | Pass: Your code is passing the quality gate qualified for AI-generated code.

  • Run a new analysis to check your code against the quality gate.

$AI Code Assurance [sonar] | Fail: Your code is not passing the quality gate qualified for AI-generated code.

  • Address the issues in your code to meet the standards defined by your quality gate.

$AI Code Assurance [sonar] | On: Your code is using a quality gate qualified for AI-generated code and the quality gate status has not been computed.

  • Run a new analysis to update the status of your quality gate.

$AI Code Assurance [sonar] | Off: Your code is not using a quality gate qualified for AI-generated code.

  • Assign a quality gate qualified for AI-generated code and run an analysis to update the quality gate status.

Monitoring guardrails

Assuring the security and code quality of AI-generated code relies on two steps:

  1. Sufficient guardrails are configured (Quality Gate, Quality Profile).

  2. The established guardrails are respected while promoting code.

When guardrails are not respected, the codebase is at risk and AI Code Assurance is not guaranteed. Quality gate history helps you monitor adherence to guardrails and understand whether your project is actually following its configured quality gate over time. This feature is available only for projects that use the Previous version as a new code definition.

Last updated

Was this helpful?