Skip to content
This repository was archived by the owner on Mar 22, 2020. It is now read-only.

Latest commit

 

History

History
132 lines (99 loc) · 3.93 KB

Configuration.adoc

File metadata and controls

132 lines (99 loc) · 3.93 KB

The cmake_check configuration file

Intro

This document is all you need to know about what’s required in your cmake_check configuration file. It must be actual JSON, not just a JavaScript object literal. It contains of one JSON object, its members are described in the following sections.

As a reference, a commented JSON schema exists.

An example configuration as a basic starting point exists.

crawler

required, type:object

The crawler object contains options for the directory traversal during search for CMake files.

excludePaths

optional, type:string[]

A list of regular expressions that match directories that shall be skipped during traversal. Some folders like .git contain a lot of files but are not relevant for cmake_check, excluding them reduces analysis time. Also add directories that contain uninteresting files and should be excluded from analysis like 3rd party code.

"excludePaths":["\\.git$", "\\.svn$"]
ℹ️
When a character needs to be escaped in the regular expression, 2 backslashes are needed. If a path under windows should be excluded, 4 backslashes are needed: folder\\\\folder1.

cRules

required, type:Rule[]

The collection of rules that should be applied to CMake files. At least one rule is required.

Rule

type:object

A rule is a logical element that describes a requirement to CMake files (an element of a coding guideline). A rule consists of any number of checks. The rule is checked for each input file and passes when all checks pass.

Example:

{
 "id": "CM-003",
 "appliesTo": [
   "TargetCMakeLists"
 ],
 "name": "Variable usage is prohibited",
 "enabled": true,
 "checks": [
   {
     "id": "C001",
     "config": {
       "commands": [
         {
           "name": "^set$",
           "occurences": "0"
         }
       ]
     }
   }
 ]
}

id

required, type: string

Unique identifier of the rule. The id is part of the warning message when the rule is violated.

appliesTo

required, type: enum[]

An array of file types that should be checked against the rule. Values are:

CMakeLists

CMakeLists.txt files that do not define targets. Usually these are the top-level file and files that exist to recurse deeper into a directory tree.

TargetCMakeLists

CMakeLists.txt files that define target(s).

CMakeModule

A CMake module with file extension .cmake.

name

required, type: string

A short description of the rule.

enabled

required, type: boolean

Can be used to disable rule checks without removing them from the configuration.

severity

optional, type: enum, default: warning

One of info, warning, error. The severity is part of the warning output and recognized by e.g. the Jenkins warnings plugin. It can be used to fine-tune rules e.g. errors could result in a build failure, warnings in unstable builds and info does not affect the build at all.

An important use case is the introduction of new warnings. Usually these should not break existing builds. Instead they can be introduced on info or warning severity. At some point in time when their number is stable, the severity can be raised.

checks

required, type: check[]

All checks the rule consists of. The rule is considered as passed for a file when all checks of the rule pass. A check object consists of the following values:

id

required, type: string

The identifier of the check, see the list of available checks.

config

required, type: object

Parameters for the specific check, see checker documentation.