Pin pointer alignment, check make indent in CI, and reformat

`DerivePointerAlignment` (inherited from the Google base style) made the
placement of `*` and `&` depend on whichever way the surrounding file
already leaned, so reformatting could silently move them. Set
`PointerAlignment: Right` and turn derivation off so the rule is the same
everywhere.

Add an `indent` CI job in the same shape as the `docs` one: reformat, then
fail on any diff. It pins clang-format 18.1.8, since different versions
format the same input differently and would otherwise fail the check
spuriously.

Reformat the sources so the new job passes. Most of the diff is drift that
accumulated while nothing was checking: trailing whitespace, spaces where
tabs belong, hand-aligned continuation lines, and casts missing the space
that `SpaceAfterCStyleCast` asks for.

Also drop the exclusion of flatgeobuf.cpp, which was the one hand-written
source the formatter never saw, and reformat it too. Only whitespace,
brace placement, and single-statement `if` bodies change; the code itself
is untouched.
This commit is contained in:
Claude
2026-08-07 19:20:45 +00:00
parent 734bba7c78
commit 231c62c25a
9 changed files with 104 additions and 77 deletions
+19
View File
@@ -36,3 +36,22 @@ jobs:
echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result." echo "::error::man/tippecanoe.1 is out of date. Run 'make docs' and commit the result."
exit 1 exit 1
} }
indent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Pinned, because different clang-format versions format the same input
# differently, which would make this check fail spuriously.
- name: Install clang-format
run: |
python3 -m venv /tmp/clang-format
/tmp/clang-format/bin/pip install clang-format==18.1.8
- name: Reformat the sources
run: PATH="/tmp/clang-format/bin:$PATH" make indent
- name: Check that the sources are correctly formatted
run: |
git diff --exit-code || {
echo "::error::Sources are not correctly formatted. Run 'make indent' and commit the result."
exit 1
}
+6 -1
View File
@@ -127,8 +127,13 @@ tippecanoe-overzoom: overzoom.o mvt.o clip.o evaluator.o jsonpull/jsonpull.o tex
clean: clean:
rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check rm -f ./tippecanoe ./tippecanoe-* ./tile-join ./unit *.o *.d */*.o */*.d tests/**/*.mbtiles tests/**/*.check
# CI checks that the committed sources match what this produces, so run it before
# sending a pull request. Different clang-format versions format the same input
# differently, so the CI job pins one (see .github/workflows/test.yml); if your
# local version disagrees with it, let the job tell you what to fix rather than
# committing its idea of the formatting.
indent: indent:
clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false}" $(filter-out flatgeobuf.cpp,$(C)) $(H) jsonpull/*.[ch] clang-format -i -style="{BasedOnStyle: Google, IndentWidth: 8, UseTab: Always, AllowShortIfStatementsOnASingleLine: false, ColumnLimit: 0, ContinuationIndentWidth: 8, SpaceAfterCStyleCast: true, IndentCaseLabels: false, AllowShortBlocksOnASingleLine: false, AllowShortFunctionsOnASingleLine: false, SortIncludes: false, PointerAlignment: Right, DerivePointerAlignment: false}" $(C) $(H) jsonpull/*.[ch]
TESTS = $(wildcard tests/*/out/*.json) TESTS = $(wildcard tests/*/out/*.json)
SPACE = $(NULL) $(NULL) SPACE = $(NULL) $(NULL)
+9 -6
View File
@@ -20,8 +20,7 @@ struct NodeItem {
}; };
// copied from https://github.com/flatgeobuf/flatgeobuf/blob/master/src/cpp/packedrtree.cpp#L365 // copied from https://github.com/flatgeobuf/flatgeobuf/blob/master/src/cpp/packedrtree.cpp#L365
uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize) uint64_t PackedRTreeSize(const uint64_t numItems, const uint16_t nodeSize) {
{
if (nodeSize < 2) if (nodeSize < 2)
throw std::invalid_argument("Node size must be at least 2"); throw std::invalid_argument("Node size must be at least 2");
if (numItems == 0) if (numItems == 0)
@@ -62,7 +61,8 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y); projection->project(xy->Get(i), xy->Get(i + 1), 32, &x, &y);
if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end) * 2)) { if (i == 0 || (ends != NULL && current_end < ends->size() && i == ends->Get(current_end) * 2)) {
dv.push_back(draw(VT_MOVETO, x, y)); dv.push_back(draw(VT_MOVETO, x, y));
if (i > 0) current_end++; if (i > 0)
current_end++;
} else { } else {
dv.push_back(draw(VT_LINETO, x, y)); dv.push_back(draw(VT_LINETO, x, y));
} }
@@ -72,7 +72,8 @@ drawvec readLinePart(const FlatGeobuf::Geometry *geometry) {
drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryType h_geometry_type) { drawvec readGeometry(const FlatGeobuf::Geometry *geometry, FlatGeobuf::GeometryType h_geometry_type) {
FlatGeobuf::GeometryType geometry_type = h_geometry_type; FlatGeobuf::GeometryType geometry_type = h_geometry_type;
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = geometry->type(); if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
geometry_type = geometry->type();
if (geometry_type == FlatGeobuf::GeometryType_Point) { if (geometry_type == FlatGeobuf::GeometryType_Point) {
return readPoints(geometry); return readPoints(geometry);
@@ -107,7 +108,8 @@ void readFeature(const FlatGeobuf::Feature *feature, long long feature_sequence_
int drawvec_type = -1; int drawvec_type = -1;
FlatGeobuf::GeometryType geometry_type = h_geometry_type; FlatGeobuf::GeometryType geometry_type = h_geometry_type;
if (h_geometry_type == FlatGeobuf::GeometryType_Unknown) geometry_type = feature->geometry()->type(); if (h_geometry_type == FlatGeobuf::GeometryType_Unknown)
geometry_type = feature->geometry()->type();
switch (geometry_type) { switch (geometry_type) {
case FlatGeobuf::GeometryType_Point: case FlatGeobuf::GeometryType_Point:
@@ -397,7 +399,8 @@ void parse_flatgeobuf(std::vector<struct serialization_state> *sst, const char *
queueFeature(feature, feature_sequence_id, h_geometry_type, h_column_names, h_column_types, sst, layer, layername); queueFeature(feature, feature_sequence_id, h_geometry_type, h_column_names, h_column_types, sst, layer, layername);
if (feature_sequence_id >= 0) feature_sequence_id ++; if (feature_sequence_id >= 0)
feature_sequence_id++;
start += sizeof(uint32_t) + feature_size; start += sizeof(uint32_t) + feature_size;
} }