Bug 513153

Summary: Clazy no longer export diagnostics info for check that doesn't have any replacement
Product: [Developer tools] clazy Reporter: Trần Nam Tuấn (Bill) <tuantran1632001>
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: alexander.lohnau, drizt72, smartins, sulmpx60
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Qt Creator and warnings before clazy 1.16
Qt Creator and warnings after clazy 1.16

Description Trần Nam Tuấn (Bill) 2025-12-10 02:26:20 UTC
As of v1.16, Clazy no longer exports diagnostics info for check that doesn't have any replacement. I'm talking about the "--export-fixes=<string>" option.

For example, checks like "clazy-unused-non-trivial-variable" are not exported, but "clazy-qstring-arg" still is. The warnings are still output to stderr, though.

I've checked and this does not happen with v1.15.

SOFTWARE/OS VERSIONS
Clazy version 1.16
LLVM version 21.1.6
Comment 1 Alexander Lohnau 2026-01-04 20:53:19 UTC
Hmm, but why should clazy export warnings when the export option only mentions fixes?

Like this was a change to prevent clazy from generating those files even if there was no fixit that could be applied.
Comment 2 Trần Nam Tuấn (Bill) 2026-01-04 22:03:16 UTC
(In reply to Alexander Lohnau from comment #1)
> Hmm, but why should clazy export warnings when the export option only
> mentions fixes?
> 
> Like this was a change to prevent clazy from generating those files even if
> there was no fixit that could be applied.

I'm currently maintaining a VSCode extension for Clazy [1] which derived from another extension for clang-tidy. From the original extension, it seemed that clang-tidy itself also exported warning along with fixes (though I have not yet tested this with more recent version of clang-tidy since clangd has already filled that role). And for a while Clazy also did the same until the new version.

I have already adapted my extension to parse the warning from stderr in addition to the exported diagnostics. Though, that has its own limitation. The warnings from stderr do not provide accurate/easily-parsable ranges of the affected code. Only the starting line and column can be extracted from the warning message. This makes it difficult to provide highlighting with the editor. (Unless, there is a better way of doing this that I am not aware of.) I have elected to just reported only one character from the start position, which give a very cute and small yellow squiggly line in the editor.

I do understand the reasoning that the option only mention fixes. I was just unsure if this was intended as, at the time, I didn't see it was mentioned in the changelog.

[1] https://gitlab.com/TheBill2001/vscode-clazy
Comment 3 Ivan Romanov 2026-01-26 20:22:49 UTC
Seems I opened duplicate https://bugs.kde.org/show_bug.cgi?id=515127. Also my question on StackOverflow https://stackoverflow.com/questions/79875933/how-to-navigate-to-clazy-warning-in-qt-creator. There a screenshot to see a problem. I spend of couple of days to find reason of a problem. I can't believe that such obviously problem is intented behaviour. Long time I though that I doing something wrong and there is a way to setup this. So my opinion it's very bad practic to export warnings partially. It makes them unusable. Need to parse output but Qt Creator plugin doesn't do this. I look to Diagnostics pane and see my app fine. Then I open Clazy output pane and see many warning. And I can't with clicks open them. It makes me sad. So please fix it. If need I can write a patch. Anyway I've allready opened clazy sources and find a place with problem.
Comment 4 Ivan Romanov 2026-01-26 21:13:05 UTC
I rebuild Fedora package with.

$ cat fix-export-fixes.patch 
diff --git a/src/FixItExporter.cpp b/src/FixItExporter.cpp
index 70e96229..750d507a 100644
--- a/src/FixItExporter.cpp
+++ b/src/FixItExporter.cpp
@@ -137,11 +137,6 @@ void FixItExporter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const D
         Client->HandleDiagnostic(DiagLevel, Info);
     }
 
-    // Do not export file when we can not provide any fixits
-    if (Info.getNumFixItHints() == 0) {
-        return;
-    }
-
     // Convert and record warning diagnostics and their notes
     if (DiagLevel == DiagnosticsEngine::Warning) {
         auto ToolingDiag = ConvertDiagnostic(Info);

It fix my problem.
Comment 5 Sergey Katunin 2026-02-09 15:28:40 UTC
*** Bug 515127 has been marked as a duplicate of this bug. ***
Comment 6 Sergey Katunin 2026-02-09 15:33:53 UTC
Clazy no longer export diagnostics (warnings) that doesn't have fixits since v1.16 
(https://invent.kde.org/sdk/clazy/-/commit/941406ecdb809dc739425c4b9465d0bc5b1297bb).

This leads to the fact that now Qt Creator does not display these warnings. 

Moreover, looks like that many warnings should to have a fix-it, for example, `clazy-empty-qstringliteral`, but they do not have a fix-it, and therefore they are also not displayed now.

At the same time, Clazy continues to output these warnings in the stderr log.

Apparently, the Clazy plugin in Qt Creator now has to parse these warnings in some other way in order to display all warnings as before.

I created a bug report in Qt about it here: https://qt-project.atlassian.net/browse/QTCREATORBUG-34068
Comment 7 Sergey Katunin 2026-02-09 15:34:36 UTC
Created attachment 189398 [details]
Qt Creator and warnings before clazy 1.16
Comment 8 Sergey Katunin 2026-02-09 15:34:45 UTC
Created attachment 189399 [details]
Qt Creator and warnings after clazy 1.16
Comment 9 Ivan Romanov 2026-02-09 16:30:20 UTC
I found some workaround. Instead of /usr/bin/clang-tidy use some wrapper script for clang-tidy.

$ cat /usr/bin/clang-tidy-clazy.sh
#!/bin/sh
# clang-tidy-clazy.sh
#
# Wrapper to run clang-tidy with Clazy plugin preloaded

CLANG_TIDY=${CLANG_TIDY:-clang-tidy}
CLAZY_SO=${CLAZY_SO:-ClazyClangTidy.so}

exec "$CLANG_TIDY" \
    --load="$CLAZY_SO" \
    "$@"

Set in Qt Creator settings  /usr/bin/clang-tidy-clazy.sh as clang-tidy executable. Now when I call analyze my project with clang-tidy it shows also clazy messages. And no need to use standalone clazzy.
Comment 10 Alexander Lohnau 2026-02-14 13:40:23 UTC
Oh, I understand the issue now. I was not aware how qtcreator handles the diagnostics.

I will make sure the next release contains a fix!
Comment 11 Bug Janitor Service 2026-02-14 13:45:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/clazy/-/merge_requests/245
Comment 12 Alexander Lohnau 2026-02-15 06:56:54 UTC
Git commit 60c69f218d5cb69dd92689e07f11eb5bf7b46775 by Alexander Lohnau.
Committed on 14/02/2026 at 13:45.
Pushed by alex into branch 'master'.

Always emit diagnostic files, even if we do not provide any fixits

M  +1    -5    src/FixItExporter.cpp

https://invent.kde.org/sdk/clazy/-/commit/60c69f218d5cb69dd92689e07f11eb5bf7b46775