36

Improve your C++ code in KDevelop with Clang-Tidy

 5 years ago
source link: https://www.tuicool.com/articles/hit/QJb6nm6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

You might be aware of Clang-Tidy , the clang-based C++ “linter” tool which allows static analysis of your code, including fixing it automatically where possible.

And you remember the introduction of the “Analyzer run mode” with version 5.1 of KDevelop , the extensible cross-platform IDE for C, C++, Python, PHP and other languages.

While development of a separate KDevelop plugin for the integration of Clang-Tidy was started in 2016, named kdev-clang-tidy , activity stalled after some time, with other things in life to do.

One good thing about Copyleft software is that where somebody left others can pick up and continue: with Clang-Tidy getting more and more useful, there has been new motivation to have such integration with KDevelop, and after some bits of code pushing here we are now, looking at the first released versions of kdev-clang-tidy with basic functionality, which already helped to improve some code bases.

The latest release 0.3.0 enables KDevelop users to do this:

  • running clang-tidy on a single file, subdirectories or the whole project, with the result shown in the Problems tool view, invokable from file context menus and main menu (Analyzer section)
  • per-project config UI:
    • free field for additional command line parameters to clang-tidy
    • checkbox whether to include system headers in the check
    • toggle between using .clang-tidy files or options in the config UI:
      • header filter regular expression
      • opt-in list of checks

See kdev-clang-tidy 0.3.0 in activity in some screenshots, here with KDevelop 5.3 pre-beta:

ERVnei2.png!web Configure Clang-Tidy globally Ej6jIrv.png!web Configure Clang-Tidy for a project RruMjyM.png!web Running Clang-Tidy on a subdirectory of a project (here the Clazy integration plugin part of upcoming KDevelop 5.3)

(And yes, in the screenshots one can spot upcoming support for another static code analyzer, clazy, which will be shipped as part of upcoming KDevelop 5.3, more on that soon in another blog post)

The current version 0.3.0 of kdev-clang-tidy can be built against the versions 5.2, upcoming 5.3 and the current development branch (master) of KDevelop.

Learn more about the kdev-clang-tidy plugin from its README.md file, e.g. how to build it, how to package it, how to use it, where to report issues, and what the planned roadmap is.

The latest released kdev-clang-tidy version is currently also included in the Nightly AppImage builds of the current stable KDevelop code version (which already switched to the 5.3 branch).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK