You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
manual: add description about namingng. if misra is needed then cppcheck premium is recommended. do not describe misra.py in premium manual because that shouldn't be used. (#7518)
Copy file name to clipboardExpand all lines: man/manual-premium.md
+42-21Lines changed: 42 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -981,47 +981,68 @@ Cppcheck is distributed with a few addons which are listed below.
981
981
982
982
## Supported addons
983
983
984
-
### misra.py
984
+
### namingng.py
985
+
986
+
[namingng.py](https://github.com/danmar/cppcheck/blob/main/addons/namingng.py) allows you to configure and check naming conventions.
987
+
988
+
You need to have a configuration file that defines your naming conventions. By default the filename `namingng.config.json` is used but there is an option so you can use any filename you want.
989
+
990
+
Example configuration of naming conventions:
991
+
```
992
+
{
993
+
"RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"],
994
+
"RE_PRIVATE_MEMBER_VARIABLE": null,
995
+
"RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"],
996
+
"_comment": "comments can be added to the config with underscore-prefixed keys",
997
+
"include_guard": {
998
+
"input": "path",
999
+
"prefix": "GUARD_",
1000
+
"case": "upper",
1001
+
"max_linenr": 5,
1002
+
"RE_HEADERFILE": "[^/].*\\.h\\Z",
1003
+
"required": true
1004
+
},
1005
+
"var_prefixes": {"uint32_t": "ui32"},
1006
+
"function_prefixes": {"uint16_t": "ui16",
1007
+
"uint32_t": "ui32"}
1008
+
}
1009
+
```
985
1010
986
-
[misra.py](https://github.com/danmar/cppcheck/blob/main/addons/misra.py) is used to verify compliance with MISRA C 2012, a proprietary set of guidelines to avoid questionable code, developed for embedded systems.
1011
+
### threadsafety.py
987
1012
988
-
The full list of supported rules is available on: [https://files.cppchecksolutions.com/misrac2023.html](https://files.cppchecksolutions.com/misrac2023.html)
1013
+
[threadsafety.py](https://github.com/danmar/cppcheck/blob/main/addons/threadsafety.py) analyses Cppcheck dump files to locate thread safety issues like static local objects used by multiple threads.
989
1014
990
1015
### y2038.py
991
1016
992
1017
[y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) checks Linux systems for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. This required [modified environment](https://github.com/3adev/y2038). See complete description [here](https://github.com/danmar/cppcheck/blob/main/addons/doc/y2038.txt).
993
1018
994
-
### threadsafety.py
995
-
996
-
[threadsafety.py](https://github.com/danmar/cppcheck/blob/main/addons/threadsafety.py) analyses Cppcheck dump files to locate thread safety issues like static local objects used by multiple threads.
997
-
998
1019
## Running Addons
999
1020
1000
-
Addons could be run through Cppcheck command line utility as follows:
1021
+
Addons can be executed with the `--addon` option:
1001
1022
1002
-
cppcheck --addon=misra.py somefile.c
1023
+
cppcheck --addon=namingng.py somefile.c
1003
1024
1004
-
This will launch all Cppcheck checks and additionally calls specific checks provided by selected addon.
1025
+
Likewise, if you have created your own script you can execute that:
1005
1026
1006
-
Some addons need extra arguments. You can configure how you want to execute an addon in a json file. For example put this in misra.json:
1027
+
cppcheck --addon=mychecks.py somefile.c
1028
+
1029
+
You can configure how you want to execute an addon in a json file. For example:
1007
1030
1008
1031
{
1009
-
"script": "misra.py",
1032
+
"script": "mychecks.py",
1010
1033
"args": [
1011
-
"--rule-texts=misra.txt"
1012
-
]
1034
+
"--some-option"
1035
+
],
1036
+
"ctu": false
1013
1037
}
1014
1038
1015
-
And then the configuration can be executed on the Cppcheck command line:
1016
-
1017
-
cppcheck --addon=misra.json somefile.c
1039
+
To use that json file to execute your addon use the --addon option:
1018
1040
1019
-
By default Cppcheck would search addon at the standard path which was specified
1020
-
during the installation process. You also can set this path directly, for example:
Copy file name to clipboardExpand all lines: man/manual.md
+58-19Lines changed: 58 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -986,47 +986,86 @@ Cppcheck is distributed with a few addons which are listed below.
986
986
987
987
[misra.py](https://github.com/danmar/cppcheck/blob/main/addons/misra.py) is used to verify compliance with MISRA C 2012, a proprietary set of guidelines to avoid questionable code, developed for embedded systems.
988
988
989
-
The misrarule texts should be downloaded from [MISRA](https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/tools)
989
+
The misra.py script does not provide rule texts, those should be downloaded from [MISRA](https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/tools)
990
990
991
-
Use the option `--rule-texts` to specify the rules text file that has been downloaded from [MISRA](https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/tools).
991
+
To load the ruletexts, create a configuration file. Example `misra.json`:
992
992
993
-
Checkers in open source Cppcheck only cover MISRA rules partially.
To use that `misra.json` in Cppcheck analysis, use option `--addon=misra.json`:
996
1002
997
-
[y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) checks Linux systems for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. This required [modified environment](https://github.com/3adev/y2038). See complete description [here](https://github.com/danmar/cppcheck/blob/main/addons/doc/y2038.txt).
Misra checkers in open source Cppcheck only cover MISRA rules partially and for full coverage use Cppcheck Premium.
1006
+
1007
+
### namingng.py
1008
+
1009
+
[namingng.py](https://github.com/danmar/cppcheck/blob/main/addons/namingng.py) allows you to configure and check naming conventions.
1010
+
1011
+
You need to have a configuration file that defines your naming conventions. By default the filename `namingng.config.json` is used but there is an option so you can use any filename you want.
1012
+
1013
+
Example configuration of naming conventions:
1014
+
```
1015
+
{
1016
+
"RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"],
1017
+
"RE_PRIVATE_MEMBER_VARIABLE": null,
1018
+
"RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"],
1019
+
"_comment": "comments can be added to the config with underscore-prefixed keys",
1020
+
"include_guard": {
1021
+
"input": "path",
1022
+
"prefix": "GUARD_",
1023
+
"case": "upper",
1024
+
"max_linenr": 5,
1025
+
"RE_HEADERFILE": "[^/].*\\.h\\Z",
1026
+
"required": true
1027
+
},
1028
+
"var_prefixes": {"uint32_t": "ui32"},
1029
+
"function_prefixes": {"uint16_t": "ui16",
1030
+
"uint32_t": "ui32"}
1031
+
}
1032
+
```
998
1033
999
1034
### threadsafety.py
1000
1035
1001
1036
[threadsafety.py](https://github.com/danmar/cppcheck/blob/main/addons/threadsafety.py) analyses Cppcheck dump files to locate thread safety issues like static local objects used by multiple threads.
1002
1037
1038
+
### y2038.py
1039
+
1040
+
[y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) checks Linux systems for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. This required [modified environment](https://github.com/3adev/y2038). See complete description [here](https://github.com/danmar/cppcheck/blob/main/addons/doc/y2038.txt).
1041
+
1003
1042
## Running Addons
1004
1043
1005
-
Addons could be run through Cppcheck command line utility as follows:
1044
+
Addons can be executed with the `--addon` option:
1045
+
1046
+
cppcheck --addon=namingng.py somefile.c
1006
1047
1007
-
cppcheck --addon=misra.py somefile.c
1048
+
Likewise, if you have created your own script you can execute that:
1008
1049
1009
-
This will launch all Cppcheck checks and additionally calls specific checks provided by selected addon.
1050
+
cppcheck --addon=mychecks.py somefile.c
1010
1051
1011
-
Some addons need extra arguments. You can configure how you want to execute an addon in a json file. For example put this in misra.json:
1052
+
You can configure how you want to execute an addon in a json file. For example:
1012
1053
1013
1054
{
1014
-
"script": "misra.py",
1055
+
"script": "mychecks.py",
1015
1056
"args": [
1016
-
"--rule-texts=misra.txt"
1017
-
]
1057
+
"--some-option"
1058
+
],
1059
+
"ctu": false
1018
1060
}
1019
1061
1020
-
And then the configuration can be executed on the Cppcheck command line:
1021
-
1022
-
cppcheck --addon=misra.json somefile.c
1062
+
To use that json file to execute your addon use the --addon option:
1023
1063
1024
-
By default Cppcheck would search addon at the standard path which was specified
1025
-
during the installation process. You also can set this path directly, for example:
0 commit comments