<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CI on KDE Blogs</title><link>https://blogs.kde.org/tags/ci/</link><description>Recent content in CI on KDE Blogs</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 26 Nov 2026 20:49:19 +0100</lastBuildDate><atom:link href="https://blogs.kde.org/tags/ci/index.xml" rel="self" type="application/rss+xml"/><item><title>CI: clang-tidy, clazy and compiler warnings in your merge requests</title><link>https://blogs.kde.org/2026/11/27/ci-clang-tidy-clazy-and-compiler-warnings-in-your-merge-requests/</link><pubDate>Fri, 27 Nov 2026 18:00:00 +0000</pubDate><author>Sebastian Englbrecht</author><guid>https://blogs.kde.org/2026/11/27/ci-clang-tidy-clazy-and-compiler-warnings-in-your-merge-requests/</guid><description>&lt;p&gt;Code hygiene matters especially in large and old codebases. Until now compiler warnings only showed up in the CI build log. In reality that means nobody noticed them unless they went digging through the logs. For clang-tidy and clazy you had to write your own CI scripts.&lt;/p&gt;
&lt;p&gt;That changes now: if you opt in all of them appear in the code quality widget of your merge request.&lt;/p&gt;
&lt;h2 id="what-we-already-have-cppcheck"&gt;What we already have: cppcheck&lt;/h2&gt;
&lt;p&gt;Most of you know the cppcheck job already. It runs on every pipeline, reports its findings to GitLab's code quality widget and with &lt;code&gt;require-cppcheck-clean: true&lt;/code&gt; it can fail the pipeline. cppcheck is fast and does not need to build the project. That is its strength and also its limit: it does not see the code the way the compiler sees it.&lt;/p&gt;
&lt;h2 id="what-is-new-compiler-warnings-and-clang-tidy-with-clazy"&gt;What is new: compiler warnings and clang-tidy with clazy&lt;/h2&gt;
&lt;p&gt;The new options hook into the regular build. Each warning the build prints for a file in your repository becomes an entry in the code quality report. GitLab then compares it with the target branch so the merge request shows only what it introduces or fixes.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blogs.kde.org/2026/11/27/ci-clang-tidy-clazy-and-compiler-warnings-in-your-merge-requests/clang-tidy-warnings.png"&gt;&lt;figure&gt;
 &lt;img class="img-fluid" alt="The GitLab code quality widget in a merge request: &amp;quot;Code Quality scans found 712 new findings&amp;quot;, listing clang-tidy findings such as bugprone-suspicious-include and clazy-connect-3arg-lambda with their file and line" src="https://blogs.kde.org/2026/11/27/ci-clang-tidy-clazy-and-compiler-warnings-in-your-merge-requests/clang-tidy-warnings.png"
 style="max-width: 100%; height: auto"
 /&gt;
&lt;/figure&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Don't let the 712 scare you, the number also includes the cppcheck findings. For a large and old codebase that is not unusual. Better to know about them (and start fixing them) than to bury your head in the sand.&lt;/p&gt;
&lt;p&gt;clang-tidy runs on the real compile commands with the full include paths, defines and Qt headers. With the clazy plugin loaded it also knows Qt! There are a number of checks, e.g. detaching containers in range loops, &lt;code&gt;QString&lt;/code&gt; misuse, wrong &lt;code&gt;connect&lt;/code&gt; calls and much more.&lt;/p&gt;
&lt;h2 id="which-tool-is-for-what"&gt;Which tool is for what&lt;/h2&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;&lt;/th&gt;
 &lt;th&gt;cppcheck&lt;/th&gt;
 &lt;th&gt;Compiler warnings&lt;/th&gt;
 &lt;th&gt;clang-tidy + clazy&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;Runs&lt;/td&gt;
 &lt;td&gt;in its own job&lt;/td&gt;
 &lt;td&gt;during the build&lt;/td&gt;
 &lt;td&gt;during the build&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Needs a build&lt;/td&gt;
 &lt;td&gt;no&lt;/td&gt;
 &lt;td&gt;yes&lt;/td&gt;
 &lt;td&gt;yes&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Understands Qt&lt;/td&gt;
 &lt;td&gt;no&lt;/td&gt;
 &lt;td&gt;no&lt;/td&gt;
 &lt;td&gt;yes, through clazy&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Finds&lt;/td&gt;
 &lt;td&gt;likely bugs and style issues from the sources alone&lt;/td&gt;
 &lt;td&gt;what GCC already tells you with &lt;code&gt;-W…&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;bug patterns, modernization, readability and Qt specific issues&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Checks set by&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;cppcheck-arguments&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;the project's compile flags&lt;/td&gt;
 &lt;td&gt;the project's &lt;code&gt;.clang-tidy&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Can fail the pipeline&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;require-cppcheck-clean&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;no&lt;/td&gt;
 &lt;td&gt;&lt;code&gt;require-clang-tidy-clean&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;They do not replace each other. cppcheck stays the cheap first look for every project. Compiler warnings are free (but not as good as beer) since the build runs anyway. clang-tidy with clazy is the deep look and you choose how deep with your &lt;code&gt;.clang-tidy&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="how-to-enable-it"&gt;How to enable it&lt;/h2&gt;
