KDToolBox icon indicating copy to clipboard operation
KDToolBox copied to clipboard

includemocs: include MOC file at the earliest possible opportunity if…

Open Poldraunic opened this issue 1 year ago • 5 comments

… header file is not found

The script expects to find header file include with relative path. However, if absolute path is used (e.g. #include "path/to/header.h" instead of #include "header.h") the check will return 0 as insertion position. This, however, can (and often will) conflict with license/copyright comment meaning MOC file will be included before license/copyright comment.

Furthermore, clang-format is unable to re-sort headers, if this check is enabled at all. And so, this means that user would have to manually adjust every file.

This patch add additional attempt at finding #include directive and if it is found, MOC file will be included before the first occurrence of the #include directive. This somewhat guarantees that license/copyright header has been skipped.

This change, of course, doesn't fix all the possible issues, but only attempts to mitigate a common instance of such case.

Poldraunic avatar Aug 23 '24 19:08 Poldraunic

CI fail seems unrelated as everything passed (except for REUSE) on my machine.

Poldraunic avatar Aug 23 '24 20:08 Poldraunic

you mixed pre-commit fixes in with your includemocs changes I will fix all pre-commit issues and then you can rebase your patch

winterz avatar Aug 26 '24 15:08 winterz

done. please rebase

winterz avatar Aug 26 '24 15:08 winterz

@winterz done!

Poldraunic avatar Aug 26 '24 16:08 Poldraunic

@winterz, any updates?

Poldraunic avatar Sep 06 '24 19:09 Poldraunic

@jesperkdab since you're the includemocs author, please check if this is something that you want merged

iamsergio avatar Jan 24 '25 12:01 iamsergio