5.5.5. Using the Axivion Visual Studio Code Plugin

The Axivion Visual Studio Code Plugin provides several commands that extend the functionality of Visual Studio Code. Refer to the plugin overview in Visual Studio Code (see Axivion Visual Studio Code Plugin).

These commands can be triggered via the Command Palette (View > Command Palette or Ctrl+Shift+P) by typing Axivion, or by clicking the Ax icon in the Visual Studio Code status bar.

Commands can also be bound to shortcuts under File > Preferences > Keyboard Shortcuts.

The Axivion Visual Studio Code Plugin provides the following commands:

  • Axivion: Show Issues View and Axivion: Show Issue Properties open the windows described below.

  • Axivion: Reload Issues View reloads the Issues View with the current settings. Axivion: Clean Caches and Reload Issues View also discards the data cached by the Axivion Visual Studio Code Plugin.

  • Axivion: Toggle Editor Markers and Axivion: Toggle Editor CodeLens show or hide the issue markers and the CodeLens elements in the editor.

  • Axivion: Show Output Channel shows the output channel Axivion with the log of the Axivion Visual Studio Code Plugin.

  • Axivion: Start a Local Build starts a Local Build for the project selected in the Issues View. Axivion: Start a Local Dashboard and Axivion: Stop a Local Dashboard switch to the results of the Local Build and back to the results of the Axivion Dashboard Server.

  • Axivion: Run Single File Analysis starts a single-file analysis. Axivion: Clear Single File Analysis Results removes its markers.

  • Axivion: Clear Dashboard Secrets deletes the stored passwords and ApiTokens of the configured Axivion Dashboard Servers. This command is only available when the setting axivion.featureFlags.clearDashboardSecrets is enabled.

The Axivion Visual Studio Code Plugin provides two Visual Studio Code windows:

  • Issues View, which lists the issues available for a selected analysis project;

  • Issue Properties, which provides details for the currently selected issue in the Issues view.

5.5.5.1. Issue View

The Issues View window allows you to query new and resolved erosion issues. The user interface is very similar to the web dashboard described in section Issue Table and Issue Deltas.

To open the Issues View, use the command Axivion: Show Issues View.

:guielement:`Issues View` window

Issues View window

The elements in the toolbar select which issues to display. From left to right:

  1. Dashboard selection: The dashboard selection dropdown allows to quickly change between several dashboards. It also contains the entry Offline (see Offline Local Build).

  2. Project: Allows you to select the analysis project whose issues are viewed. The combobox lists all projects available on the server, which the current user can access.

  3. plugins_local_build Start Local Build: Starts the local build. The results are stored in
    <home>/.bauhaus/localbuild.
  4. plugins_local_dashboard View Local Build Results: Switches between the results of the dashboard (global analysis on CI server) and the results of the local build.

  5. Issue Kind: Selects which type of issue to display.

  6. State: The two controls with the arrow symbols allow you to view only added issues, only removed issues, or both. The numbers indicate the number of added/removed issues in the current query result.

  7. Start version (Version): Like the web dashboard, the issue list shows the difference between two versions. Issues that exist in the start version but not in the end version are listed as removed. Issues that exist in the end version but not in the start version are listed as added. To see all issues, pick EMPTY as start version. This special version does not contain any issues, so the list will display all issues in the chosen end version. When a new analysis is available on the Axivion Dashboard Server, the list of available versions in the plugin might not update immediately. In this case, click the Axivion: Reload Issues View button at the top-right corner of the window to force the plugin to download the current list of versions from the Axivion Dashboard Server.

    As an alternative, you can also run the command Axivion: Reload Issues View to update the issue list.

  8. End version (to): The end version for which the issues are to be retrieved. In Local Build mode, the start and end version controls are replaced with a dropdown which allows to quickly select the two available versions or their difference: Reference version, Locally changed issues, and All local issues.

  9. User: Specifies the user whose issues are to be shown:

    • ANYBODY: shows all issues; that is, does not filter based on the user;

    • NOBODY: shows only those issues that are not associated with any user,

    • <user_name>: shows all erosion issues associated with the given user name.

    As a normal user, you can see only your own user name as well as those of users marked with the public flag (see Section Users).

  10. Filter: Allows one to specify a globbing pattern. Only the issues associated with a file that matches the specified globbing pattern are shown. For example, the path “src/main/io.c” can be matched by *.c as well as */io.?. If left empty, all files are considered.

  11. Named Filter: Allows applying a Named Filter which overrides the currently set filters and column sorting. Named Filter management is possible in the Web UI. If a filter or sorting is changed, the dropdown switches to the last entry in the list [modified] which denotes the “unnamed filter” - meaning that the currently applied filters and sorting are not saved as a Named Filter.

    Private Names Filters are marked with the suffix [^].

  12. plugins_filter_question Show filter help: Opens a browser and shows the filter help.

The Axivion Visual Studio Code Plugin will automatically start a new query when any of the above options are changed.

Note

The Axivion Visual Studio Code Plugin does not support Local Build, Local Dashboard, and Single File Analysis in restricted mode. Therefore, the Local Build and Local Dashboard buttons will be disabled in untrusted workspaces.

Filtering

In addition to the file filter, the issue list view also supports filtering individual columns. You can type in the filter text boxes below the column headers to apply a filter to the respective column.

Detailed information on the filter strings supported by individual columns is available by clicking the plugins_filter_question Show filter help button.

Filtering the issue list.

Filtering the issue list.

Sorting

The issue list can be sorted by clicking column headers. A single click sorts the list by that column. To sort by multiple columns, hold Shift while clicking column headers.

