Commit Graph

284 Commits

Author SHA1 Message Date
Konrad Grochowski 8290d84472 MISRA 10.4 - fixed ?: operator (#1281)
x ? a : b - only a and b has to be checked
2018-06-09 08:23:41 +02:00
Konrad Grochowski 06f19fb3a7 misra.py: template used for error reporting will now be configurable (#1279)
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
2018-06-06 14:53:09 +02:00
orbitcowboy 79f70cbb32 misra.py: restored previous output style. The output style was broken by 0c6d60d202. 2018-06-05 14:16:25 +02:00
Konrad Grochowski 0c6d60d202 MISRA - support for per file/line error suppression (#1275)
* cppcheckdata.py: fixed Suppression.isMatch method

* cppcheckdata.py: fixed parsing <suppressions> tag

* misra.py: now uses cppcheckdata.reportError and supports suppressions
2018-06-04 21:50:21 +02:00
Swasti Shrivastava bdb372f929 Modified rule 14.1 (#1267)
* Modified rule 14.1

* Made suggested changes

* Added findCounterTokens

* Removed hasFloatComparison

* Improved isFloatCounterInWhileLoop

* Made all required minor changes
2018-06-04 10:12:51 +02:00
Konrad Grochowski e1014253ef MISRA Rule 11.6 will no longer report violation on '(void)p;' (#1272) 2018-05-30 12:44:20 +02:00
Konrad Grochowski d46baad462 misra.py: support for and C99 keywords in isBoolExpression (#1268) 2018-05-29 06:50:32 +02:00
Swasti Shrivastava a3b9745557 Modified Rule 10.8 (#1265)
* Modified Rule 10.8

* Made suggested changes to handle unary operators
2018-05-28 12:58:19 +02:00
Swasti Shrivastava 742d6513a1 Modified rule 10.6 (#1263)
* Modified rule 10.6

* Improved rule 10.6
2018-05-24 22:28:36 +02:00
Kyle Chisholm 6ce3571bdd Add --suppress-rules argument for misra.py (#1259)
* 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
2018-05-24 06:31:20 +02:00
Daniel Marjamäki 9f47d04af6 misra.py: add rule 10.1, partial checking 2018-05-23 16:26:00 +02:00
Swasti Shrivastava ea5417b8af Modified rule 11.9 (#1262) 2018-05-23 15:48:07 +02:00
Swasti Shrivastava 8daa8520ba Modified rule 11.6 (#1261) 2018-05-23 12:50:35 +02:00
Swasti Shrivastava 684c18f657 Modified rule 11.3 and 11.7 (#1260)
* Modified rule 11.3 and 11.7

* Changed if to elif
2018-05-23 10:14:17 +02:00
Swasti Shrivastava c73dc63537 Modified rule 11.5 (#1256) 2018-05-22 14:32:00 +02:00
Daniel Marjamäki 5505cbac26 misra.py: fixed fix for fp so that struct initializers are handled also 2018-05-22 13:27:27 +02:00
Daniel Marjamäki dbe2a42e89 misra.py: Fixed 13.1 fp for struct initialization 2018-05-22 13:11:39 +02:00
Swasti Shrivastava c511b3de20 Modified rule 11.4 (#1252)
* Modified rule 11.4

* Made changes in isEnum()

* Made suggested changes in isEnum()
2018-05-22 09:07:48 +02:00
Richard A. Smith 01cbadc6ed Add --quiet flag to misra.py for cleaner output (#1254)
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.
2018-05-21 21:46:58 +02:00
Swasti Shrivastava f78314b613 Updated rule 10 4 (#1251)
* Updated rule 10.4

* Updated rule 10.4

* updated rule 10.4 along with test suite
2018-05-21 12:04:20 +02:00
Richard A. Smith e4f10bce6d Show summary of violations (#1244)
- 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.
2018-05-20 14:48:01 +02:00
Swasti Shrivastava 00970274b2 Added rule 21.6 and 21.10 (#1243) 2018-05-20 14:44:12 +02:00
Richard A. Smith 672d0433a4 Allow per project misra.py addon (#1241)
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.
2018-05-20 14:42:25 +02:00
Richard A. Smith a26d73f78f Fix false positive in misra.py rule 20.14 (#1240)
MISRA rule 20.14 is not limited to #if pragmas and also extends to
positives whenever #ifdef/#ifndef is used.
2018-05-20 08:31:59 +02:00
Swasti Shrivastava 248e2ef2f8 Modified rule 7.3 (#1232) 2018-05-16 12:04:02 +02:00
Swasti Shrivastava 92fd7d9343 Modified rule 5.1 along with test suite (#1231)
* Modified rule 5.1 along with test suite

* Modified variable name in misra-test.c

* Modified rule 5.1 along with test suite

* Changed variable name
2018-05-16 11:07:44 +02:00
Swasti Shrivastava bb7ffd123d Modified rule 8.12 (#1233) 2018-05-15 13:18:55 +02:00
Matthias Krüger 4c8bb9ac6f fix a few typos 2018-05-14 13:11:59 +02:00
Swasti Shrivastava 4b873ed573 Rule 5.3 modified along with test suite (#1227)
* 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
2018-05-14 13:09:38 +02:00
swasti16 4956b89506 Changes in misra c rule 5.4 and 5.5 (#1219)
* 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
2018-05-11 14:57:08 +02:00
orbitcowboy c39e3467a4 misra.py: Rule 21.8, added missing exit() function. 2018-05-09 16:48:49 +02:00
orbitcowboy bcae3ce9d4 misra.py: State that Cppcheck already covers rule 22.4 with error-id: 'writeReadOnlyFile'. 2018-05-09 13:51:14 +02:00
swasti16 d934065d21 Added rule 5.2 (#1212)
* Added rule 5.2

* updated 5.2

request-checks: true

* Updated test suite for Rule 5.2
2018-05-08 20:41:45 +02:00
Markus Elfring 58ebc64b2f Using compiled regular expressions for MISRA check functions (#1208)
​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>
2018-05-07 22:19:39 +02:00
Daniel Marjamäki 286e300c6f misra: fix test assertion 2018-05-04 22:30:24 +02:00
Daniel Marjamäki 904e9149bf misra: fix 16.3 false negative for conditional break 2018-05-04 22:27:45 +02:00
Daniel Marjamäki 8be593db8f misra: fixed false negatives 2018-05-04 22:18:22 +02:00
Daniel Marjamäki 53e3217254 misra: updated 20.14 2018-05-04 06:37:02 +02:00
Daniel Marjamäki 8b42706158 misra: Added check for rule 20.13 2018-05-03 22:53:06 +02:00
Daniel Marjamäki 274d56d0aa misra: Added 20.14 rule 2018-05-03 22:41:12 +02:00
Daniel Marjamäki 493e243c0b misra: fix fp in 16.6 2018-05-03 10:59:09 +02:00
Daniel Marjamäki 2a9ee563c2 misra: avoid fp for essentially boolean conditions when bitfield member is used 2018-05-02 20:56:03 +02:00
Daniel Marjamäki fce7a0a128 dump: add Function::type 2018-04-30 16:52:51 +02:00
Daniel Marjamäki 2f18fbabaa Addons: Renamed classStart/classEnd to match SymbolDatabase 2018-04-28 23:06:54 +02:00
Daniel Marjamäki 975be66c63 String concatenation in array: Improved handling of macros 2018-04-28 23:01:29 +02:00
rebnridgway 995b496ddf Add suppressions to the XML dump (#1166)
* Added parsing suppressions from dump xml.

* Added code to dump suppressions to an xml file

* Added declaration for dump function

* Suppressions will now be written to the xml file when a dump is requested

* Fixed syntax error

* Removed excess whitespace

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Fixed indentation to be consistent

* Added missing include for ErrorLogger::toXml

* Fixed suggestions from pull request #1166

Switched to using ranged for loop to iterate through suppressions.
Made the line number attribute optional, rather than 0 if not specified.  This means when Python deserialises it it will be None, which is more pythonic.

* Implemented checking suppressions in reportError

This modification expects suppressions and a function to be called to write a line of output to be passed in.  The function checks if any of the suppressions match the warning (with the new Suppression.isMatch function) and if so returns None.  This change maintains the old behaviour of returning the warning text, but adds the possibility of returning None if the warning was suppressed.

* Fixed code quality warnings

* Removed more extraneous whitespace
2018-04-24 22:19:24 +02:00
Daniel Marjamäki 5e31911fcd misra.py: fix false positives in 16.3 for unconditional blocks of code 2018-04-24 09:28:24 +02:00
Daniel Marjamäki 86a9deffbf misc.py: removed bailouts 2018-04-20 08:18:49 +02:00
Daniel Marjamäki 3c48e08e6c misc.py: write debug message when valueType is None 2018-04-19 22:23:34 +02:00
Daniel Marjamäki fb89c987b0 misra.py: Improved 'isBoolExpression' 2018-04-18 16:20:54 +02:00
Daniel Marjamäki f94a2b0019 misra.py: cppcheck handle rule 20.6 2018-04-17 08:15:36 +02:00
Daniel Marjamäki d181e98d02 misc.py: Added experimental ellipsisStructArg checker that warns when struct is passed to ellipsis function 2018-04-16 13:55:12 +02:00
Daniel Marjamäki 194b4096c2 renamed misc test file since it has c++ code 2018-04-16 13:17:47 +02:00
Daniel Marjamäki d65f00fe2e misc.py: Add check for implicitly virtual functions 2018-04-16 13:16:53 +02:00
Daniel Marjamäki 9579b12be9 misc.py: fixed FP 2018-04-16 12:55:27 +02:00
Daniel Marjamäki 19591298f1 misc.py: Fixed FP for string concatenation 2018-04-16 10:53:29 +02:00
Daniel Marjamäki 7031cc7e22 misc.py: Add addon for some misc checkers 2018-04-13 22:19:47 +02:00
Daniel Marjamäki 97c86ff0e6 Dumps: Added isVirtual/isImplicitlyVirtual info 2018-04-13 21:15:43 +02:00
Daniel Marjamäki 8f21ba91e3 cert.py: Fix FP 2018-04-12 20:23:50 +02:00
Daniel Marjamäki 1767fe525b Addons: Fixed handling of noname arguments 2018-04-10 11:10:10 +02:00
Sebastian d46e4c1df6
misra.py: Typo in number of rules (comment) (#1150)
I have no copy of the misra pdf but according to
https://sourceforge.net/p/cppcheck/discussion/general/thread/ccbe9e89/#a6ab
and the number of lines/rules printed by misra.py -generate-table i
guess 143 is really the correct number of rules.
2018-04-10 08:55:25 +02:00
Daniel Marjamäki 97b17d50aa cert.py: fixed fp in exp05 for non-pointer casts 2018-04-03 15:12:01 +02:00
Daniel Marjamäki d31ba0ca02 misra.py: updated 11.8 2018-04-03 15:11:25 +02:00
Daniel Marjamäki 2db7c6e1a3 cert.py: Add rule EXP-05: do not cast away const 2018-04-03 13:35:19 +02:00
Daniel Marjamäki 1270ae2ad8 cppcheckdata: fixed loading of function data 2018-04-03 13:20:21 +02:00
Daniel Marjamäki 4a36520af2 misra.py: reformatting -generate-table output 2018-04-02 13:04:44 +02:00
Daniel Marjamäki 15218b388f misra.py: Add -generate-table option that shows what rules are implemented 2018-03-31 12:52:00 +02:00
Daniel Marjamäki ed8fda571b misra.py: Add rule 4.1 2018-03-31 12:17:55 +02:00
Daniel Marjamäki 588ec80122 misra: the user must provide the rule texts in text file. 2018-03-24 13:28:40 +01:00
amai ed25e21929 Set executable bit for addons/ python scripts 2018-03-20 20:54:59 +01:00
Daniel Marjamäki 480d84d69c Fixed #8441 (MISRA Addon: FP 12.3 issued for initializer lists) 2018-03-18 22:05:31 +01:00
amai2012 449dcc15e8 Add links to external references 2018-03-16 08:12:39 +01:00
Daniel Marjamäki 1110cd0c57 misra.py: updated parsing of misra-rules.txt 2018-03-14 23:00:17 +01:00
Daniel Marjamäki c74b0934e9 misra.py: assume that '0' and '1' have essentially boolean types 2018-03-14 14:54:05 +01:00
Daniel Marjamäki b8d0da31de threadsafety.py: warn for local static non-class variables also 2018-03-14 11:55:01 +01:00
Daniel Marjamäki 08ee5709ed misra.py: updated 17.1 to catch non-compliant code in example suite 2018-03-14 09:41:23 +01:00
Daniel Marjamäki 348232a599 misra.py: catch all 15.6 bugs in misra exemplar suite 2018-03-13 14:22:25 +01:00
Daniel Marjamäki 49c8e42b30 misra.py: Clarify code for switch case fallthrough 2018-03-13 13:14:26 +01:00
Daniel Marjamäki caf0789ab3 misra.py: updated -verify behaviour, print all errors seen and not just the first 2018-03-12 15:51:41 +01:00
Daniel Marjamäki a705391054 misra.py: minor update 2018-03-12 15:47:06 +01:00
Daniel Marjamäki 77318d0e14 misra.py: updated 16.3 code 2018-03-12 15:16:57 +01:00
Daniel Marjamäki f10d170ad3 misra addon: handle [[fallthrough]] attribute 2018-03-12 13:43:23 +01:00
Jonathan Clohessy 589cc6049d Modified misra.py to fix issue introduced during last change (#1101)
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
2018-02-26 22:08:22 +01:00
Daniel Marjamäki 21bb973702 Removed code metrics addon 2018-02-18 11:17:54 +01:00
Daniel Marjamäki 0e6e8ecda1 addons/metrics.py: count comments 2018-02-17 17:31:59 +01:00
Daniel Marjamäki 5db9345a08 addons/metrics: Add simple script for generating some metrics 2018-02-17 14:59:40 +01:00
Daniel Marjamäki 7f616a1805 misra.py: Add error handling when there are missing files, wrong arguments, etc 2018-02-17 07:39:37 +01:00
Daniel Marjamäki 6e8184f7cc cert.py: Added test for EXP46 2018-01-23 22:43:29 +01:00
Daniel Marjamäki 8eae9cdd60 cert.py: Added testcases for EXP42 and fixed the code a little 2018-01-23 17:18:47 +01:00
amai2012 fcbe88ad2f Move test files to subfolder 2018-01-23 11:33:13 +01:00
Daniel Marjamäki 55b3004000 misra.py: minor tweaks 2018-01-21 10:39:18 +01:00
Daniel Marjamäki 6f2d4361df Misra: Integration of MISRA in the GUI. The misra addon can now extract the rule texts from the PDF. 2018-01-20 14:13:09 +01:00
orbitcowboy 5a333dfa17 addons:y2038:README: fixed typos. 2017-11-07 11:14:09 +01:00
KMilhan 76c3cef4d6 MISRA 15.7 only checks if...else if constructs (#983) 2017-10-26 08:47:53 +02:00
Daniel Marjamäki 438b1ccb91 cert.py: update cert-INT31-C checker 2017-10-16 13:35:07 +02:00
Daniel Marjamäki 8a8339274b cert.py: add testfile 2017-10-15 16:18:29 +02:00
Daniel Marjamäki 56ceb5a58c cert.py: Added INT-31-C check, ensure that integer conversions do not result in lost or misinterpreted data 2017-10-14 22:24:24 +02:00
Daniel Marjamäki 243960eb8a Revert "Remove MISRA addon before the release of 1.81"
This reverts commit 9baefd8687.
2017-10-09 15:25:55 +02:00
Daniel Marjamäki 773cc07d44 cppcheckdata.py: parsing of NULL pointers from VS 32-bit and 64-bit 2017-10-07 22:44:35 +02:00
Daniel Marjamäki 9baefd8687 Remove MISRA addon before the release of 1.81 2017-10-07 13:38:21 +02:00