[QGIS-Developer] pre-commit for code-formatting
Stefanos Natsis
uclaros at gmail.com
Thu Dec 5 01:54:16 PST 2024
Thank you Denis for all this work and the heads up for setting things up!
I have a few notes/questions about things I've encountered so far:
1. There are cases where the formatting is not applied. For example in PR
https://github.com/qgis/QGIS/pull/59382, after merging master and pushing,
clang-format fails in the CI
2. Is there a way one can manually run pre-commit for all modified files
and not just files staged for commit?
3. clang-format seems to try to squeeze parameters in a single line, even
if one has explicitly used new lines for readability.
For example, it will do this:
```cpp
- else if ( isOnMesh && ( mWidgetActionDigitizing->zValueSourceType() ==
QgsMeshEditDigitizingAction::InMeshUseMeshZWidgetOtherwise ||
- mWidgetActionDigitizing->zValueSourceType() ==
QgsMeshEditDigitizingAction::InMeshUseMeshTerrainOtherwise ) )
+ else if ( isOnMesh && ( mWidgetActionDigitizing->zValueSourceType() ==
QgsMeshEditDigitizingAction::InMeshUseMeshZWidgetOtherwise ||
mWidgetActionDigitizing->zValueSourceType() ==
QgsMeshEditDigitizingAction::InMeshUseMeshTerrainOtherwise ) )
```
This is a big hit on readability when there are parentheses in the
parameters.
4. It seems like with astyle we had something equivalent to
SpacesInAngles=Leave, so both static_cast<int> and static_cast< int > was
valid. Now the spaces are gone and while it's fine for small types, it is
harder to read for bigger types in longer statements.
5. Similar for SpacesInSquareBrackets and SpacesInContainerLiterals
Best
Stefanos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20241205/30da9b11/attachment.htm>
More information about the QGIS-Developer
mailing list