Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » [PROPOSAL] CppCheck support
[PROPOSAL] CppCheck support [message #59544] Sun, 22 January 2023 18:00 Go to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

I've been using CppCheck for a long time, and found it very useful. It is a very popular free static analyzer tool with lots of features and it is easy to integrate.

While its own parser is very good, it also provides an experimental clang AST backend, so it is very flexible.

I am currently integrating it with theIDE, and the integration is very smooth. So I am proposing to add cppcheck support to TheIDE.

My Plan is to make it available to public before U++ 2023 1, in a usable/stable state.

What it requires.

0. CppCheck binary.
1. A single file in TheIDE's codebase (CppCheck.cpp)
2. Detection of CppCheck binary (HasCppCheck() function)
3. A settings pane, in theIDE's settings dialog (will be available only if the binary is detected).
4. Color entries in (Settings/Syntax Highligting pane) for CppCheck error severity types (style, warning, performance, portability, etc.)

5. It will have the ability to check
a) A single file
b) A package
c) Workspace (all packages)
This will require adding menu and toolbar entries when cppcheck binary is detected.
(Similar to existing "Compile $FILENAME" or "Build $PACKAGE" entries -> "Analyze $PACKAGE)

See the below screenshot for a working version (initial)

index.php?t=getfile&id=6767&private=0


I will create a branch (theide_cppcheck) in my fork of upp and make the source code available so others can participate.

What do you think?


Best regards
Oblivion,





Re: [PROPOSAL] CppCheck support [message #59545 is a reply to message #59544] Mon, 23 January 2023 08:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you Oblivion

I would like to have it.


Best regards
Iñaki
Re: [PROPOSAL] CppCheck support [message #59557 is a reply to message #59544] Sat, 04 February 2023 11:54 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello,

The initial linter (cppcheck) support has landed in my fork of U++, under ide_linter branch.

The basic functionality is there. It is tested on Linux. Windows exe detection will be availble tomorrow, so as of today it only supports Linux.

DONE
+ Check file, package, project (all) commands.
+ TheIDe linter keyboard shortcuts for check file, package, and project commands.
+ TheIDE linter setup pane in Setup dialog.
+ Ability to select severity message types.
+ Core configuration settings (language, standard, platform, etc.)

TODO:
- Add Windows cppcheck executable detection.
- Add configurable cppcheck build dir path (to speed-up analysis)
- Add library file support.
- Add Package/File list menu entries.
- Add CLANG backend switch.
- Add the ability to pass additional command line options.
- Filter out non C/C++ files (*.tpp, *.log, etc).


To make it less intrusive, I have put it into its own package under ide (ide/Linter).

I'll add a more detailed overview tomorrow.

Reviews, patches, suggestions and testing is welcome.

Best regards,
Oblivion



Re: [PROPOSAL] CppCheck support [message #59558 is a reply to message #59557] Sat, 04 February 2023 13:38 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Oblivion,

Downloaded your branch.

Works great. I was waiting for This feature.


Warm Regards

Deepak
Re: [PROPOSAL] CppCheck support [message #59559 is a reply to message #59558] Sat, 04 February 2023 21:10 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Oblivion,

I like the idea to addlinter support for TheIDE, however I am not sure we should go for cppcheck. When I used it in the past, the tool had some problems like false positives. Also, the decision to relay on this particular one in the main code base is very difficult. We have very good alternatives such as clang-tidy and the true thing is that we are now basing on clang ecosystem like never before. With the usage of libclang and recent clang-format integration.

What about creating plugin system for TheIDE to allowing creation of extensions? Thanks to that there will be possible to support multiple linters. I understand that it will require a lot of work, but in the long term it is the way to go.

Klugier


U++ - one framework to rule them all.
Re: [PROPOSAL] CppCheck support [message #59560 is a reply to message #59559] Sat, 04 February 2023 22:05 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Klugier,

Quote:
Hello Oblivion,

I like the idea to addlinter support for TheIDE, however I am not sure we should go for cppcheck. When I used it in the past, the tool had some problems like false positives. Also, the decision to relay on this particular one in the main code base is very difficult. We have very good alternatives such as clang-tidy and the true thing is that we are now basing on clang ecosystem like never before. With the usage of libclang and recent clang-format integration.

What about creating plugin system for TheIDE to allowing creation of extensions? Thanks to that there will be possible to support multiple linters. I understand that it will require a lot of work, but in the long term it is the way to go.

Klugier


Thank you very much for your comments.

CppCheck has matured nicely. Yes, it occasionaly gives false positives, but so does clang-tidy. Not to mention cppcheck is famous for catching *interesting* issues where other solutions fail.
The main reason why I opt for cppcheck is:

It is extremely simple to integrate and remove.
a) The ide/Linter package is almost self-contained package in the sense that there are only several Lines of code (7 lines of code in cpp files, and one line of code in ide.h: only menu entries, and config stuff) in TheIde's codebase.
IMO that's not much of a maintenanca burden. Removing it completely from the codebase if required won't take more than 15 seconds.
b) It uses it's own config file (JSON), meaning it does not mess with TheIDE's config file.
c) Implementation does not have to rely on low level, raw stuff, so future changes won't really break it unless U++ somehow gets broken.
d) It is activated only if the cppcheck executable is found.

If you look closely to the linter package, you'll notice that the main class (Linter) is actually an abstraction.
This is a stripped down version of my own linters system (I use a commercial solution besides cppcheck).
Hence the name is Linter, not CppCheck. We can definitely (re)add clang-tidy later.

As for the plugin system:
Writing a plugin system has always been a good idea, given that I intend to participate more in TheIDE's development this year, I'll likely look into it.

Best regards,
Oblivion






[Updated on: Sat, 04 February 2023 22:22]

Report message to a moderator

Re: [PROPOSAL] CppCheck support [message #59561 is a reply to message #59559] Sun, 05 February 2023 00:26 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
By the way,

I decided to re-implement clang-tidy support in Linter package too. Lets have both. Smile
First version will likely be available next weekend.

Best regards,
Oblivion


[Updated on: Sun, 05 February 2023 00:29]

Report message to a moderator

Re: [PROPOSAL] CppCheck support [message #59564 is a reply to message #59544] Sun, 05 February 2023 15:08 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

ide/Linter package now supports Windows too.
If you download the official cppcheck executable, theIde should detect it.


Best regards,
Oblivion


Re: [PROPOSAL] CppCheck support [message #59597 is a reply to message #59544] Sat, 11 February 2023 23:55 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

TheIde/Linter (Cppcheck) has made some more progress.

+ CppCheck library files support is enabled.
+ CppCheck plugins support is enabled.
+ Additional command line options can now be passed manually, via setup dialog. (If needed)
+ U++ X11 (NOGTK) backend crash fixed on linux.


Note that, cppcheck library files (configurable checkers) are a powerful and nice way to allow cppcheck to recognize external libraries' (U++, GTK, QT, etc.) stuff (functions, etc.) Now it is enabled. ide/Linter will now check for .cfg files under a user-configurable path.

Similarly, 3rd party plugins for cppcheck can now be enabled.

Best regards,
Oblivion


Re: [PROPOSAL] CppCheck support [message #59797 is a reply to message #59544] Wed, 19 April 2023 00:06 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

Experimental CppCheck branch of my U++ fork is updated.

Changes:
Configuration dialog is redesigned.
Ability to select individual libraries and addons.


Screenshot:
index.php?t=getfile&id=6800&private=0

Best regards,
Oblivion



Re: [PROPOSAL] CppCheck support [message #59809 is a reply to message #59544] Thu, 20 April 2023 21:40 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

Experimenal linter package for TheIDE is updated.

This is a big update since the package is now reimplemented as a generic framework for interfacing with command-line-driven static analysis tools.

Accordingly, CppCheck interface is reimplemented as a linter module.I've added the essential API docs.
It is now possible to add multiple linters easily. (Meaning that clang-tidy module is on its way.)

Also, cppcheck module can now display verbose messages and inconclusive results.

DONE & TODO List:

+ Linter package: Redesigned as a framework to utilize multiple command-line-driven static analysis tools.
+ Linter package: Added initial API docs for implmenting linter modules.
+ CppCheck module: Re-implemented as a linter module.
+ CppCheck module: Can now show verbose messages.
+ CppCheck module: Can now show inconclusive results.
+ CppCheck module: Filtering out non C/C++ files and directories (*.tpp, *.log, etc).

TODO:
- CppCheck module: Add configurable build dir path (to speed-up analysis).
- CppCheck module: Add CLANG backend switch to CppCheck module.
- CppCheck module: Allow per-project configuration file.
- Linter package: Add a mechanism to switch between linter modules on-the-fly.
- Linter package: Add a clang-tidy module.


You can download the code from this address.

Any questions, suggestions, bug reports, etc. are welcome.

Best regards,
Oblivion



[Updated on: Thu, 20 April 2023 21:42]

Report message to a moderator

Re: [PROPOSAL] CppCheck support [message #59817 is a reply to message #59544] Sun, 23 April 2023 18:14 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,

Last round of updates for this week:

CppCheck module: Now allows per-project configuration files.
Configuration files (json) are stored in cppcheck folder, under the upp's config directory.
And they are automatically loaded when the linter is invoked.
Format of the name of each config file is [name of the main package]-cppcheck.json.



Code can be found here.

Best regards,
Oblivion


[Updated on: Sun, 23 April 2023 18:16]

Report message to a moderator

Re: [PROPOSAL] CppCheck support [message #59831 is a reply to message #59544] Sat, 29 April 2023 13:36 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hi,


A round of weekly updates to the experimental TheIDe/Linter framework:


+ Linter package: Linter package is now a compile-time option, using the LINTER flag.
+ Linter package: Footprint in TheIDE's source code is further narrowed down.
+ Linter package: A module registration mechanism is implemented.
+ Linter package: Added a mechanism to switch between available linter modules on-the-fly.



Now the registered modules that have a valid/installed backend will appear in the menu and can be selected by the user.

Since now the module registration and selection is implemented, it is time to send a pull request for review and start implementing clang-tidy module.

Any questions, reviews, testing, help is welcome.

Best regards,
Oblivion


[Updated on: Sat, 29 April 2023 13:38]

Report message to a moderator

Previous Topic: Assiste symbol information about
Next Topic: Should be an easy one: could we turn word wrapping on in the log view?
Goto Forum:
  


Current Time: Thu Mar 28 23:30:22 CET 2024

Total time taken to generate the page: 0.01053 seconds