Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Poldraunic
Copy link

… 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
Copy link
Author

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

@Poldraunic Poldraunic force-pushed the master branch 2 times, most recently from a4f4f77 to 2556d80 Compare August 23, 2024 20:03
@winterz
Copy link
Contributor

winterz commented Aug 26, 2024

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
Copy link
Contributor

winterz commented Aug 26, 2024

done. please rebase

… 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 they're separated by code or comments, if this check is event 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
Copy link
Author

@winterz done!

@Poldraunic
Copy link
Author

@winterz, any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants