* MISRA: Refactor many top level functions into a class
All the checker operations were implemented as individual functions. In
order to share data globals were used.
By refactoring all these into class methods data can be shared between
them without resorting to globals.
This change is scope only. No functional change for any of the methods.
Data is still shared via globals.
* MISRA: Refactor non-option globals into MisraChecker class
- Move all non-option global variables into the MisraChecker class
- Allows data to be shared among the class methods without needing
globals.
- Move global VERIFY_EXPECTED to class variable verify_expected
- Move global VERIFY_ACTUAL to class variable verify_actual
- Move global VIOLATIONS to class variable violations
- Move global suppressRules to class variable suppressedRules
- Move global suppressions to class variable dumpfileSuppressions
This refactoring is in anticipation of parsing and using the
suppressions added into the dump file by cppcheck.
Only variable naming and scope changed. No functional change for any of the
methods.
* MISRA: Restore original summary behavior
Version 1.84 introduced a regression in the behavior of the rule summary
output due to changes in the way multiple input files were handled.
The intended behavior of the summary was to output the total number of
violations after all files have been processed.
Commit aa831ce972 restored the input file
handling behavior but left summary behavior such that a summary output
was produced for each file that caused a violation instead of the total
number of violations after all files were processed.
Move the -verify logic up into the main loop so that the exit calls are
in the top level and restore the original behavior of the summary
output.
* MISRA: Support per file rule suppressions
Parse the suppressions list from cppcheck and extract MISRA rule strings from
the suppressions class by matching for errorId strings that begin with
'MISRA' or 'misra'. Extract the MISRA rule from those strings by
looking for a '_' or a '.' to separate rule numbers.
Store the rule number, filename, line number, and symbol name from the
suppression entry into a structure that allows for dictionary lookups
by the rule number and then the filename. All the line number
and symbol entries for that filename are are stored in list of tuples of
(line number, symbol name). A rule entry that has a value of None for
the filename is treated as a global suppression for all files. A
filename entry that has None for the rule items list is treated as a
suppression for the entire file. If the rule item list exist then it is
searched for matching line numbers.
Although symbol names are parsed and added int the list of rule items
they are not used for rule matching. Symbol names can include regular
expressions. Adding support for symbol names and regular expressions is
left as a future feature.
The existing global suppression method provided by the --suppress-rules
option is supported. Those rules are added into the suppressions
structure as if they were provided by the suppressions list as global
suppressions. ie A rule with a None for the filename value.
* MISRA addon: Support multiple files with argparse
* MISRA addon fix exit code
Fix to run all dump files then exit with error code if any error in any file found.
* added CLion project folder to .gitignore
* adjusted project name in CMakeLists.txt
* avoid warning when compiling "Debug" with Visual Studio via CMake
There was a GCC-style compiler flag in the common flags in compileroptions.cmake which caused the following warning:
cl : Command line warning D9002 : ignoring unknown option '-O0'
* compileroptions.cmake: restored original formatting
* daca2.py: added missing import
* misra.py: removed unnecessary escaping from regular expression
* added CLion project folder to .gitignore
* adjusted project name in CMakeLists.txt
* avoid warning when compiling "Debug" with Visual Studio via CMake
There was a GCC-style compiler flag in the common flags in compileroptions.cmake which caused the following warning:
cl : Command line warning D9002 : ignoring unknown option '-O0'
* compileroptions.cmake: restored original formatting
* some small *.py script cleanups
WARNING: breaking change - now default misra.py report style will be the
same as cppcheck itself, but previosly misra.py default template was a
little different
* Added ignore list
- Added ignore list
- Use argparse to parse arguments
- Source formatting
* misra.py changed argument name
- Changed ` --ignore-rules` to ` --suppress-rules`
* Resolved VERIFY option in misra.py
Resolved broken broken logic in commit to add argparse.
* edit suppression list
Modified names
Hide some arguments
* command line help formatting
* Revert removal of --no-summary argument
* missing text rules no longer reported
* VERIFY scope modified to global
Output will still be given for style violations.
This allows the build process output to be smaller and cleaner,
making it easier to spot and address problems.
- Show a summary of the of the number of violations. This can be
disabled with the --no-summary option.
- Return an error code if -verify flag not used and violation exists.
Use python's __file__ variable to figure out where the checker script is
located.
This allows a customized per project scripts to be used instead of the
one provided in the cppcheck release.
* Added rule 5.2
* updated 5.2
request-checks: true
* Added rule 5.3
* Changed rule 5.4, 5.5
* Updated test suite for Rule 5.2
* Changes in Rule 5.4 and 5.5
* Change in function name in test suite and removed type from class token in cppcheck
* Changed the name of function in misra-test.c
* Modified rule 5.3
* Modified misra-test.c for rule 5.3
* Added rule 5.2
* updated 5.2
request-checks: true
* Added rule 5.3
* Changed rule 5.4, 5.5
* Updated test suite for Rule 5.2
* Changes in Rule 5.4 and 5.5
* Change in function name in test suite and removed type from class token in cppcheck
* Changed the name of function in misra-test.c
The method “match” was used as a module-level function in for loops
of implementations for MISRA check functions so far.
Use compiled regular expression objects instead.
Link: https://trac.cppcheck.net/ticket/8547
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Added additional elif confition to cause error checks to ignore .dump files
Previous change meant that .dump always falls into else statement and script exits