-
Notifications
You must be signed in to change notification settings - Fork 60
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
Clean up headers with include-what-you-use #567
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Did you get include-what-you-use
to work for this? If yes, can we also have that in CI somehow?
There is one minor comment below.
I added iwyu to the stack and ran it. I think it's not in a state where it can be added to CI. The authors say it's in "alpha" and after playing with it a bit, it needed to add back one include that keeps being removed, doesn't take into account that some includes can only be used with C++20 and for some reason |
there is also |
#include "podio/CollectionBuffers.h" | ||
#include "podio/SchemaEvolution.h" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep "our" headers above the STL ones? Or did something change here for the recommendations? (Mainly because this makes it more likely to miss some STL / system headers in our included files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by changing .clang-format, at least the headers I checked had the system ones below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely convinced yet that all of the proposed changes from IWYU are what we want in the end. I have left a few comments inline.
Since we are most likely not planning to run this in CI, I would propose to clean this PR up a bit starting from the IWYU, trying a bit to also follow some of our conventions.
tests/extra_code/implementations.cc
Outdated
@@ -1 +1,6 @@ | |||
bool {name}::lt(int i) const { return number() < i; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should not be clang-formatted (and I think they should also be excluded from the pre-commit workflow)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be already excluded from pre-commit right?
Line 14 in 0a5af60
exclude: (tests/(datamodel|src|extra_code)/.*(h|cc)|podioVersion.in.h|SIOFrame.*h) |
Line 19 in 0a5af60
exclude: (tests/(datamodel|src|extra_code)/.*(h|cc)$|podioVersion.in.h) |
To exclude from clang-format
run automatically by some IDE, adding a new file clang-format config should work.
tests/extra_code/.clang-format
with:
DisableFormat: true
Would you like a separate PR or is it fine to do it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware that is a possibility. Can you make a separate PR for that and also put one into the python/templates
directory? Then I could probably remove the custom hook from my config :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #605
include/podio/RNTupleReader.h
Outdated
|
||
#include <RVersion.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <RVersion.h> | |
#include <RVersion.h> | |
src/ROOTReader.cc
Outdated
#include <TBranch.h> | ||
#include <TObjArray.h> | ||
#include <TObject.h> | ||
#include <algorithm> | ||
#include <functional> | ||
#include <optional> | ||
#include <stdexcept> | ||
#include <unordered_map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <TBranch.h> | |
#include <TObjArray.h> | |
#include <TObject.h> | |
#include <algorithm> | |
#include <functional> | |
#include <optional> | |
#include <stdexcept> | |
#include <unordered_map> | |
#include <TBranch.h> | |
#include <TObjArray.h> | |
#include <TObject.h> | |
#include <algorithm> | |
#include <functional> | |
#include <optional> | |
#include <stdexcept> | |
#include <unordered_map> |
Additionally, the system headers should go to the bottom.
src/SIOBlock.cc
Outdated
|
||
#include "podio/CollectionBase.h" | ||
#include "podio/GenericParameters.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "podio/CollectionBase.h" | |
#include "podio/GenericParameters.h" | |
#include "podio/CollectionBase.h" | |
#include "podio/GenericParameters.h" | |
src/SIOFrameData.cc
Outdated
#include "sio/buffer.h" | ||
#include "sio/definitions.h" | ||
|
||
#include <sio/api.h> | ||
#include <sio/block.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "sio/buffer.h" | |
#include "sio/definitions.h" | |
#include <sio/api.h> | |
#include <sio/block.h> | |
#include "sio/buffer.h" | |
#include "sio/definitions.h" | |
#include <sio/api.h> | |
#include <sio/block.h> |
@jmcarcell - can you update this? thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have looked through a few files and it looks like we are getting there, but there are still a few things that I would like to explore to see whether things can be improved.
- Regex: '<[[:alnum:]._]+>' | ||
Priority: 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Regex: '<[[:alnum:]._]+>' | |
Priority: 5 | |
- Regex: '<[[:alnum:]._]+>' | |
Priority: 5 | |
- Regex: '^(<"podio/)' | |
Priority: 1 |
To keep the podio ones at the top?
@@ -1,25 +1,34 @@ | |||
#ifndef PODIO_RNTUPLEWRITER_H | |||
#define PODIO_RNTUPLEWRITER_H | |||
|
|||
#include "podio/Frame.h" | |||
#include "podio/GenericParameters.h" | |||
#include "TFile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would move this to the other ROOT includes (might be solved by the addition to clang-format above).
@@ -1,4 +1,5 @@ | |||
#include "podio/ROOTReader.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,11 +1,17 @@ | |||
#include "podio/SIOLegacyReader.h" | |||
#include "podio/SIOBlock.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you rebase this PR to do further cleanup after #652? Or should we close this and open a new one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we still try to have the "podio/..."
headers sorted at the top? Currently some of the ROOT headers are still above them in quite some places.
@@ -1,4 +1,5 @@ | |||
#include "podio/DataSource.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,14 +1,26 @@ | |||
#include "podio/RNTupleReader.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
#include "podio/SIOBlock.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "podio/SIOBlock.h" | |
#include "podio/SIOBlock.h" | |
Would effectively leave the file unchanged.
@@ -1,7 +1,7 @@ | |||
#include "podio/SIOWriter.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh I think some of these are coming from clang-format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Wondering which setting causes that 😂 Anyhow, if it is truly from clang-format
and we don't find the setting to turn it off, we can also leave them instead of trying to fight clang-format
.
@@ -1,7 +1,10 @@ | |||
#include "podio/SchemaEvolution.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,9 +1,13 @@ | |||
#include "podio/UserDataCollection.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BEGINRELEASENOTES
ENDRELEASENOTES