Commit Graph

1197 Commits

Author SHA1 Message Date
chrchr-github 033cf64961
Avoid const_cast (#5490) 2023-09-28 18:20:43 +02:00
Oliver Stöneberg 3fd00c19df
perform logging in `CmdLineParser` through an interface (#5478)
This is in preparation of avoiding accessing `std::cout` directly as
well as streamlining and improving the logging during the settings
parsing. There are no functional changes yet.
2023-09-25 13:43:18 +02:00
Oliver Stöneberg f49fedb2ad
fixed #11483 (FN unusedFunction for method with inline implementation) (#5457)
Co-authored-by: chrchr-github <78114321+chrchr-github@users.noreply.github.com>
2023-09-20 14:45:44 +02:00
Oliver Stöneberg a43b55a0ca
Improved addon execution errorhandling (#5451) 2023-09-20 10:40:57 +02:00
Daniel Marjamäki 3089fc393b
Fix #12002 (Filelister: Unclear error 'finding files failed (error: 3)') (#5460) 2023-09-19 15:36:34 +02:00
Daniel Marjamäki 79e8735d1a
cli: update --help output, premium has full cert c++ coverage (#5450) 2023-09-14 15:59:06 +02:00
Oliver Stöneberg 98ce46a3e5
fixed #11919 - Removed deprecated command-line options `--template <template>` and `--template-format=<template>` (#5439) 2023-09-12 22:46:40 +02:00
Oliver Stöneberg 64cd09ab62
fixed #11917 (Default to `native` platform in Windows builds) (#5428) 2023-09-11 11:08:23 +02:00
Daniel Marjamäki 4fa1c7d5f9
2.12.99: Set versions (#5427) 2023-09-10 18:43:00 +02:00
Oliver Stöneberg 91070ca794
utils.h: added `startsWith()` and started using it (#5381)
This makes the code much more readable. It also makes it less prone to
errors because we do not need to specify the length of the string to
match and the returnvalue is clear.

The code with the bad returnvalue check was never executed and I added a
test to show that.
2023-09-08 19:30:25 +02:00
Daniel Marjamäki 4739ac8416 Update copyright year 2023-09-06 15:51:05 +02:00
Oliver Stöneberg ce780177b2
fixed #11910 - removed Visual Studio x86 targets from project files and builds from CI (#5397)
Windows XP Pro x64 was released on April 25, 2005 and consumer
processors supporting x86-64 have been around almost as long. Although
there are still 32-bit Windows images available there is not much of a
point maintaining support for these. We also never did any x86 builds
for non-Windows platforms in CI so we don't even know if we work on
those. You might still be able to build 32-bit binaries via CMake.
2023-09-04 19:40:13 +02:00
Daniel Marjamäki 44c149e51b
Fix #11897 (Safety: show what checks are enabled/disabled) (#5378)
This primarily adds the corresponding report in the GUI that we have in
the command line already
2023-08-31 18:28:47 +02:00
Oliver Stöneberg ad1caa8100
report `internalError` when command execution returns errorcode / also some related cleanups and tests (#5037)
Encountered while investigating https://trac.cppcheck.net/ticket/11708.

This has been like this since the introduction of `internalError` in
b6bcdf2936 (almost ten years ago to the
day). Logging internal errors which bail out(!) of the analysis simply
to `std::cout` for them possibly never to be seen (and also not affected
the exitcode) is pretty bad IMO. They should always be visible.

I also removed the filename from the message as it is already available
(and thus redundant) and its existence should be defined by the
template.
2023-08-31 13:33:29 +02:00
Daniel Marjamäki 276f017fbe
Partial fix for #11897 (Safety: show what checks are enabled/disabled) (#5372)
Example output on stdout:
```
$ ./cppcheck m1.cpp 
Checking m1.cpp ...
Active checkers: 59/177
```
2023-08-29 12:00:52 +02:00
Oliver Stöneberg 499f566e9d
got rid of duplicated file/directory existence implementations / improved errorhandling and testing of `FileLister` (#5350) 2023-08-23 11:22:41 +02:00
Oliver Stöneberg 0901e496ed
refs #3450 (CLI --report-progress is currently useless) - added `--report-progress=<val>` to specify interval (#5353) 2023-08-23 11:20:20 +02:00
Daniel Marjamäki e35d5d3ceb
Fix #11882 (add --premium=misra-c-2023 option) (#5363) 2023-08-23 10:28:02 +02:00
Oliver Stöneberg 59c3bd22e6
ProcessExecutor: removed unnecessary `\0` passing in message reading/writing - fixes stray `\0` characters in output (#5354)
This was introduced in #5279. We were transferring the terminating `\0`
via the pipe and also added another one in the parsing. As we are now
directly writing into a `std::string` these extra characters will now
show up in it. So just get rid of them.
2023-08-21 12:17:08 +02:00
Oliver Stöneberg c7f88db90a
CmdLineParser: deprecated `--template <template>` and `--template-location <template>` (#5331)
Both are bugprone since they just take the next parameter which doesn't
start with `-`.

Also `--template` has not been documented since
17842394c0 back in 2011(!). And
`--template-location` has never been documented since its induction in
f058d9ad08. That's also why we can have a
short deprecation period.
2023-08-18 11:59:14 +02:00
Oliver Stöneberg 33dee83c21
moved suppression-specific code out of `ErrorLogger` (#5329) 2023-08-18 11:55:23 +02:00
Oliver Stöneberg 84a9b3a5f2
enabled and mitigated `modernize-use-equals-default` clang-tidy warnings / removed unnecessary default destructors (#5335) 2023-08-16 17:13:36 +02:00
chrchr-github 8b309a8829
Use readdir() instead of deprecated readdir_r() (#5330) 2023-08-16 10:20:53 +02:00
Ryan M. Lederman d064f9c243
-j 0 causes indefinite hang. require >= 1 (#5326)
In cppcheck 2.11.1 (macOS), using `-j 0` actually causes cppcheck to do
nothing–it stalls indefinitely.

I could only find one place where `mSettings.jobs` was validated against
> 0 and it's simply an assert, so you wouldn't hit it in a release
build.

- Require -j >= 1 
- Cap -j at 1024, not 10000  (I don't even know what would happen if
you created 10,000 threads, but nothing good; likely exhaust virtual
memory or grind the process to a halt). 1024 is still obscene but there
may be some hypercomputers out there that have that many logical cores.
2023-08-14 11:55:32 +02:00
Oliver Stöneberg d076da8f7c
added missing `__GNUC__` define for selfcheck (#5324)
This was causing some code not to be enabled in the selfchecks leading
to some missing warnings.
2023-08-14 10:29:04 +02:00
Oliver Stöneberg 5371455606
optimized pipe writing/reading and `ErrorMessage` serialization a bit (#5279) 2023-08-13 11:52:02 +02:00
Oliver Stöneberg f1749ab7ad
CppcheckExecutor: use dedicated ErrorLogger for printing error messages XML (#4985)
This starts to untangle the `ErrorLogger` implementation in
`CppcheckExecutor` which handles three different cases and makes things
unnecessarily complicated.
2023-08-08 22:58:02 +02:00
chrchr-github eee1221738
Use in-class initializers, default constructors, class -> struct (#4842) 2023-08-08 11:05:02 +02:00
Oliver Stöneberg 988edd24c2
TestSingleExecutor: test clang-tidy invocation (#5294) 2023-08-07 20:47:24 +02:00
Oliver Stöneberg cc592a6927
CppCheckExecutor: improved library loading error handling a bit (#5275) 2023-08-07 19:48:11 +02:00
Oliver Stöneberg a17f6e89d1
pass `Suppressions` separately from `const Settings` into executors (#5278) 2023-08-07 18:39:57 +02:00
Samuel Poláček de8b4150a8
Explicitly state that --verbose and --quiet can be used at the same time (#5259)
Just a little clarification.
2023-08-05 19:18:10 +02:00
Samuel Poláček b2511fb3ae
Check if --cppcheck-build-dir exists (#5254)
Cppcheck does not report that cppcheck build dir does not exist and also
does not report any write issues to the non-existent directory.

This means that cppcheck build dir is actually not used.

We should either create the directory or fail.
2023-08-04 17:38:43 +02:00
Oliver Stöneberg 45de338f1b
cleaned up includes based on include-what-you-use / iwyu.yml: updated to yet another distro to get the latest version and updated the Chaotic-AUR key (#5267)
This is a mess. The version is AUR is still outdated and also doesn't
install anymore. Fedora 38 carries the latest version of it so use that
now. Keep the old steps in case we need to switch again in the future.
2023-08-02 10:36:17 +02:00
Samuel Poláček ba764eaddc
unusedFunction disabled warning is not printed if --cppcheck-build-dir is used (#5252)
ususedFunction check is enabled if cppcheck build dir is used. Warning
about disabled unusedFunction check should not be printed in such case.
2023-07-25 12:00:23 +02:00
Daniel Marjamäki 55af68aaf7
Update type for Settings::checksMaxTime. (#5205)
It's a time offset not a size. It should not have value SIZE_MAX that
makes it ineffective (overflow in calculation of stop time).
2023-06-28 19:52:33 +02:00
chrchr-github 9259aea317
Fix #11762 Read failure in ProcessExecutor::handleRead() (#5196) 2023-06-27 15:41:05 +02:00
Daniel Marjamäki 557241ad71 2.11.99: Set versions 2023-06-22 13:50:51 +02:00
Daniel Marjamäki 3abe8eeca5 Update copyright year 2023-06-21 19:58:11 +02:00
chrchr-github bb962e2bc3
Enable and mitigate readability-else-after-return (#5175) 2023-06-20 18:43:21 +02:00
Long Radix c033c62190
Typos and stilistic updates (#5141) 2023-06-14 12:30:45 +02:00
chrchr-github fb850a844b
Use path to executable when trying to load library (#5082)
* Use path to executable when trying to load library

* Fix function call, add support for more OS, add test

* Format

* Handle MacOS

* Amend

* Argument as fallback

* Use Path::getCurrentExecutablePath()

* Move to cmdlineparser.cpp

* Debug output

* Use argv[0] in Cygwin

* Revert "Debug output"

This reverts commit 5a68d71f1d27549c7b4a46363f3cd5cd912018e7.

* Use native python in Cygwin
2023-05-26 06:55:36 +02:00
chrchr-github 78182d4773
Fix FN constVariablePointer (#5076)
* Fix FN constVariablePointer

* Fix FP

* Add const

* Fix tests

* Add const
2023-05-22 19:53:51 +02:00
chrchr-github 59b955e014
Suppress deprecation warning with -E (#5050) 2023-05-11 14:35:56 +02:00
Daniel Marjamäki e1d5d9988d
Fixed #11715 (Add --showtime=file-total option to show checking time of each file) (#5049) 2023-05-11 14:04:22 +02:00
Oliver Stöneberg b5ce2c708b
SingleExecutor: process markup files after code when scanning projects (#4972)
* SingleExecutor: added TODOs

* test `SingleExecutor` with files and project

* SingleExecutor: process markup files after code when scanning project

* TestSingleExecutor: generate scoped files before calling executor

* CI-unixish.yml: added `--output-on-failure` to CTest call

* helpers.cpp: improved error reporting in `~ScopedFile()`

* use unique filenames in executor tests to avoid collisions

* fixed `functionStatic` selfcheck warnings
2023-05-03 17:32:28 +02:00
Daniel Marjamäki 07b802fd2a
File lister: Fix possible resource leaks (#5031)
Trac ticket created: #11703

Found by Coverity: CID 1474932
2023-05-03 16:23:07 +02:00
Daniel Marjamäki 46b9d4ec61
Fixed #11700 (Markup support is broken, unused function false positives) (#5025) 2023-05-03 11:19:13 +02:00
Daniel Marjamäki d5fbd552a6
Refactoring: Break out loadLibraries() function. (#5024)
No functional change is intended.

This is a preparation to make qml handling work again
2023-05-01 14:41:14 +02:00
Oliver Stöneberg 5a2c31a41c
CmdLineParser: pass suppressions separately from settings (#5023) 2023-04-30 20:56:54 +02:00
Oliver Stöneberg 8cf6a22ea3
cleaned up includes based on `include-what-you-use` (#5021) 2023-04-30 07:33:19 +02:00
Oliver Stöneberg b3016f01a1
fixed some CLion inspection warnings (#4688)
* fixed some CLion "Unused global declaration" warnings

* fixed some CLion "Not implemented function" warnings

* fixed some CLion "Unused struct" warnings

* added TODO

* removed unused parameter reported by CLion

* fixed some CLion "Unused macro" warnings

* fixed some CLion "Condition is always true" warnings and a CLion "The value is never used" warning
2023-04-28 16:02:41 +02:00
Oliver Stöneberg 6eae4e71f6
make sure executors are only used in the intended context / `TestSuppressions` cleanups (#4963)
* added asserts to make sure executors are only used in the intended context

* TestSuppressions: specify proper job counts in `checkSuppression*()`

* TestSuppressions: enabled all asserts in `runChecks()`

* TestSuppressions: removed unnecessary setting from `checkSuppression()`

* TestSuppressions: small cleanup in the way tests are called

* TestSuppressions: use `SingleExecutor`
2023-04-28 12:41:53 +02:00
Oliver Stöneberg 9ad26f51e8
removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()` (#4967)
* made `CppCheck::getErrorMessages()` static

* removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()`
2023-04-16 13:54:21 +02:00
Daniel Marjamäki 7726a5b5b3
Add a --check-level option (#4942) 2023-04-09 13:48:13 +02:00
Oliver Stöneberg f5e51eace7
do not use string-to-integer conversions without error handling (#4906) 2023-04-08 22:29:09 +02:00
Oliver Stöneberg cfca3a69a2
optimized template string substitutions a bit (#4840) 2023-04-08 22:19:52 +02:00
Oliver Stöneberg 1f2b49142e
extracted single job execution into `SingleExecutor` / improved testing / do not unconditionally apply colors to output (#4882)
* added `Settings::useSingleJob()` and use it instead of checking `jobs` or `jointSuppressionReport`

* extracted single job execution into `SingleExecutor`

* moved `reportStatus()` from `CppCheckExecutor` to Èxecutor

* TestSingleExecutor: improved tests

* added testing of markup extension handling in executors

* cleaned up includes based on `include-what-you-use`

* testsingleexecutor.cpp: suppress `performance-unnecessary-value-param` clang-tidy warnings

* ProcessExecutor: send color via pipe instead of applying it beforehand

* do not unconditionally apply colors to output / disable all colors in tests / adjusted tests for changed output behavior

* fixed precision loss in `Executor::reportStatus()`

* fixed `naming-varname` selfcheck warnings
2023-04-08 18:06:38 +02:00
Oliver Stöneberg 5be8eee943
iwyu.yml: use a distro which has the latest `include-what-you-use` / enabled Qt mappings / cleaned up includes (#4885) 2023-04-08 16:08:47 +02:00
Daniel Marjamäki 89a95ddc8f --performance-valueflow-max-if-count: review comments 2023-04-08 13:07:28 +02:00
Daniel Marjamäki 2359b9ff82 valueflow: limit valueflow in functions that have many ifs 2023-04-01 20:58:15 +02:00
Oliver Stöneberg 5ec0ad6bed
use `ccache` for sanitizer builds / do not use precompiled headers with `ccache` (#4910)
* added CMake option `DISABLE_DMAKE` to disable `run-dmake` dependencies

* tools/CMakeLists.txt: added TODO

* use `ccache` for sanitizer builds

* aligned selfcheck between sanitizer workflows and disabled some currently unnecessary steps

* CI-unixish.yml: do not use precompiled headers with `ccache`
2023-04-01 09:40:10 +02:00
Paul Fultz II 7231d1cece
Update the isVariableChanged to correctly check the const bit (#4912) 2023-03-26 15:12:49 +02:00
Oliver Stöneberg 8148095fe5
cmdlineparser.cpp: fixed compilation (#4880) 2023-03-10 00:39:29 +01:00
Oliver Stöneberg 2c05281a31
ThreadExecutor: refactoring in preparation of sharing code (#4870) 2023-03-09 20:08:39 +01:00
Oliver Stöneberg 30131837b5
refs #11603 - deprecated `--enable=information` implicitly enabling `missingInclude` (#4865) 2023-03-09 20:04:20 +01:00
Oliver Stöneberg 87d9c8fbc5
fixed #9590 - ProcessExecutor: read the process pipe until we have all the expected data / greatly improved error handling (#4859) 2023-03-07 12:25:49 +01:00
Oliver Stöneberg d17e804235
made `CmdLineParser::mSettings` a reference (#4855) 2023-03-07 12:11:21 +01:00
Oleksandr Redko 0719a57ca8
cli: correct typo in help message (#4862) 2023-03-06 11:25:07 +01:00
Oliver Stöneberg ad6c5d80ff
removed unused `ErrorLogger::reportInfo()` / small `*Executor` cleanup (#4852) 2023-03-04 17:29:34 +01:00
Daniel Marjamäki 340baf10cd
Adjust version 2.11.99 => 2.10.99 (#4851) 2023-03-04 17:19:31 +01:00
Oliver Stöneberg a00b6e1f8a
simplified `ThreadExecutor` class by moving some code out of it / fixed some thread safety issues (#4849) 2023-03-04 12:05:17 +01:00
Oliver Stöneberg 7fd4118d60
Fix #10039 (integrate `--check-config` include findings with normal analysis) / also fixes #11283 (#3229) 2023-03-04 09:02:35 +01:00
Oliver Stöneberg 0ec2d84f1a
optimized suppression lookups a bit when no suppressions exist (#4839) 2023-03-03 18:37:09 +01:00
Oliver Stöneberg 5af6ca6637
made `Platform` a member of `Settings` instead of inheriting from it / cleanups (#4791) 2023-03-03 18:36:27 +01:00
Oliver Stöneberg b70e1d5461
avoid some unchecked pointer dereferences (#4811) 2023-03-02 22:05:41 +01:00
Oliver Stöneberg bd1ae69b00
cleaned up includes based on `include-what-you-use` (#4599) 2023-03-02 21:50:14 +01:00
Oliver Stöneberg 8f5f06add7
some `Tokenizer` construction and related other cleanups (#4799) 2023-03-02 21:48:14 +01:00
Oliver Stöneberg a846bc2d99
added precompiled header for `cli` (#4779) 2023-02-08 21:11:11 +01:00
Oliver Stöneberg 8ef14dad98
fixed and enabled `performance-faster-string-find` clang-tidy warning (#4769) 2023-02-08 21:01:51 +01:00
Oliver Stöneberg 14e78e1800
greatly improved error handling in Cppcheck project file parsing / some cleanups (#4752) 2023-02-08 20:30:43 +01:00
Oliver Stöneberg 1a460d7bc0
bumped version to 2.11 (#4751) 2023-01-29 15:18:22 +01:00
Daniel Marjamäki 464fbe8d53 Update copyright year 2023-01-28 10:16:34 +01:00
Oliver Stöneberg f16ffd88e9
deprecate non-`native` platform being used by default in Windows builds (#4734)
* deprecate non-`native` platform being used by default in Windows builds

* test-helloworld.py: avoid deprecation warnings
2023-01-27 10:46:48 +01:00
Oliver Stöneberg fd15811215
de-coupled `--check-library` from `information` severity and other dependencies (#3861) 2023-01-26 22:28:04 +01:00
Oliver Stöneberg a0b1285f4a
added CMake option `BUILD_CORE_DLL` to build lib as `cppcheck-core.dll` with Visual Studio (#4733) 2023-01-26 22:13:07 +01:00
Oliver Stöneberg e5572835c0
fixed `platforms` lookup / set proper platform type for `unix32-unsigned` and `unix64-unsigned` / copy `platforms` in CMake (#4464) 2023-01-26 22:05:40 +01:00
Oliver Stöneberg 41849b1a78
generate `*.vcxproj` file lists with `dmake` (#4652) 2023-01-21 11:55:36 +01:00
Oliver Stöneberg 38abeccd24
added command-line option `--disable=<id>` to disable individual checks (#4712) 2023-01-21 10:39:44 +01:00
chrchr-github 50d297b309
Enable useStlAlgorithm in selfcheck (#4725) 2023-01-17 20:48:26 +01:00
Oliver Stöneberg 124668979c
replaced some `std::ostringstream` usage with `std::to_string()` (#4719) 2023-01-16 22:05:33 +01:00
Oliver Stöneberg 0c95971c54
added .gitattributes and normalized files (#4668) 2022-12-30 21:33:45 +01:00
Oliver Stöneberg d3a2cdc26c
converted (undocumented) define `MAXTIME` into (undocumented) command-line options `--checks-max-time=`, `--template-max-time=` and `--typedef-max-time=` (#4661) 2022-12-30 21:21:05 +01:00
Oliver Stöneberg 1cfe49e340
use `const_iterator` where possible (#4662) 2022-12-30 15:13:47 +01:00
Oliver Stöneberg b380fd2589
added command-line option `--valueflow-max-iterations` to control amount of valueflow iterations / also log debug warning when iterations are being exceeded (#4557) 2022-12-20 20:51:08 +01:00
Oliver Stöneberg 3c68b9b29f
use `cbegin()` and `cend()` with `const_ierator` loops (#4658) 2022-12-20 20:32:16 +01:00
Oliver Stöneberg 2cd8bb94e4
some small `CmdLineParser` cleanups and improvements (#4654) 2022-12-19 22:28:36 +01:00
Oliver Stöneberg 29e0133cb5
extracted `FwdAnalysis` from `astutils.{cpp|h}` (#4637)
* added missing filtering offiles in Visual Studio project

* extracted `FwdAnalysis` from `astutils.{cpp|h}`
2022-12-13 22:29:23 +01:00
Oliver Stöneberg 40a69e5afb
optimized deserializing of `ErrorMessage` and related main process code (#4610) 2022-12-09 19:34:51 +01:00
Oliver Stöneberg 4103d05c7f
improved `ErrorMessage::deserialize()` error messages (#4617) 2022-12-07 18:00:45 +01:00