diff --git a/package.json b/package.json index ae792a1..87f4286 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,40 @@ } } } + ], + "walkthroughs": [ + { + "id": "cppcheck-official.gettingStarted", + "title": "Get Started with Cppcheck", + "description": "Learn the basics of using cppcheck in VS Code with the official extension", + "steps": [ + { + "id": "step1", + "title": "Connect extension to your cppcheck executable", + "description": "", + "media": { + "markdown": "walkthrough/path.md" + }, + "completionEvents": ["onSettingChanged:cppcheck-official.path"] + }, + { + "id": "step2", + "title": "Customize settings", + "description": "", + "media": { + "markdown": "walkthrough/arguments.md" + } + }, + { + "id": "step3", + "title": "Try out the extension", + "description": "", + "media": { + "markdown": "walkthrough/test.md" + } + } + ] + } ] }, "scripts": { diff --git a/src/extension.ts b/src/extension.ts index 9c0aad4..dfa32e2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -68,6 +68,19 @@ function parseMinSeverity(str: string): SeverityNumber { // Your extension is activated the very first time the command is executed. export async function activate(context: vscode.ExtensionContext) { + // Register a command to push user to workspace settings from walkthrough + context.subscriptions.push( + vscode.commands.registerCommand( + 'cppcheck-official.configureArguments', + async () => { + await vscode.commands.executeCommand( + 'workbench.action.openWorkspaceSettings', + 'cppcheck-official.arguments' + ); + } + ) + ); + // Create a diagnostic collection. const diagnosticCollection = vscode.languages.createDiagnosticCollection("Cppcheck"); context.subscriptions.push(diagnosticCollection); diff --git a/walkthrough/arguments.md b/walkthrough/arguments.md new file mode 100644 index 0000000..bdbe99a --- /dev/null +++ b/walkthrough/arguments.md @@ -0,0 +1,12 @@ + + +Cppcheck works best for you if you set it up according to your needs. You may e.g. want to disable certain kinds of warnings, and if you have cppcheck premium you will need to set this up for it to work in this extension. All of this is done through the extension property 'arguments', with the different flags or arguments available being detailed in the [official cppcheck documentation](https://files.cppchecksolutions.com/manual.pdf#page=13). + +It is recommended to set up these settings in the workspace settings so that you and your team easily can work with the same set up. Furthermore you are likely to want to have the same settings between VS Code and your CI workflows. This is most easily done through project files, which are referenced from the argument setting (see [documentation](https://files.cppchecksolutions.com/manual.pdf#page=4) for how to create a project file). + +![image showing project file path being set in arguments property](../images/project_file.png) + +Another way of synching your set up between different environments is through using scripts. The argument property supports running scripts with the syntax `@(/path/to/script.sh)`. The extension expects this script to output what to use for arguments wrapped with `@()`, so e.g. `echo "@(--report-progress --enable=style --inconclusive --suppress=syntaxError)"`. + + +[Set up arguments](command:cppcheck-official.configureArguments) \ No newline at end of file diff --git a/walkthrough/path.md b/walkthrough/path.md new file mode 100644 index 0000000..af96119 --- /dev/null +++ b/walkthrough/path.md @@ -0,0 +1,5 @@ +![image showing where to find the cppcheck path property](../images/cppcheck_path.png) + +Open the extension settings. Set the path to your cppcheck executable in the `path` property. + +[Set path](command:workbench.action.openSettings?%5B%22cppcheck-official.path%22%5D) \ No newline at end of file diff --git a/walkthrough/test.md b/walkthrough/test.md new file mode 100644 index 0000000..cd52017 --- /dev/null +++ b/walkthrough/test.md @@ -0,0 +1,5 @@ +![Image showing cppcheck warnings in the problems tab.](../images/check_result2.png) + +Open a .c or .cpp file and save it. If cppcheck detects any issues these will show up in the problems tab in the bottom of your VS Code window. + +The extension is in continuous development, so if you find issues, have feature requests or some other kind of feedback we are happy to recieve it at the [Cppcheck Official github page](https://github.com/cppchecksolutions/vscode-cppcheck-official/issues). \ No newline at end of file