Commit Graph

478 Commits

Author SHA1 Message Date
Oliver Stöneberg 30ca8e11b5
moved `Language` from `settings.h` to `standards.h` (#5854) 2024-01-07 22:53:39 +01:00
Oliver Stöneberg bbd2b2aa83
cleaned up includes based on `include-what-you-use` (#5855) 2024-01-07 11:07:51 +01:00
Daniel Marjamäki 5aa1710dd0
Fix #12071 (Add safety mode that makes cppcheck more strict about critical errors) (#5777) 2023-12-18 18:26:23 +01:00
Daniel Marjamäki 2932ab7592
Revert "Fixed #12071 (suppressing critical error, no indication to user that analysis of file fails) (#5771)" (#5775)
This reverts commit 7c316fb76d.
2023-12-17 19:13:14 +01:00
Daniel Marjamäki 7c316fb76d
Fixed #12071 (suppressing critical error, no indication to user that analysis of file fails) (#5771) 2023-12-17 15:42:17 +01:00
Oliver Stöneberg f2622a673f
more cleanups in handling of ignored files (#5767) 2023-12-16 21:04:45 +01:00
olabetskyi 7191ed92b9
#12263: Constant Error 'missingInclude' (#5769)
Small adjustment of the log of the error.

- printed only when there was `--enabled=information` and no mentioning
of `missingInclude`
2023-12-16 18:38:30 +01:00
Oliver Stöneberg fcb41e2533
small cleanup of handling of ignored paths (#5757) 2023-12-14 16:55:42 +01:00
Daniel Marjamäki bc5023775d
Partial fix for #12254 (cppcheck.cfg can't be loaded from relative paths anymore) (#5760) 2023-12-13 06:53:03 +01:00
Oliver Stöneberg 7452e681dd
fixed #12221 - de-duplicate input source files (regression) (#5740) 2023-12-08 22:17:22 +01:00
Oliver Stöneberg 3272a2bbe7
greatly improved `Settings::loadCppcheckCfg()` error handling (#5712)
This also fixes the issue that `cppcheck.cfg` is no longer being loaded
from executable path. That was introduced by #5704.
2023-12-01 16:34:14 +01:00
Oliver Stöneberg 237bed8a91
CmdLineParser: made some options exclusive (#5704) 2023-12-01 14:19:47 +01:00
Oliver Stöneberg a937862a5d
CmdLineParser: return enum from `parseFromArgs()` instead of using additional member (#5698) 2023-11-27 12:06:03 +01:00
Oliver Stöneberg f2461781fd
added `xml.h` wrapper for TinyXML2 / cleaned up suppressions of Clang compiler warnings (#5700) 2023-11-26 14:04:35 +01:00
Oliver Stöneberg 8e1ae7e412
CmdLineParser: various refactorings and cleanups as well as testing improvements (#5676) 2023-11-25 21:12:24 +01:00
Oliver Stöneberg 4addad1643
moved settings-related code from `CppCheckExecutor` to `CmdLineParser` (#5672)
`CppCheckExecutor` contains some code which is not related to the
execution but actually to the creation of the settings. This is causing
inconsistencies in the error handling/logging as well as interfering
with the testability.
2023-11-19 19:45:10 +01:00
Oliver Stöneberg 2a15428096
fixed #12059 - added `--fsigned-char` and `--funsigned-char` command-line options (#5580) 2023-11-08 09:28:33 +01:00
Oliver Stöneberg df860a937d
do not explicitly load `windows.cfg` during command-line parsing (#5613)
As we now fail early on loading of all libraries we no longer need to
explicitly bail out on mandatory ones. This would have also caused
`libraries` and `library` to go out-of-sync and possibly lead to
duplicated loading of the library. It also allows for a
`CppCheckExecutor` to be made private.
2023-11-04 13:33:10 +01:00
Oliver Stöneberg ca6d1aafdb
moved `fileSettings` out of `Settings` (#5608)
Moved the `FileSettings` out of the `Settings` and pass them around
explicitly. They can never be specified at the same time and are used
exclusively. The code hasn't been fully adjusted to reflect this as this
is only the refactoring without any functional changes.
2023-11-03 23:24:04 +01:00
Oliver Stöneberg e6d15b17ff
extracted `FileSettings` from `ImportProject` to `filesettings.h` (#5604) 2023-11-02 17:42:41 +01:00
Oliver Stöneberg dd627a2b1d
moved `ImportProject` out of `Settings` and only store `fileSettings` (#5603)
`ImportProject` is not needed outside of the command-line parsing so we
do not need it inside the `Settings` at all. We only use the
`fileSettings` in the executors.
2023-11-01 21:08:30 +01:00
Oliver Stöneberg 7086ffaa1b
fixed #12045 - print error when using an option which has not been compiled in instead of treating it as non-existent or a no-op (#5508)
Also disabled more internal code around those options and did some
cleanups.
2023-10-21 09:12:59 +02:00
Oliver Stöneberg ebb877adcc
gui/platforms.h: renamed `Platform` to `PlatformData` / Platform: removed unnecessary `cppcheck` namespace (#5545) 2023-10-13 16:02:04 +02:00
Oliver Stöneberg 8c0d43d928
removed unnecessary encapsulation of severity enum and made it an `enum class` (#5541) 2023-10-12 11:58:39 +02:00
Oliver Stöneberg 7393083d5d
added `CmdLineLogger::printRaw()` / CppCheckExecutor: more `CmdLineLogger` usage (#5537) 2023-10-09 22:22:39 +02:00
Oliver Stöneberg 06b5ef1e4d
cleaned up includes based on include-what-you-use (#5532) 2023-10-09 10:07:20 +02:00
Oliver Stöneberg 3ba53c6b6a
fixed #12022 - disallow using `--project` with source files (#5515) 2023-10-08 09:07:15 +02:00
Oliver Stöneberg 5a52fa80fb
refs #12022 - disallow multiple `--project` options (#5499) 2023-10-05 21:36:44 +02:00
Oliver Stöneberg fc700b68eb
refs #4452 / refs #11705 - improved `--showtime=` behavior and testing (#4876)
This is a step onto leveraging the `ThreadExecutor` implementation for
`ProcessExecutor` which is a follow-up to #4870. We need to have the
proper test coverage and the existing implementations working as
expected before we move to the shared code.

Fixes:
- added `--showtime=` tests for all executor implementations
- only print `--showtime=summary` once at the end
- prevents `--showtime=` by multiple threads to be written at the same
time - essentially breaking the output
- reset the timer results before each test
- deprecated `top5` in favor of `top5_file`
- fixed printing for all executors except `ProcessExecutor`
2023-10-05 19:04:06 +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
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
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 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 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
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
chrchr-github eee1221738
Use in-class initializers, default constructors, class -> struct (#4842) 2023-08-08 11:05:02 +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 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