Note: Only the sorting arrows of manually clicked columns are highlighted. Sorting via named filters is applied but not highlighted due to implementation restrictions.

Go to Dashboard

The Axivion Visual Studio Code Plugin allows you to quickly jump to the dashboard to view an issue, view the issue table, or obtain a dashboard link for an issue to share with a colleague.

Right-click an issue to open the context menu, which offers the following options: Open issue in editor, Open issue properties, Open issue in dashboard, Open table in dashboard, and Copy dashboard link to clipboard.

This is not possible when Local Build is active.

Open issue in dashboard context menu.

Open issue in dashboard context menu.

Note

When using the Open table in dashboard entry while having a Named Filter selected, you will be taken to an issue table with the Named Filter expanded, i.e., the exact set of issues.

Viewing Issues

To view more details for an issue in the Issues View, open Issue Properties using the Open issue properties entry in the issue’s context menu. The command Axivion: Show Issue Properties opens the Issue Properties window without issue details. While this window is open, it shows the details of the issue selected in the Issues View.

Issue Properties showing issue details

Issue Properties showing issue details

Note

If the dashboard URL uses localhost, clicking the ID link of the issue shown in Issue Properties opens the issue in the integrated browser of Visual Studio Code, since Visual Studio Code 1.145. To open the issue in the system browser instead, disable Open Localhost Links under Settings > Workbench > Browser.

To open the code for an issue, double-click the entry in the issue list. If the path mapping is configured correctly, the plugin will open the source file and jump to the line containing the issue.

Since the analyzed version of the code may differ from the local version, the line numbers of issues may have changed. For example, an issue that was on line 100 during the analysis may now be on line 120 if 20 lines of code were added at the beginning of the file. When opening an issue, the Axivion Visual Studio Code Plugin downloads the analyzed version of the file and computes the new location of the issue using the difference between the analyzed file and the current editor contents.

5.5.5.2. Code Editor

If path mapping is configured correctly, opening a code file in Visual Studio Code displays issues from the latest analysis as gutter icons in the breakpoint area, as a clickable CodeLens element that navigates to Issue Properties, and as a Diagnostic (underlined code entity). This is enabled by default and can be toggled using the command Axivion: Toggle Editor Markers. Additionally, issues are added to the VS Code Problems view.

Caution

Issue markers for a file are cached for 20 minutes. After a new analysis has been performed, use the command Axivion: Reload Issues View and reopen the file to refresh the issue markers.

5.5.5.3. Local Analyses

Local analyses allow you to analyze code locally before it is committed to version control. This requires the Axivion Suite to be installed locally, in addition to the Axivion Visual Studio Code Plugin. Please note that this requires specific settings as described in Configuration.

Complete Project

A complete analysis of the entire project is called a “Local Build.” This is documented in Starting Local Build from within the IDE Plugins.

Offline Local Build

The Offline Local Build feature allows you to run Axivion Local Build without a connection to a remote dashboard server. Users can select “Offline” as the dashboard in the Issues View, select a project, and run the analysis directly from the IDE. The Issues View reloads automatically after the build to display the results.

When selecting a project, the project picker lists all previously analyzed projects as well as any Local Build configurations that do not yet contain analysis data. Additionally, a New project... option is available; selecting this prompts for a project name and creates a new Local Build configuration for the project.

Single Compilation Unit

A single compilation unit can be analyzed for style violations using the Axivion: Run Single File Analysis command in the command palette, or via the context menu in the File Explorer or the editor.

Single-File Analysis command in the Command Palette

Single-File Analysis command in the Command Palette

Single-File Analysis Command in the Explorer View

Single-File Analysis Command in the Explorer View

For instructions on how to successfully run this command in your workspace, see the configuration example in Single-File Analysis Settings.

The command can also be started from a shell type task in tasks.json using the command ${command:axivion.singleFileAnalysis} and the single argument ${file}. The analysis output is shown in the Axivion - Local Analyses output channel.

While the single-file analysis is running, a progress indicator provides a cancel button.

Cancel the Single-File Analysis

Cancel the Single-File Analysis

The results are shown in the Visual Studio Code Problems view.

Single-File Analysis results in the Problems View

Single-File Analysis results in the Problems View

The single-file analysis creates markers for the detected issues. These markers are displayed in addition to markers from the Axivion Dashboard Server or the Local Build. Single-file analysis markers are cleared when a new single-file analysis is run.

Single-File Analysis markers

Single-File Analysis markers

Caution

To run the single-file analysis, the Axivion Suite used must be version 7.0.0 or later.

5.5.5.4. AI Chat Tools

The Axivion Visual Studio Code Plugin provides tools for the VS Code AI Chat, allowing LLMs to assist you in understanding and fixing Axivion Suite issues. When interacting with a chat agent, the agent can now query markers in the current file or fetch details for specific issues. This enables the agent to provide more context-aware assistance, such as explaining the issues in the current file or suggesting fixes based on the issue details.

The Axivion Visual Studio Code Plugin tools can also be triggered manually. Use #axivion_ in the chat to explore the available tool options.

To enable AI assistance, ensure the Axivion Visual Studio Code Plugin is configured according to the instructions in Configuration. Specifically, a connection to the Axivion Dashboard Server and a path mapping are required to access markers. Local Build and Single File Analysis configurations are required if the agent needs to run local analyses.

Note

The #axivion_get_suppression_guidance tool requires axivion.experimental.languageModelTools.bauhausConfig to be set. It defaults to ${workspaceFolder}/axivion.