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

Add clang-format to the pre-commit. #222

Merged
merged 4 commits into from
Feb 20, 2023
Merged

Add clang-format to the pre-commit. #222

merged 4 commits into from
Feb 20, 2023

Conversation

willGraham01
Copy link
Collaborator

@willGraham01 willGraham01 commented Jan 26, 2023

🥇 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:

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 requires compile_commands.json to be present. Can be done by passing DCMAKE_EXPORT_COMPILE_COMMANDS=ON when invoking cmake.
  • cpplint filters whitespace/comments due to a conflict with Doxygen and clang-tidy standards. Suppresses legal/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.

Base automatically changed from wgraham-iterator-refactor-2 to main January 30, 2023 14:22
@samcunliffe samcunliffe mentioned this pull request Jan 31, 2023
2 tasks
willGraham01 added a commit that referenced this pull request Feb 2, 2023
@samcunliffe
Copy link
Member

samcunliffe commented Feb 6, 2023

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 pre-commit etc.

@samcunliffe
Copy link
Member

Also: way too many commits in this branch...? Need another rebase?

@samcunliffe samcunliffe linked an issue Feb 6, 2023 that may be closed by this pull request
4 tasks
@willGraham01
Copy link
Collaborator Author

willGraham01 commented Feb 7, 2023

Also: way too many commits in this branch...? Need another rebase?

It's going to be because wgraham-iterator-refactor-2 was squash-merged into main last week. This guy was branching off him - will attempt a rebase.

Edit: it looks a lot better now... commit-wise at least.

willGraham01 and others added 4 commits February 7, 2023 09:34
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.
@samcunliffe
Copy link
Member

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?

@willGraham01 willGraham01 marked this pull request as ready for review February 20, 2023 16:23
@willGraham01
Copy link
Collaborator Author

willGraham01 commented Feb 20, 2023

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 compile_commands.json to exist locally (because we decided that was excessive).

Feel free to hit the merge button when your review goes in 👍

@samcunliffe samcunliffe changed the title Added clang-tidy and cpplint to the pre-commit. Add clang-format to the pre-commit. Feb 20, 2023
@samcunliffe samcunliffe merged commit a2e1e22 into main Feb 20, 2023
@samcunliffe samcunliffe deleted the wgraham-cpp-linter branch February 20, 2023 16:31
willGraham01 added a commit that referenced this pull request Feb 23, 2023
* 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
willGraham01 added a commit that referenced this pull request Mar 6, 2023
* 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
willGraham01 added a commit that referenced this pull request Mar 7, 2023
* 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
willGraham01 added a commit that referenced this pull request Mar 29, 2023
* 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
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.

[CI] Build TDMS with -Wall -Werror and run a linter
3 participants