8000 GitHub - Konstantin343/cppcheck-annotation-action: Github action, which allows you to annotate C/C++ code in a pull request with warnings, errors, etc. from cppcheck static analysis tool
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Github action, which allows you to annotate C/C++ code in a pull request with warnings, errors, etc. from cppcheck static analysis tool

License

Notifications You must be signed in to change notification settings

Konstantin343/cppcheck-annotation-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CppCheck Annotation Action

tests

Github action, which allows you to annotate C/C++ code in a pull request with warnings, errors, etc. from cppcheck static analysis tool.

Usage

Create .github/workflows/cppcheck-annotaion.
Add default content to it:

name: cppcheck-annotations

on:
  pull_request:

jobs:
  build:
    name: cppcheck-annotations
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run cppcheck-annotation-action
        uses: Konstantin343/cppcheck-annotation-action@v1.1
        with:
          std: 'c++14'
          platform: 'unix64'
          log-level: 'verbose'

      - name: Annotate lines with errors
        uses: yuzutech/annotations-action@v0.5.0
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          title: 'Results of CppCheck'
          input: 'annotations.json'

Usage - extended example

Example of action-fail-level additional parameter usage that sets the step and whole job status to fail, if any of the annotations listed in this parameter will be generated by cppcheck-annotation-action

name: cppcheck-annotations

on:
  pull_request:
  push:

jobs:
  build:
    name: Run Cppcheck Analise
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Run cppcheck-annotation-action
        uses: Konstantin343/cppcheck-annotation-action@v1.1
        with:
          std: 'c++14'
          platform: 'unix64'
          log-level: 'verbose'
          action-fail-level: 'failure,warning'

      - name: Annotate lines with errors
        if: always()                              
        uses: yuzutech/annotations-action@v0.5.0
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          title: 'Results of CppCheck'
          input: 'annotations.json'

Inputs

Input Description Default
json-results-file File to store results in format described on https://docs.github.com/en/rest/checks/runs#create-a-check-run--parameters annotations.json
enable Value for cppcheck argument --enable, comma-separated checks. See https://linux.die.net/man/1/cppcheck all
log-level Log level for cppcheck command, possible values: quite, verbose. Other values will be ignored
std C++ Standard for cppcheck command. See https://linux.die.net/man/1/cppcheck c++20
platform Platform for cppcheck command. See https://linux.die.net/man/1/cppcheck unix32
suppress Comma-separated suppressions for --suppress parameter. See https://linux.die.net/man/1/cppcheck
additional-args Additional arguments for cppcheck command. See https://linux.die.net/man/1/cppcheck
sources Path to folder with source code. See https://linux.die.net/man/1/cppcheck .
annotation-warnings Comma-separated severities of checks of cppcheck that should be warnings in GitHub annotations. See https://linux.die.net/man/1/cppcheck warning
annotation-notices Comma-separated severities of checks of cppcheck that should be notices in GitHub annotations. See https://linux.die.net/man/1/cppcheck information
annotation-failures Comma-separated severities of checks of cppcheck that should be failures in GitHub annotations. See https://linux.die.net/man/1/cppcheck error
annotation-level-default Default level for all annotations that not presented in annotation-warnings, annotation-notices, annotation-failures. Possible values: notice, warning, failure warning
action-fail-level Comma-separated severities of annotations that should lead to a failure status when running this action. Possible values: notice, warning, failure

Outputs

Generate file with name that passed as json-results-file in inputs.
This file contains json object with GitHub Checks annotations in format described on https://docs.github.com/en/rest/checks/runs#create-a-check-run--parameters.
Example:

[
    {
    "title": "Division by zero.",
    "message": "Division by zero.",
    "annotation_level": "failure",
    "file": "tests/test.cpp",
    "line": 14,
    "start_column": 23,
    "end_column": 23
  },
  {
    "title": "Variable 'arr[10]' is assigned a value that is never used.",
    "message": "Variable 'arr[10]' is assigned a value that is never used.",
    "annotation_level": "warning",
    "file": "tests/test.cpp",
    "line": 14,
    "start_column": 13,
    "end_column": 13
  }
]

License

MIT License

Copyright (c) 2022 Konstantin343

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Github action, which allows you to annotate C/C++ code in a pull request with warnings, errors, etc. from cppcheck static analysis tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0