Coder Social home page Coder Social logo

ceedling-cppcheck-plugin's Introduction

Cppcheck Ceedling Plugin

Add Ceedling task for analyzing code with Cppcheck.

Contents

Installation

Clone this into Ceedling's plugin folder of your current project.

$ cd <your-project>/vendor/ceedling/plugins
$ git clone https://github.com/deltalejo/cppcheck-ceedling-plugin.git cppcheck

Enable the plugin

Add the plugins path to your project.yml if you have not done it yet. Then add cppcheck plugin to the enabled plugins list:

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - cppcheck

Configuration

Add cppcheck section to your project.yml specifying configuration options. e.g:

:cppcheck:
  :reports:
    - html
  :addons:
    - misra

Reports

Three types of reports are available:

  • text
  • xml
  • html

They can be enabled by listing them on the :reports list:

:cppcheck:
  :reports:
    - text
    - html

Text

Artifact file and output format can be configured:

:cppcheck:
  :text_artifact_filename: path/to/CppcheckResults.txt
  :template: gcc

:template can be any of the ones included with Cppcheck or custom format string.

XML

Artifact file can be configured:

:cppcheck:
  :xml_artifact_filename: path/to/CppcheckResults.xml

HTML

Artifact directory and HTML title can be configured:

:cppcheck:
  :html_artifact_dirname: path/to/CppcheckHtml
  :html_title: Awesome Project

Notes:

  • This report requires the cppcheck-htmlreport tool to be available.
  • This report implies the xml report.

Preprocessor defines

Define

:cppcheck:
  :defines:
    - A
    - B
    - C=1

Undefine

:cppcheck:
  :undefines:
    - A
    - B
    - C

Note: By default TEST is undefined so the analysis is performed against production code.

Includes

Force inclusion of files before checked files.

:cppcheck:
  :includes:
    - file1.h
    - file2.h

Excludes

Exclude files from the analysis.

:cppcheck:
  :excludes:
    - file1.c
    - file2.c

Platform

Specify platform to use for the analysis, can be any of the ones included with Cppcheck, e.g.: unix64, or the path of the platform XML file.

:cppcheck:
  :platform: unix64

Standard

Specify C/C++ language standard.

:cppcheck:
  :standard: c99

Check Level

Specify the check level to be used for whole project analysis.

  • normal
  • exhaustive

By default exhaustive will be used.

:cppcheck:
  :check_level: normal

Single file analysis uses Cppcheck's default. i.e. normal.

Addons

Addons to be run.

:cppcheck:
  :addons:
    - misra
    - path/to/addon.py

MISRA with rule texts file

Locate your rules text file or copy it to your project. e.g.: <your-project>/misra.txt and create the addon file misra.json inside your project:

misra.json
{
	"script": "misra",
	"args": ["--rule-texts=misra.txt"]
}

Enable the addon:

:cppcheck:
  :addons:
    - misra.json

Checks

Enable additional checks:

:cppcheck:
  :enable_checks:
    - performance
    - portability

Note: These are only enabled for single file analysis. Whole project analysis always enable all checks.

Disable individual checks:

:cppcheck:
  :disable_checks:
    - style
    - information

Suppressions

Inline

Inline suppressions are disabled by default, they can be enabled with:

:cppcheck:
  :inline_suppressions: true

List Files

Suppressions files can be used by giving the search paths and/or files in the :paths and :files sections of your project.yml respectively. e.g.:

:paths:
  :cppcheck:
    - suppressions/
    - source/*/suppressions/

:files:
  :cppcheck:
    - suppressions.xml

Both XML and text files are supported, and for the latter, the file extension can be configured. The default is .txt. e.g.:

:extension:
  :cppcheck: .txt

The files that will ultimately be used can be verified with:

ceedling files:cppcheck

Command Line

Command line suppressions can also be added:

:cppcheck:
  :suppressions:
    - memleak:src/file1.cpp
    - exceptNew:src/file1.cpp

Library configuration

Add library configuration files:

:cppcheck:
  :libraries:
    - lib1.cfg
    - lib2.cfg

Rules

Regular expression rules:

:cppcheck:
  :rules:
    - if \( p \) { free \( p \) ; }

Extra options

For things not covered above, add extra command line options:

:cppcheck:
  :options:
    - --max-configs=<limit>
    - --suppressions-list=<file>

Usage

Analyze whole project

Run analysis for all project sources:

$ ceedling cppcheck:all

Note: Analysis is run with all checks enabled.

Analyze single file

Run analysis for single source file:

$ ceedling cppcheck:<filename>

Note: Analysis will run with the checks in :enable_checks list enabled or with style check if none given.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.