Commit Graph

475 Commits

Author SHA1 Message Date
Georgiy Komarov 390a5af064
misra.py: Fix crashes on obsolete GCC syntax for struct initialization (#3175)
* misra.py: Fix crashes on obsolete GCC syntax for struct initialization

* Added expected violations
2021-03-20 13:59:39 +01:00
JuPrgn 0f2855af0b
Fix misra parameter typo (#3166) 2021-03-08 16:01:55 +01:00
Daniel Marjamäki 170c8257b2 Revert "Small refactoring"
This reverts commit 103e0d883c.
2021-03-07 10:39:23 +01:00
Daniel Marjamäki 103e0d883c Small refactoring 2021-03-07 09:03:50 +01:00
Daniel Marjamäki ebf54ac53e Misra; Remove 12.4 because the check is not implemented properly 2021-02-25 22:11:13 +01:00
Daniel Marjamäki 22727ee3ab Addons; split up possible/known values and impossible values. This is inconsistent with core Cppcheck, however the addons do not handle impossible values in general. A future improvement might be to clarify this somehow, maybe renaming Token.values. 2021-02-23 22:40:49 +01:00
Oliver Stöneberg b472b4e65d
some Python cleanups based on PyCharm inspections (#2999)
* some Python cleanups based on PyCharm inspections

* test-helloworld.py: adjusted assert in test_addon_relative_path()
2021-01-31 14:27:11 +01:00
Armin Müller 0de0a954d2
Typos found by running "codespell" (#3042) 2021-01-12 20:48:25 +01:00
Georgiy Komarov 35a42cd0fe
cppcheckdata: Make the source files for configuration public (#3030)
Extend CppcheckData class API to make the list of source files public.
This can be used by custom addons.
2021-01-08 22:59:58 +01:00
Georgiy Komarov 13b8ee8871
cppcheckdata: Use instance attributes in Cppcheckdata (#3029)
This commit makes CppcheckData class to use instance attributes instead
of class attributes.

Since class attributes are mutable (list), when you append to them, they
don't promote to instance variable which means when you call parsedump()
multiple times data just gets appended to them.

Found by samed on the forum:
https://sourceforge.net/p/cppcheck/discussion/general/thread/c6e1210ec2/
2021-01-08 10:25:51 +01:00
Georgiy Komarov 82f51bd523
misra: Fix crash on rule 9.x (#3024)
Closes ticket #10084
2021-01-07 15:04:12 +01:00
kskjerve c22290f5a3
Fix #10043 unexpected designator (#2966) 2020-12-21 13:25:41 +01:00
kskjerve d4860f500a
MISRA 9.2 to 9.5 (#2954) 2020-12-16 17:28:54 +01:00
Daniel Marjamäki a810678b83 Addons: handle inline suppressions internally in cppcheckdata 2020-12-05 11:37:09 +01:00
Daniel Marjamäki 02d927f0f9 Temporarily disable misra suppressions test 2020-12-04 21:16:02 +01:00
Daniel Marjamäki 649a754cfd Revert "Addons: handle inline suppressions internally in cppcheckdata"
This reverts commit 1ce78a1086.

There was regressions in handling of suppressions.
2020-12-04 18:05:47 +01:00
Ivar Andreas Bonsaksen 9029fff59d
Fixed #9993 (false positive: misra-c2012-9.2) (#2908) 2020-11-18 10:50:35 +01:00
Ivar Andreas Bonsaksen 0e7ec1eddf
Fixed #9988 (false positive: misra-c2012-9.2) (#2904) 2020-11-16 17:31:00 +01:00
kskjerve 4d3f76b63c
MISRA rule 9.2 The initializer for an aggregate or union shall be enclosed in braces (#2899) 2020-11-16 09:27:17 +01:00
Daniel Marjamäki 43c4a48d48 Fixed #9971 (missing system includes in addon/test test files) 2020-11-15 12:46:28 +01:00
Daniel Marjamäki 9a81d17a58 cppcheckdata: Add Scope.varlist 2020-11-13 21:03:02 +01:00
Daniel Marjamäki c7f816f986 Misra refactorings 2020-11-13 07:21:34 +01:00
Lars Even Almaas 3a91b998d6
MISRA rule 10.2 Expressions of essentially character type in additions and subtraction (#2897) 2020-11-12 11:37:28 +01:00
Daniel Marjamäki 2ae91b9ffe Try to fix addon suppressions tests 2020-11-11 20:28:26 +01:00
Daniel Marjamäki 1ce78a1086 Addons: handle inline suppressions internally in cppcheckdata 2020-11-11 20:01:58 +01:00
Daniel Marjamäki 7e8839a991 Addons: Reuse cppcheckdata.simpleMatch 2020-11-11 14:24:55 +01:00
Lars Even Almaas 9d70926fcd
MISRA rule 15.4 Only one break/goto from iteration statement (#2892) 2020-11-09 15:11:08 +01:00
Georgy Komarov 9cbb09076c
misra.py: Fix R7.2 crash on va_args (#2886) 2020-11-05 23:54:12 +01:00
Lars Even Almaas c1212f823f
MISRA rule 7.2 Require 'u' prefix when using large unsigned integer constants (#2881) 2020-11-05 13:38:09 +01:00
Georgy Komarov 6f7f508967
misra.py: Fix 7.4 false positive (#2883)
Fix false positives for the function calls with "const pointer to const
value" arguments: https://trac.cppcheck.net/ticket/9967.

The variable.valueType.constness have same encoding as encoding as
ValueType::constness in Cppcheck.
2020-11-05 08:13:23 +01:00
Lars Even Almaas 05b804d126
MISRA Rule 7.4 Check if variables assigned as string literals are const (#2866) 2020-11-04 13:45:02 +01:00
Georgy Komarov b87aaaac52
Fix and impove MISRA 6.1 and 6.2 rules (#2863) 2020-10-28 20:54:43 +01:00
Lars Even Almaas 79b9dd5345
MISRA Rule 6.1/6.2 Bit field check (#2861) 2020-10-27 16:00:19 +01:00
amai2012 2fa837c716
threadsafety shall not warn about const vars (in C++11) (#2847)
threadsafety shall not warn about const vars (in C++11) 
For C++03 a new id threadsafety-const was created.
2020-10-23 11:58:25 +02:00
Georgy Komarov 3944e70e02
misra.py: Treat enum constants as constant known at compile time (#2823)
C89 standard defines enum members as enumeration contants at ch.
6.4.4.3, and they are always known at compile time.

This commit fix false positives for rule 18.8 (and possible other rules
that check "constentess") with enumeration members.

Fix Trac#9913
2020-09-25 21:02:34 +02:00
Daniel Marjamäki 687b44dbb7 Token: add flag for splitted variable declaration with initialization 2020-09-09 16:22:47 +02:00
Daniel Marjamäki 6e4085f3d8 Misra: Write 12.3 warnings in structs/classes 2020-09-08 09:29:57 +02:00
Daniel Marjamäki f3fa7a6f5e misra: updated test addons/test/misra/misra-test.cpp 2020-09-06 13:25:37 +02:00
Daniel Marjamäki 9a943e7616 misra: rewrote rule 12.3 2020-09-06 11:33:37 +02:00
Daniel Marjamäki 7969bf7ae8 Token: Add 'isSplittedVarDecl attribute 2020-09-06 11:02:22 +02:00
Georgy Komarov 4738da3d69
misra.py: Fix R12.3 FP on calling functions in function arguments (#2778) 2020-09-05 07:53:56 +02:00
Georgy Komarov e21bdb985c
misra.py: Fix 12.3 FP for variables defined in headers (#2773)
When we include the header file with variables definitions, Cppcheck
will write `variables` entries with line numbers from the header to the
dump file.

If the line number in the header file and the source file are equal,
misra.py performs an additional check what leads to false positives.

Minimal example that demonstrates the problem:

`misra_fp.c`:
```c
void test_12_3_fp(void)
{
    //Initialize the events queue
    QEQueue_init(&me->deferred_event_queue, me->deferred_events_queue_buf, Q_DIM(me->deferred_events_queue_buf));
}
```

`misra_fp.h`:
```c

static const uint32_t timer_max_blocking_call_us;
```

This commit closes trac ticket 9874.
2020-09-04 20:58:32 +02:00
Daniel Marjamäki c6d2e0fae1 Fixed #9830 (Addons should return 0 when success) 2020-08-29 07:44:32 +02:00
Georgy Komarov 3bae716fd4
misra.py: Fix 20.7 false positive for multi-character arguments
See: https://trac.cppcheck.net/ticket/9633#comment:3
2020-08-08 13:03:19 +03:00
Georgy Komarov dc1faa71ed
misra.py: Fix false negatives in string concatenation for rule 20.7
This will fix Trac#9633
2020-07-24 07:15:40 +03:00
Georgy Komarov fc504ed6c3
misra.py: Fix false positives on macro expansion
This will fix Trac#9634
2020-07-21 20:03:04 +03:00
Richard A. Smith 41a846d8a7 misra.py: Squelch duplicate violation messages
When checking multiple files if the same violation is encountered from
an included file then the violation is both displayed and counted in the
error summary.

Track each violation by location and error number and if the violation
has been previously encountered then do not report it again.
2020-07-19 08:42:35 -03:00
Daniel Marjamäki 33388217a5 new default branch is main 2020-06-15 20:04:57 +02:00
Carl-Oskar Larsson 2abf542838
Misra severity (#2674) 2020-06-08 15:58:17 +02:00
Georgy Komarov 90550d24c4
misra.py: Fix crash on volatile macro argument (#2654) 2020-05-21 08:34:28 +02:00