Code references

3 minute read
Code references currently supports GitHub repositories only. It performs a basic text search across .ts, .tsx, and .go files using the GitHub Search API, it does not parse code or detect semantic usage. Results may include matches inside comments, strings, or unrelated code, and may miss usages in unsupported file types.

The Code references page displays where a selected feature flag appears in your codebase. This is especially useful when cleaning up flags that are no longer in use.

Before viewing code references, link components to an application. For setup instructions, refer to Set up code references.

What you can do

On the Code references page, you can:

  • View where a flag is referenced in your source code.

  • Filter by repository.

  • Search for a specific file or reference.

  • Select Access full list on GitHub to view all search results directly in GitHub (opens in a new browser tab outside of CloudBees Unify).

Access code references

To view code references for a flag:

  1. Select Feature management.

  2. On the Flags page, select a flag to open the Configuration page.

  3. On the Configuration page, select the Code references tab.

On the Code references page, you can:

  • View a list of repositories associated with the selected application and flag.

  • Select a specific repository to narrow the search.

  • Select Access full list on GitHub to open a GitHub search tab for the selected flag.

  • Review individual file references, each with a direct link to the GitHub search results.

If no repository is selected, the search runs across all connected repositories.

No results

If no code references display, check the following:

No repositories linked to this application

When no components with repositories are linked to the application, CloudBees Unify has no source code to scan for flag references.

To resolve this:

  1. Connect components with repositories to this application.

  2. Verify each component has a repository connected via an SCM integration.

  3. Refer to Set up code references for detailed setup instructions.

No references found

When repositories are linked but no references appear for a specific flag, this could mean:

  • The flag has not been implemented in your codebase yet (expected for new flags).

  • The flag name in your code does not exactly match the flag name in CloudBees Unify (flag names are case-sensitive).

  • The flag is implemented but has not been committed to the repository branch being scanned.

To resolve this:

  1. Verify the flag name matches exactly between your code and CloudBees Unify.

  2. Check that the flag code has been committed and pushed to the repository.

  3. Wait a few minutes for the scan to complete after pushing new code.

For additional troubleshooting scenarios, refer to troubleshooting code references.

Example code references display

Flag name: METestFlag
  • Created: 2024/11/14 14:40:11

  • Last updated: 2024/11/14 14:44:10

  • Activity status: Inactive

  • File types searched: .ts, .tsx, .go

  • Repositories: All (default)

  • Branches: main (default)

Potential references to METestFlag were found in the following files:

Repository File name View

cloudbees/nextgen-ui

flags.ts

View on GitHub

cloudbees/nextgen-ui

StaticRoutes.tsx

View on GitHub

cloudbees/nextgen-ui

FeatureManagementFlagTabOutlet.tsx

View on GitHub

cloudbees/flag-service

code_references.go

View on GitHub

How it works

  • The GitHub Search API searches for the selected flag name (flagName) across your organization.

  • Results can be filtered by file scope: .ts, .tsx, and .go files.

  • Each result links to GitHub with a prefilled query for the specific file.

  • CloudBees does not link to specific lines—GitHub handles highlighting within the file.

  • If there are no results, an empty search view is returned.

Additional notes

  • Feature flags with dependencies: A flag cannot be deleted if other flags depend on it. These dependencies appear in the Code references tab.

  • Scope: The Code references page displays results based on the selected application.