Commit Graph

456 Commits

Author SHA1 Message Date
fuzzelhjb 8fcfe0ceb0 add CERT STR07-C check 2019-06-23 13:59:24 +02:00
Daniel Marjamäki 63bd29d644 addons/cppcheckdata.py: Add 'cppcheckdata.getArguments' function 2019-06-23 13:54:33 +02:00
Georgy Komarov 02cc9ffcd8 misra.py: Add --verify-rule-texts option. (#1909)
* misra.py: Add verify-rule-texts option.

* Capture stdout output in travis.
2019-06-19 21:57:27 +02:00
Georgy Komarov e979b0652c misra.py: Fix up and improve load rules parser. (#1895)
* misra.py: Fixup load rules parser.

* misra.py: Report when rule text is missing in rule-texts file

* misra.py: Allow to skip misra checks not specified in rule-texts.

* misra.py: Remove top-level control flow.

Create separate class that stores settings, instead of global variables.

This is required to perform imports from misra.py for testing purposes.

* misra.py: Add simple pytest test for load rules.

* misra.py: Add document structure tests.

* misra.py: Exit after show rules table.

* misra.py: Add document structure tests.

* misra.py: Fixup import pitfall with python2

* misra.py: Minor fixes
2019-06-17 21:17:29 +02:00
fuzzelhjb 5e3da9e82a add CERT STR05-C check (#1899)
* add CERT STR05-C check

* update check
2019-06-17 20:42:23 +02:00
eivindt 44670005ea Record C/CPP/Posix Standard used for cppcheck in dump file / use this for misra checking (#1782)
* Add cmd parameter for choosing between C90 and C99

Misra specifies different requirements to the uniqueness of
macros/enums/variables depending on what C standard
that's being used.

* Add standards configuration to each dump file

Read standards config from misra addon to decide what rules to use.

* Posix as standard setting should be deprecated.  Don't include this in the xml

* Rewritten to use a switch
2019-06-14 12:06:57 +02:00
Daniel Marjamäki 1584e62367 cppcheckdata: Added 'simpleMatch' function 2019-06-06 15:38:15 +02:00
Daniel Marjamäki 784f2951fb misra: generating misra table 2019-06-01 15:57:19 +02:00
Daniel Marjamäki 7c6d15bb81 Fixed #8658 (false positive: MISRA rule 8.12) 2019-06-01 13:10:20 +02:00
Daniel Marjamäki f204ab88d6 misra feature matrix: I believe Cppcheck handle rule 14.3 2019-05-27 17:28:59 +02:00
Daniel Marjamäki d594b195d4 Misra feature matrix: Cppcheck has checks for 18.2 and 18.3 2019-05-26 20:45:21 +02:00
Daniel Marjamäki d039c388ec Fixed #8582 (Regression MISRA Rule 5.1) 2019-05-26 18:46:35 +02:00
Daniel Marjamäki 54be0bc3cf Misra: Added checker for misra rule 17.7 2019-05-22 21:39:33 +02:00
Mathias Schmid 149c07f475 Fix misra addon rule 4 1 (#1846)
* Modifiy check for MISRA rule 4.1 to avoid skipping constant character literal enclosed by single quotes.
Add test for MISRA rule 4.1 which contains non-compliant cases defined by MISRA C 2012 document.

* Moved additional test cases for MISRA rule 4.1 to appropriate test case section.
2019-05-22 14:33:59 +02:00
Daniel Marjamäki 48dfba429a Fixed #8822 (false positive: MISRA rule 13.4) 2019-04-27 17:43:26 +02:00
Daniel Marjamäki 146326bfaf misra.py: Rewrote rule texts parser 2019-04-16 10:57:31 +02:00
Daniel Marjamäki 7f19a9a255 addon/misra.py: fix problem with summary 2019-04-16 08:45:06 +02:00
Daniel Marjamäki e0da316759 cppcheckdata.py: fix sys.errout 2019-04-16 08:26:58 +02:00
Daniel Marjamäki 97157046f7 addons: /reportErrorCli/reportError/ 2019-04-14 08:54:53 +02:00
Daniel Marjamäki b1b5b27b4e addons: write column in error message(s) 2019-04-13 10:22:13 +02:00
Daniel Marjamäki 8bacfafd01 misra.py: Advisory=>style 2019-04-12 12:30:06 +02:00
Daniel Marjamäki 76e64dce8c misra: fix crash if Misra severity Required/Mandatory/Advisory is not set 2019-04-12 12:28:44 +02:00
Daniel Marjamäki a1c30b834c misra.py: Added rule 20.10 2019-04-11 10:50:07 +02:00
Daniel Marjamäki 3e3c805a66 misra.py: Add rule 20.7 2019-04-11 10:36:02 +02:00
Daniel Marjamäki cb55ccb9b0 misra.py: Fix dereference of None 2019-04-10 21:21:17 +02:00
Daniel Marjamäki b5d9313663 naming.py: Unify addon output 2019-04-10 21:11:50 +02:00
Daniel Marjamäki 7b6d7b9335 threadsafety.py: allow execution with --addon 2019-04-10 21:06:40 +02:00
Daniel Marjamäki 05fcfc85fa findcasts: Unify output 2019-04-10 18:29:46 +02:00
Daniel Marjamäki bf5ad56dba cert.py: Removed CLI 2019-04-10 18:09:27 +02:00
Daniel Marjamäki 466caabbf2 Fixed misc.py test 2019-04-10 07:31:52 +02:00
Daniel Marjamäki 4509b25f97 replace tabs with spaces in cppcheckdata.py 2019-04-10 06:48:16 +02:00
Daniel Marjamäki 4415992a62 Addons: Remove the xml output. You can get xml output from the GUI/command line clients. 2019-04-09 20:42:17 +02:00
Daniel Marjamäki f2889d5c82 Try to unify addon output 2019-04-09 20:36:24 +02:00
Daniel Marjamäki 44dcbda88e Addons: Fixed handling of addon configuration 2019-04-08 19:42:16 +02:00
eivindt ff1114e3c7 Misra explicitly allows spaces between # and the preprocessing tokens (#1781)
* Misra explicitly allows spaces between # and the preprocessing tokens

* Added tests illustrating need for changing preprocessor checking
2019-04-08 18:26:17 +02:00
eivindt 253986bc31 List the number of violations per rule (#1786)
* List the number of violations per rule

* Avoid using 'id' as variable name
2019-04-08 18:10:40 +02:00
Daniel Marjamäki d2949adff1 misc.py: Make it possible to run this addon from cppcheck 2019-04-07 21:07:08 +02:00
Daniel Marjamäki bf9006737a Addons: Adding support in Cppcheck CLI to execute addons 2019-04-07 17:01:59 +02:00
eivindt 0debd8d520 Misra xml output (#1787)
* Add (very) simple XML output support

* Removed xml top and tail, better handled outside
2019-04-05 12:36:58 +02:00
eivindt 76bf5ecb06 Map MISRA violation categories to cppcheck categories (#1775) 2019-04-03 19:39:05 +02:00
eivindt 480284d428 Show number of hits per suppression rules entry (#1776) 2019-04-03 19:38:03 +02:00
Sebastian 4735b6ca1b
addons/naming.py: Fix crash on unnamed arguments, add regex validation. (#1762)
Crash has been reported in the forum:
https://sourceforge.net/p/cppcheck/discussion/development/thread/138788ac6b/
A small test has been added to avoid regression.
2019-03-26 18:54:09 +01:00
versat 68dd203f43 addons/namingng.py: Fixed typos, no functional changes intended. 2019-03-26 15:21:49 +01:00
Armin Müller f4b5b156d7 Typos found by running "codespell" (#1715) 2019-03-01 01:01:39 +01:00
Sebastian 72c9646be9
misra.py: Possible fix for problematic code (#1613)
Without the `for scope in data.scopes:` loop, scope is not assigned anything.
From the context a loop over `data.scopes` could be intended. But other things like indentation would be possibly correct too. Not sure how this code should be.
We try this fix.
2019-01-22 07:28:29 +01:00
Sebastian c106dd2939
misra addon: Fix issue with unexpected encodings in loadRuleTexts() (trac 8946) (#1608)
https://trac.cppcheck.net/ticket/8946
Add tests to travis script for verifying rule text loading.
Add dummy rule text files.
misra.py: Try to find a suitable codec for rule texts file.
2019-01-18 21:30:08 +01:00
Servando 7c168fa850 Feature/ros naming check (#1511)
* Added script to check ROS naming style

* Added header to script

* Enhanced namingng.py and added ROS_naming.json

* Correction of style bugs

* Removed trailing whitespace

* Removed trailing whitespace

* Removed path

* Remove path from file name

* Check if the token belongs to the current file or is included

* Reverted

* Fixed msg errors
2019-01-09 18:16:51 +01:00
practicalswift 0a1b3a9d6f Fix typos (#1568) 2019-01-06 17:15:57 +01:00
Thorsten Sick 43b6a391d8 Added a new naming check addon. Also verifies variable and function p… (#1456)
* Added a new naming check addon. Also verifies variable and function prefixes

* Verification added to code

* added naming checks ng selftest to travis file

* Ensure zero exit value for tests if tests succeed

* Expected values adjusted

* Fixed copy and paste error
2018-11-06 20:46:07 +01:00
Armin Müller acf2035a53 Typos found by running "codespell" (#1461) 2018-11-03 07:34:27 +01:00
Daniel Marjamäki 25a3aeef86 cert.py: another fix for valueflow 2018-10-29 01:39:52 +01:00
Daniel Marjamäki b5241ecb80 cert.py: more robust handling of values 2018-10-28 20:55:15 +01:00
Daniel Marjamäki 2730b16326 cppcheckdata.py: read more data from dumps 2018-10-28 20:47:44 +01:00
Richard A. Smith f286325cec Fix per file excludes (#1437)
* MISRA: Allow printing of the suppressed rules to the console

--show-suppressed-rules will print rules in the suppression rule list to
the console sorted by rule number.

* MISRA: Correct rule suppression for entire file scope

The entire file scope suppression check was checking for the rule item
list to be None instead of looking for None as an entry into the list.

Correct this check and modify the documentation to explicitly state that
an entry of None in the rule item list will set the scope for that
suppression to be the entire file.

* MISRA: Tests for checking per-file rule suppressions

To run:

../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c
python ../misra.py misra-suppressions*-test.c.dump

There should be no violations reported

* MISRA: Allow ignoring a prefix from file paths when suppression matching

For environments that run cppcheck from the build system cppcheck may be
passed a filename that is a complete path.

Often this path will include a portion that is specific to the developer
or to the environment where the project is located.

The per-file suppression rules do filename matching based on the
filename passed to cppcheck. To match any path information also has to
be included into the suppressions file provided to cppcheck via the
--suppressions-list= option.

This limits the usefulness of the per-file based suppressions because
it requires the suppression to be customized on a per instance basis.

Add a option "--file-prefix" that allows a prefix to be excluded from
the file path when doing the suppression filename matching.

Example.

Given the following structure:

/test/path1/misra-suppressions1-test.c
/test/path1/misra-suppressions2-test.c

specifying --file-prefix /test/path1 will allow the use of
misra-suppressions1-test.c and misra-suppressions2-test.c as filenames
in the suppressions file without leading patch information but still
match the suppression rule.

* MISRA: Tests for --file-prefix option

To run:

../../cppcheck --suppressions-list=suppressions.txt \
    --dump misra-suppressions*-test.c \
           path1/misra-suppressions*-test.c

python ../misra.py misra-suppressions*-test.c.dump \
                   path1/misra-suppressions*-test.c

There should be no violations reported
2018-10-18 09:17:57 +02:00
Richard A. Smith 4dbdc934b8 MISRA: Prevent exception on variadic functions (#1436)
Functions with variadic arguments trip an exception in the MISRA checker
because some of the token is None and does not have some of the members
the code is expecting.

Prevent this by checking to see if the token is None and skipping the
code that tries to use that value.
2018-10-18 09:11:51 +02:00
Daniel Marjamäki d9e1cc957b Fixed #8704 (false postive: MISRA rule 5.2) 2018-10-07 17:19:40 +02:00
Daniel Marjamäki 90a2a46959 Fixed #8657 (false postive: MISRA rule 15.7) 2018-10-01 20:16:48 +02:00
Richard A. Smith ecd2ba2ece MISRA: Support Per file excludes from cppcheck (#1393)
* 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.
2018-09-29 09:05:13 +02:00
Daniel Marjamäki 18eff25c98 misra: fix fp for rule 3.1 2018-09-08 17:23:24 +02:00
Daniel Marjamäki 8d88f75f03 Fixed #8567 (False positive: MISRA RULE 20.3) 2018-09-02 16:31:27 +02:00
Daniel Marjamäki 8f9fa2e6a7 Fixed #8562 (false positive: MISRA rule 20.13) 2018-09-02 16:05:37 +02:00
Sebastian dce3281766
addons/cert.py: Add MSC30-C: Do not use rand() (#1348)
Add function isStandardFunction() that checks if the given function is a standard function.
Only when this function returns true for the currently checked rand() tokens it is reported as a violation.
Tests added for C and C++.
2018-08-24 15:05:50 +02:00
Kyle Chisholm 4e25da7b9d Misra.py fix multiple file processing (#1332)
* 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.
2018-08-09 08:51:00 +02:00
Oliver Stöneberg bb27bc280a more small *.py cleanups (#1329)
* 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
2018-08-06 22:07:58 +02:00
Oliver Stöneberg 13cf982b77 some small *.py script cleanup (#1328)
* 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
2018-08-05 20:36:21 +02:00
Kyle Chisholm aa831ce972 MISRA addon: Support multiple files with argparse (#1327) 2018-08-04 21:37:08 +02:00
Daniel Marjamäki 9edcae97fc Fixed #8578 (Argument scope as global) 2018-06-19 08:50:32 +02:00
Daniel Marjamäki 68a91b73da Travis: Enforce naming convention, private variable names must start with 'm[A-Z]' 2018-06-18 09:55:43 +02:00
Daniel Marjamäki 2f23757c74 addons/naming.py: Allow regular expression for private member variable names 2018-06-17 14:46:59 +02:00
Konrad Grochowski c30f21ed2a cppcheckdata.py - support for missing file name in suppression (#1286) 2018-06-13 22:32:27 +02:00
Konrad Grochowski 3702c477c0 misra.py - rule 8.12 fixed for enums depending on other enums values (#1287) 2018-06-13 06:54:30 +02:00
Konrad Grochowski 8925a0fd81 misra.py - Rule 11.8 fixed in function arguments checks (#1288) 2018-06-13 06:51:24 +02:00
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
KMilhan 8b509a158f Make MISRA C 2012 12.2 work on C++ (#946) 2017-08-31 16:06:46 +02:00
Daniel Marjamäki b7af13ce63 cert.py: reformat output again 2017-08-15 21:44:43 +02:00
Daniel Marjamäki 2ca46ceae9 threadsafety.py: reformat output 2017-08-15 21:44:21 +02:00
Daniel Marjamäki 256adfbcb5 cert.py: Reformatting output 2017-08-15 20:34:54 +02:00
Daniel Marjamäki 051fb55e2c misra.py: Reformatting output 2017-08-15 20:34:44 +02:00
Daniel Marjamäki bb5b18cf7e Revert "Remove MISRA addon before the release of 1.80"
This reverts commit 2ecf47c328.
2017-07-29 16:28:57 +02:00
Daniel Marjamäki 2ecf47c328 Remove MISRA addon before the release of 1.80 2017-07-29 10:04:54 +02:00
Ayaz Salikhov 2e6a22e882 Improve Python code 2017-07-22 11:05:50 +02:00
Ayaz Salikhov 3dc4188292 Improve Python code 2017-06-05 13:23:00 +02:00
Ayaz Salikhov 2dd6168258 Improve Python code 2017-06-04 22:51:48 +02:00
Daniel Marjamäki 39d55a6f6e Revert "Temporarily remove MISRA addon"
This reverts commit b85150d45a.
2017-05-13 15:03:29 +02:00
Daniel Marjamäki b85150d45a Temporarily remove MISRA addon 2017-05-13 10:55:10 +02:00
Daniel Marjamäki 2b80f17714 y2038: fix problems 2017-04-19 06:46:53 +02:00
Daniel Marjamäki 82a68858ef Misra: Add rule 3.1 2017-04-18 20:47:11 +02:00
Daniel Marjamäki ea67086da4 Misra: Fix crash in rule 10.6 for bad AST 2017-04-18 19:57:49 +02:00
Daniel Marjamäki f707eceb20 Misra: Fix endless loop in rule 5.3 2017-04-18 19:54:43 +02:00
Daniel Marjamäki ce9f121ce6 Misra: Fix rule 5.3 2017-04-17 13:32:48 +02:00
Daniel Marjamäki 9305394abd Misra: Add rule 5.3 2017-04-17 13:17:37 +02:00
Daniel Marjamäki dd2eb9ad1a Misra: tweak rule 5.4 2017-04-17 12:57:21 +02:00
Daniel Marjamäki 11621b2b36 Misra: Add rule 5.4 2017-04-17 12:55:19 +02:00
Daniel Marjamäki c56926f4bd Misra: Add rule 5.5 2017-04-17 12:48:28 +02:00
Daniel Marjamäki 892f11b7f1 Misra: Fix FP, rule 15.6 2017-04-17 10:39:05 +02:00
Daniel Marjamäki a47a5e55e4 Misra: Fix FP, rule 15.6 2017-04-17 09:38:46 +02:00
Daniel Marjamäki 0adc4f0789 Misra: Fix FP, rule 16.6 2017-04-17 09:07:45 +02:00
Daniel Marjamäki 196b530ede Misra: Fix FP, rule 10.8 2017-04-17 08:44:30 +02:00
Daniel Marjamäki d6570b01e1 misra.py: Fix loading of rule texts 2017-04-17 08:35:17 +02:00
Daniel Marjamäki 4f64e67298 Misra: Add rule 8.11 2017-04-17 07:45:27 +02:00
Daniel Marjamäki 6c8712c57b Misra: Added --rule-texts=<file> flag 2017-04-16 21:38:26 +02:00