Commit Graph

2 Commits

Author SHA1 Message Date
thingsconnected 98b9244bcb
addons/namingng.py: Add tests for include guards, config file validation. (#5815)
Include guard naming can be validated against various patterns:
- prefixes/suffixes (`_FILE_H`, `PROJECT_FILE_H`, `FILE_H_`)
- basename/full path (`FILE_H`, `SUB_DIR_INC_FILE_H`)
- upper- or lowercase (`FILE_H`, `file_h`)
- any combination of the above (`project_sub_dir_inc_file_h_`)

A regexp can be specified to match header filenames. The example matches
any filename not starting with / and ending with `.h`, intended to match
C header files while exluding system files.

The test is not limited to naming only; validity and presence of include
guards can also be tested by setting `"required":true` in the config
file.

Enabling this feature requires adding the key `"include_guard"` to the
namingng config file used.

The namingng unit test is extended to test various features of the
include guard test.

Also, config handling is improved, adding (superficial) validation and a
unit test.
2024-01-02 15:01:02 +01:00
thingsconnected 24133d4a59
addons/namingng.py: Fix commandline use. (#5793)
namingng.py was only usable in standalone mode, but now supports CLI
mode, i.e. with cppcheck --addon=namingng. It uses the generic reporting
provided by cppcheckdata.reportError(). All output other than reported
errors is suppressed.

A local function reportNamingError() is implemented to call through to
cppcheckdata.reportError(), filling in common defaults.

The collection of errors and the --verify feature are removed, including
related workflow and a test file. These are replaced by a unit test.
2023-12-30 20:54:03 +01:00