-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add clang-format to the pre-commit. #222
Conversation
Before merging, we'll want to check that the relevant section in the developer documentation instructions are clear and accurate for future devs setting up |
Also: way too many commits in this branch...? Need another rebase? |
It's going to be because Edit: it looks a lot better now... commit-wise at least. |
Requires tdms/build/compile_commands.json to exist though :(
* First pass run clang-format over the whole codebase. * Fix TODO about namespace indentation. * Tell clang-format to ignore .m files (MATLAB). * Potentially controversial. Line length to 80 characters. * Turn off cppcheck and cpplint (for now). Remove clang-tidy. I think we only want the static linters that don't need build output. That way linting can be a separate (fast) job that can run in pre-commit. We might consider also binning cppcheck if it's too slow. * Confirming that clang-format respects doxygen format comments. It does.
29c6c1b
to
609fde1
Compare
I would advocate changing this PR's title and making it "Ready for review" as-is. Need to tweak the dev docs? Or are you happy? |
I don't think the dev docs need to change, at least for this one. Marked it as ready for review, and updated the main body of the PR to reflect the fact that it doesn't require Feel free to hit the merge button when your review goes in 👍 |
* Cherry-pick Sam's linting * Add flag to Source class to indicate empty array * Add flag to Source class to indicate empty array * Indentation * Initialise values rather than assign * Refactored source updates - flagged mystery indexing * Pre-commit consistency with #223 * Update clang-format to #222 settings * Fix out-of-order initilisation warning * Revert pre-commit to suppress GitHub failures until #223 is ready * Remove unused variables in updating Ksource terms * Start refactoring the refactored functions. Flag more inconsistencies * Missing std:: * Merge E_s steady-state updates into one function (revert files to previous commit if undesired) * Fix bugs in unification (IE Will can't type) * Pull out E_s source updates, and wrap to avoid empty-source updates * Pull out H-source updates, don't add empty array checks yet * Fully refactor H-field, now to find the bug... * Add that newline to make pre-commit happy * Missed a -1 in ONE place... does this fix the bug? * Remove useless comment * Apply Peter's suggestion on #226 * Add Peter's resolution to #225 * Apply Sam's suggestions for SourceIndex struct * Small doc changes that didn't get caught
* Cherry-pick Sam's linting * Add flag to Source class to indicate empty array * Add flag to Source class to indicate empty array * Indentation * Initialise values rather than assign * Refactored source updates - flagged mystery indexing * Pre-commit consistency with #223 * Update clang-format to #222 settings * Fix out-of-order initilisation warning * Revert pre-commit to suppress GitHub failures until #223 is ready * Remove unused variables in updating Ksource terms * Start refactoring the refactored functions. Flag more inconsistencies * Missing std:: * Merge E_s steady-state updates into one function (revert files to previous commit if undesired) * Fix bugs in unification (IE Will can't type) * Pull out E_s source updates, and wrap to avoid empty-source updates * Pull out H-source updates, don't add empty array checks yet * Fully refactor H-field, now to find the bug... * Add that newline to make pre-commit happy * Missed a -1 in ONE place... does this fix the bug? * Remove useless comment * Apply Peter's suggestion on #226 * Add Peter's resolution to #225 * Apply Sam's suggestions for SourceIndex struct * Small doc changes that didn't get caught
* Cherry-pick Sam's linting * Add flag to Source class to indicate empty array * Add flag to Source class to indicate empty array * Indentation * Initialise values rather than assign * Refactored source updates - flagged mystery indexing * Pre-commit consistency with #223 * Update clang-format to #222 settings * Fix out-of-order initilisation warning * Revert pre-commit to suppress GitHub failures until #223 is ready * Remove unused variables in updating Ksource terms * Start refactoring the refactored functions. Flag more inconsistencies * Missing std:: * Merge E_s steady-state updates into one function (revert files to previous commit if undesired) * Fix bugs in unification (IE Will can't type) * Pull out E_s source updates, and wrap to avoid empty-source updates * Pull out H-source updates, don't add empty array checks yet * Fully refactor H-field, now to find the bug... * Add that newline to make pre-commit happy * Missed a -1 in ONE place... does this fix the bug? * Remove useless comment * Apply Peter's suggestion on #226 * Add Peter's resolution to #225 * Apply Sam's suggestions for SourceIndex struct * Small doc changes that didn't get caught
* Cherry-pick Sam's linting * Add flag to Source class to indicate empty array * Add flag to Source class to indicate empty array * Indentation * Initialise values rather than assign * Refactored source updates - flagged mystery indexing * Pre-commit consistency with #223 * Update clang-format to #222 settings * Fix out-of-order initilisation warning * Revert pre-commit to suppress GitHub failures until #223 is ready * Remove unused variables in updating Ksource terms * Start refactoring the refactored functions. Flag more inconsistencies * Missing std:: * Merge E_s steady-state updates into one function (revert files to previous commit if undesired) * Fix bugs in unification (IE Will can't type) * Pull out E_s source updates, and wrap to avoid empty-source updates * Pull out H-source updates, don't add empty array checks yet * Fully refactor H-field, now to find the bug... * Add that newline to make pre-commit happy * Missed a -1 in ONE place... does this fix the bug? * Remove useless comment * Apply Peter's suggestion on #226 * Add Peter's resolution to #225 * Apply Sam's suggestions for SourceIndex struct * Small doc changes that didn't get caught
🥇 Here's every single warning: pre-commit-on-all.txt
linting.yaml
Workflow renamed to "Run code linting" (previously "Run python code linting").
.pre-commit-config.yaml
Invokes pocc/pre-commit-hooks to force
C++
linting:clang-format
is pointed at our.clang-format
Future considerations:
We looked at a bunch of other pre-commit tools. Here's some stuff about them that we ended up not including in this PR but might be wanted going forward.
clang-tidy
can be pointed to our compile commands. This requirescompile_commands.json
to be present. Can be done by passingDCMAKE_EXPORT_COMPILE_COMMANDS=ON
when invokingcmake
.cpplint
filterswhitespace/comments
due to a conflict withDoxygen
andclang-tidy
standards. Suppresseslegal/copyright
because our developer docs don't require a copyright notice in header files. Runs quietly so we don't know its there if it has nothing to say.