includemocs: include MOC file at the earliest possible opportunity if… #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… 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.