&lt;p&gt;Everything is off by default. Add the options to your &lt;code&gt;.kde-ci.yml&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;Options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;# show compiler warnings in the code quality report&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;report-compiler-warnings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;# run clang-tidy with clazy, checks are set in .clang-tidy&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;run-clang-tidy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c"&gt;# optional: fail the pipeline when clang-tidy finds something&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;require-clang-tidy-clean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The analysis runs only in the main linux job (currently &lt;code&gt;suse_tumbleweed_qt612&lt;/code&gt; job from &lt;code&gt;/gitlab-templates/linux-qt6.yml&lt;/code&gt;) so your &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; needs to include that template. It does not run in the Qt &amp;quot;next&amp;quot; job or on other platforms so nothing is reported twice.&lt;/p&gt;
&lt;p&gt;clang-tidy also needs a &lt;code&gt;.clang-tidy&lt;/code&gt; file in the root of your repository. The CI does not pick checks for you. My advice would be to start small and grow it, for example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nt"&gt;Checks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;-*,clazy-range-loop-detach,clazy-qstring-arg,bugprone-use-after-move&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you also set &lt;code&gt;report-compiler-warnings: true&lt;/code&gt;, leave out &lt;code&gt;modernize-use-override&lt;/code&gt; and &lt;code&gt;modernize-use-nullptr&lt;/code&gt;. ECM's &lt;code&gt;KDECompilerSettings&lt;/code&gt; already turns on &lt;code&gt;-Wsuggest-override&lt;/code&gt; and &lt;code&gt;-Wzero-as-null-pointer-constant&lt;/code&gt; for GCC, so each of these issues would show up twice in the report (once from GCC and once from clang-tidy).&lt;/p&gt;
&lt;p&gt;Be careful with wildcards. &lt;code&gt;clazy-*&lt;/code&gt; turns on every clazy check not just levels 0 to 2. That includes the manual checks which clazy itself marks as prone to false positives or a matter of taste (such as &lt;code&gt;clazy-reserve-candidates&lt;/code&gt;, &lt;code&gt;clazy-isempty-vs-count&lt;/code&gt; or &lt;code&gt;clazy-qrequiredresult-candidates&lt;/code&gt;). Level 2 is fairly noisy too (&lt;code&gt;clazy-rule-of-three&lt;/code&gt;, &lt;code&gt;clazy-function-args-by-ref&lt;/code&gt;, …). That is fine for a first look at what comes up. But if you want &lt;code&gt;require-clang-tidy-clean&lt;/code&gt; later, you will have to switch them off one by one (&lt;code&gt;-clazy-reserve-candidates&lt;/code&gt;, …) or go back to an explicit list.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;clang-analyzer-*&lt;/code&gt; finds real bugs but it makes the build much slower as it runs on every translation unit. Check that the job still finishes within its timeout.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;clang-tidy-arguments&lt;/code&gt; passes extra arguments to clang-tidy if you need them.&lt;/p&gt;
&lt;p&gt;Want to see it in action? The first real project to get a taste (and a mouthful of new warnings) is Dolphin: &lt;a href="https://invent.kde.org/system/dolphin/-/merge_requests/1568"&gt;Dolphin MR !1568&lt;/a&gt; turns on &lt;code&gt;report-compiler-warnings&lt;/code&gt; and &lt;code&gt;run-clang-tidy&lt;/code&gt;. Its &lt;code&gt;.clang-tidy&lt;/code&gt; lists clazy's level 0 and level 1 checks explicitly which makes imho a good starting point to copy for your own project.&lt;/p&gt;
&lt;h2 id="status-and-thanks"&gt;Status and thanks&lt;/h2&gt;
&lt;p&gt;The change is &lt;a href="https://invent.kde.org/sysadmin/ci-utilities/-/merge_requests/758"&gt;ci-utilities MR !758&lt;/a&gt;. It builds on earlier work in &lt;a href="https://invent.kde.org/sysadmin/ci-utilities/-/merge_requests/532"&gt;!532&lt;/a&gt; and &lt;a href="https://invent.kde.org/sysadmin/ci-utilities/-/merge_requests/651"&gt;!651&lt;/a&gt;. Thanks to Nicolas Fella, whose idea inspired this and to Ben Cooksley for the review.&lt;/p&gt;
&lt;p&gt;Give it a try on your project once it lands. If the tooling gives you trouble please reach out. The warnings in your code though are yours to keep and fix. 😄&lt;/p&gt;
&lt;p&gt;Happy fixing!&lt;/p&gt;</description></item></channel></rss>