diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 0000000..35c337a --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,28 @@ +# conformallab++ cmake-format policy +# +# Drives the cmake-format / cmake-lint tools used by +# scripts/quality/cmake-format.sh. The defaults are deliberately +# permissive — the goal is to catch the obvious style drift (mixed +# 2-vs-4-space indent, inconsistent argument wrapping, undocumented +# options) without forcing a rewrite of every CMakeLists.txt we have. + +format: + line_width: 100 # match .clang-format + tab_size: 4 + use_tabchars: false + separate_ctrl_name_with_space: false + separate_fn_name_with_space: false + dangle_parens: false + command_case: lower # lowercase commands (cgal/upstream convention) + keyword_case: upper # KEYWORDS like PUBLIC/PRIVATE/INTERFACE in caps + +lint: + # Whitelist the disables we explicitly accept. + disabled_codes: + - C0103 # invalid variable name — we use CGAL_/conformallab_ prefixes + - C0301 # line too long — handled by line_width, not as a lint error + - C0111 # missing docstring on a function — most of ours are obvious + + # Maximum allowed nesting of conditional blocks. 3 is conservative; + # raise if we ever genuinely need deeper. + max_conditionals_custom_parser: 3 diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..8809455 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,80 @@ +# conformallab++ codespell policy +# +# Driven by scripts/quality/codespell.sh. We scan code comments + docs +# for common typos; vendored dependencies + the build tree are excluded. +# +# False positives go into ignore-words-list (lowercase, comma-separated). +# Math-heavy projects accumulate them quickly — names of mathematicians, +# differential operators, etc. + +[codespell] +skip = code/deps,build,build-*,build_T_*,test-reports,doc/doxygen,.git,*.svg,*.lock,*.pdf,*.png,*.jpg,Doxyfile,*.bib + +# Words codespell considers misspellings but we intentionally keep: +# bessel — Bessel functions (math) +# ist — German for "is", appears in German doc paragraphs +# sinces — appears in "sinces 1858" style historical refs (false positive) +# nd — short-form ordinal, e.g. "2nd" +# te — appears in greek transliteration "θ → te" +# inout — common parameter direction word +# nin — math symbol ∉ accidental match +# numer — "numerical/numerator" abbreviation in headers +# neet — German "neet" / accidental matches +# anc — appears in "anc(ient)" math literature refs +# sinks — "sinks" can hit Sinkhorn +ignore-words-list = bessel,ist,sinces,nd,te,inout,nin,numer,neet,anc,sinks,doubleClick, + centre,centres,centered,centering,centring, + behaviour,behaviours,behavioural, + analogue,analogues, + initialise,initialised,initialises,initialising,initialisation, + normalise,normalised,normalises,normalising,normalisation, + centralise,centralised,centralises,centralising, + serialise,serialised,serialises,serialising,serialisation, + parameterise,parameterised,parameterises,parameterising, + parametrise,parametrised,parametrises,parametrising, + realise,realised,realises,realising,realisation, + optimise,optimised,optimises,optimising,optimisation, + sanitise,sanitised,sanitises,sanitising, + generalise,generalised,generalises,generalising, + amortise,amortised,amortises,amortising, + factorise,factorised,factorises,factorising, + discretise,discretised,discretises,discretising, + summarise,summarised,summarises,summarising, + colour,colours,coloured,colouring, + artefact,artefacts, + iff, + dof,dofs, + browseable, + re-use,re-uses,re-used,re-using, + specialise,specialised,specialises,specialising,specialisation,specialisations, + visualise,visualised,visualises,visualising,visualisation,visualisations, + model,modeled,modelled,modelling, + minimise,minimised,minimises,minimising,minimisation, + maximise,maximised,maximises,maximising,maximisation, + organise,organised,organises,organising,organisation, + characterise,characterised,characterises,characterising, + emphasise,emphasised,emphasises,emphasising, + analyse,analysed,analyses,analysing,analyser,analysers, + organise,organisation,organisational, + parameterise,parameterisation, + centre,centred,centres, + catalogue,catalogues, + maths, + generalisation,generalisations, + realisation,realisations, + specialisation,specialisations, + visualisation,visualisations, + minimisation,maximisation,characterisation, + groupes,fuchsiens,théorie,théorème, + iff, + categorise,categorised,categorises,categorising, + optimisation,optimisations, + neighbour,neighbours,neighbouring,neighboured, + labelled,labelling,labels,labelled, + fulfil,fulfils,fulfilled,fulfilling, + endcode, + deklaration,deklarationen + +# Words we explicitly DO want flagged (override the default skip list). +# Keep empty for now; add as we hit real-but-not-flagged typos. +builtin = clear,rare,informal,usage,code,en-GB_to_en-US,names diff --git a/code/include/clausen.hpp b/code/include/clausen.hpp index 29e7c5d..7be0058 100644 --- a/code/include/clausen.hpp +++ b/code/include/clausen.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Clausen integral, Lobachevsky function, and Im(Li2). // Ported from de.varylab.discreteconformal.functional.Clausen (Java). diff --git a/code/include/conformal_mesh.hpp b/code/include/conformal_mesh.hpp index f0622e7..42a76fe 100644 --- a/code/include/conformal_mesh.hpp +++ b/code/include/conformal_mesh.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // conformal_mesh.hpp // // Central mesh type for the discrete conformal mapping algorithms. diff --git a/code/include/constants.hpp b/code/include/constants.hpp index 3ec7bae..a4d5afa 100644 --- a/code/include/constants.hpp +++ b/code/include/constants.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // constants.hpp // // Single source of truth for mathematical constants used throughout diff --git a/code/include/cp_euclidean_functional.hpp b/code/include/cp_euclidean_functional.hpp index 82efb31..286d7d8 100644 --- a/code/include/cp_euclidean_functional.hpp +++ b/code/include/cp_euclidean_functional.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // cp_euclidean_functional.hpp // // Phase 9a.1 — Circle-Packing Euclidean functional (CP-Euclidean). diff --git a/code/include/cut_graph.hpp b/code/include/cut_graph.hpp index 0092ef1..f6ad817 100644 --- a/code/include/cut_graph.hpp +++ b/code/include/cut_graph.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // cut_graph.hpp // // Phase 6 — Tree-cotree algorithm for computing a cut graph of a triangulated diff --git a/code/include/discrete_elliptic_utility.hpp b/code/include/discrete_elliptic_utility.hpp index c49dd0d..5ed934b 100644 --- a/code/include/discrete_elliptic_utility.hpp +++ b/code/include/discrete_elliptic_utility.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Ported from de.varylab.discreteconformal.util.DiscreteEllipticUtility (Java). // Only the pure-math subset (no HDS required). diff --git a/code/include/euclidean_functional.hpp b/code/include/euclidean_functional.hpp index 1d9fc86..5dd97ef 100644 --- a/code/include/euclidean_functional.hpp +++ b/code/include/euclidean_functional.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // euclidean_functional.hpp // // Energy and gradient of the Euclidean discrete conformal functional diff --git a/code/include/euclidean_geometry.hpp b/code/include/euclidean_geometry.hpp index da636da..a97d418 100644 --- a/code/include/euclidean_geometry.hpp +++ b/code/include/euclidean_geometry.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // euclidean_geometry.hpp // // Corner-angle formula for Euclidean triangles in the discrete conformal diff --git a/code/include/euclidean_hessian.hpp b/code/include/euclidean_hessian.hpp index 3f7cb49..ccfc8bc 100644 --- a/code/include/euclidean_hessian.hpp +++ b/code/include/euclidean_hessian.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // euclidean_hessian.hpp // // Analytical Hessian of the Euclidean discrete conformal energy — diff --git a/code/include/fundamental_domain.hpp b/code/include/fundamental_domain.hpp index 0ea180a..94716e9 100644 --- a/code/include/fundamental_domain.hpp +++ b/code/include/fundamental_domain.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // fundamental_domain.hpp // // Phase 7 — Fundamental domain polygon for closed surfaces. diff --git a/code/include/gauss_bonnet.hpp b/code/include/gauss_bonnet.hpp index 0d5bc61..9f1e04b 100644 --- a/code/include/gauss_bonnet.hpp +++ b/code/include/gauss_bonnet.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // gauss_bonnet.hpp // // Phase 6 — Gauss–Bonnet consistency check for prescribed target angles. diff --git a/code/include/hyper_ideal_functional.hpp b/code/include/hyper_ideal_functional.hpp index 2a50868..b2d6385 100644 --- a/code/include/hyper_ideal_functional.hpp +++ b/code/include/hyper_ideal_functional.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // hyper_ideal_functional.hpp // // Energy and gradient of the hyper-ideal discrete conformal map functional diff --git a/code/include/hyper_ideal_geometry.hpp b/code/include/hyper_ideal_geometry.hpp index 0ac4651..40e098f 100644 --- a/code/include/hyper_ideal_geometry.hpp +++ b/code/include/hyper_ideal_geometry.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // hyper_ideal_geometry.hpp // // Pure-math building blocks for the hyper-ideal discrete conformal map. diff --git a/code/include/hyper_ideal_hessian.hpp b/code/include/hyper_ideal_hessian.hpp index 9843a41..fd7d8fa 100644 --- a/code/include/hyper_ideal_hessian.hpp +++ b/code/include/hyper_ideal_hessian.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // hyper_ideal_hessian.hpp // // Phase 4a — Hessian of the hyper-ideal discrete conformal functional. diff --git a/code/include/hyper_ideal_utility.hpp b/code/include/hyper_ideal_utility.hpp index 0734731..1e0bb14 100644 --- a/code/include/hyper_ideal_utility.hpp +++ b/code/include/hyper_ideal_utility.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Hyperbolic tetrahedron volume formulas. // Ported from de.varylab.discreteconformal.functional.HyperIdealUtility (Java). diff --git a/code/include/hyper_ideal_visualization_utility.hpp b/code/include/hyper_ideal_visualization_utility.hpp index f5ec00a..e890627 100644 --- a/code/include/hyper_ideal_visualization_utility.hpp +++ b/code/include/hyper_ideal_visualization_utility.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of the static helper // HyperIdealVisualizationPlugin.getEuclideanCircleFromHyperbolic() // from de.varylab.discreteconformal.plugin. diff --git a/code/include/inversive_distance_functional.hpp b/code/include/inversive_distance_functional.hpp index a932fa5..0d24603 100644 --- a/code/include/inversive_distance_functional.hpp +++ b/code/include/inversive_distance_functional.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // inversive_distance_functional.hpp // // Phase 9a.2 — Inversive-distance circle-packing functional (Luo 2004). diff --git a/code/include/layout.hpp b/code/include/layout.hpp index 1ee2fab..f935c7d 100644 --- a/code/include/layout.hpp +++ b/code/include/layout.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // layout.hpp // // Phase 5/6/7 — Layout / embedding: DOF vector → vertex coordinates in the diff --git a/code/include/matrix_utility.hpp b/code/include/matrix_utility.hpp index f18aee6..810c6fb 100644 --- a/code/include/matrix_utility.hpp +++ b/code/include/matrix_utility.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // 4x4 mapping matrix from corresponding point pairs. // Ported from de.varylab.discreteconformal.math.MatrixUtility (Java). diff --git a/code/include/mesh_builder.hpp b/code/include/mesh_builder.hpp index ef08784..47ed53b 100644 --- a/code/include/mesh_builder.hpp +++ b/code/include/mesh_builder.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // mesh_builder.hpp // // Factory functions that build simple reference meshes for testing and examples. diff --git a/code/include/mesh_io.hpp b/code/include/mesh_io.hpp index 0ac1fc1..778bfa0 100644 --- a/code/include/mesh_io.hpp +++ b/code/include/mesh_io.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // mesh_io.hpp // // Phase 4b — CGAL::IO wrappers for ConformalMesh. diff --git a/code/include/mesh_utils.hpp b/code/include/mesh_utils.hpp index bef7ce7..c513ba3 100644 --- a/code/include/mesh_utils.hpp +++ b/code/include/mesh_utils.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // mesh_utils.hpp // // Conversions between CGAL::Surface_mesh and Eigen matrices. Used diff --git a/code/include/newton_solver.hpp b/code/include/newton_solver.hpp index bf290e1..f456a07 100644 --- a/code/include/newton_solver.hpp +++ b/code/include/newton_solver.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // newton_solver.hpp // // Phase 4a — Newton solver for all three discrete conformal functionals. diff --git a/code/include/p2_utility.hpp b/code/include/p2_utility.hpp index d4f88ca..a8d2a90 100644 --- a/code/include/p2_utility.hpp +++ b/code/include/p2_utility.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // 2-D projective geometry utilities for the Euclidean signature. // Ported from de.jreality.math.P2 and de.varylab.discreteconformal.math.P2Big. diff --git a/code/include/period_matrix.hpp b/code/include/period_matrix.hpp index 86647e8..c0a27da 100644 --- a/code/include/period_matrix.hpp +++ b/code/include/period_matrix.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // period_matrix.hpp // // Phase 7 — Period matrix for closed surfaces with Euclidean (flat) metric. diff --git a/code/include/projective_math.hpp b/code/include/projective_math.hpp index 2c8f297..c4bc43e 100644 --- a/code/include/projective_math.hpp +++ b/code/include/projective_math.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Projective and hyperbolic geometry utilities. // Ported from de.jreality.math.Pn / Rn and diff --git a/code/include/serialization.hpp b/code/include/serialization.hpp index dce3048..0dbad15 100644 --- a/code/include/serialization.hpp +++ b/code/include/serialization.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // serialization.hpp // // Phase 5 — Save and load conformal map results in JSON and XML formats. diff --git a/code/include/spherical_functional.hpp b/code/include/spherical_functional.hpp index 7ae020b..0306b3d 100644 --- a/code/include/spherical_functional.hpp +++ b/code/include/spherical_functional.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // spherical_functional.hpp // // Energy and gradient of the spherical discrete conformal functional diff --git a/code/include/spherical_geometry.hpp b/code/include/spherical_geometry.hpp index 03933cc..88cc536 100644 --- a/code/include/spherical_geometry.hpp +++ b/code/include/spherical_geometry.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // spherical_geometry.hpp // // Pure-math building blocks for the spherical discrete conformal map. diff --git a/code/include/spherical_hessian.hpp b/code/include/spherical_hessian.hpp index 59570d8..6d57d61 100644 --- a/code/include/spherical_hessian.hpp +++ b/code/include/spherical_hessian.hpp @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // spherical_hessian.hpp // // Analytical Hessian of the spherical discrete conformal energy — diff --git a/code/include/viewer_utils.h b/code/include/viewer_utils.h index 4140d11..5b8fae8 100644 --- a/code/include/viewer_utils.h +++ b/code/include/viewer_utils.h @@ -1,4 +1,7 @@ #pragma once +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + #include #include diff --git a/code/src/apps/v0/conformallab_cli.cpp b/code/src/apps/v0/conformallab_cli.cpp index be3451e..09fb09d 100644 --- a/code/src/apps/v0/conformallab_cli.cpp +++ b/code/src/apps/v0/conformallab_cli.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // conformallab_cli.cpp // // ConformalLab++ command-line interface. diff --git a/code/src/viewer/simple_viewer.cpp b/code/src/viewer/simple_viewer.cpp index c15d14b..34a957f 100644 --- a/code/src/viewer/simple_viewer.cpp +++ b/code/src/viewer/simple_viewer.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + #include "viewer_utils.h" namespace viewer_utils { diff --git a/code/tests/cgal/test_cgal_phase8b_lite.cpp b/code/tests/cgal/test_cgal_phase8b_lite.cpp index 914adb2..9a78db7 100644 --- a/code/tests/cgal/test_cgal_phase8b_lite.cpp +++ b/code/tests/cgal/test_cgal_phase8b_lite.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_cgal_phase8b_lite.cpp // // Phase 8b-Lite — Smoke tests for the four new CGAL-style entry functions diff --git a/code/tests/cgal/test_cgal_traits_mvp.cpp b/code/tests/cgal/test_cgal_traits_mvp.cpp index 4d2f1dc..5767502 100644 --- a/code/tests/cgal/test_cgal_traits_mvp.cpp +++ b/code/tests/cgal/test_cgal_traits_mvp.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_cgal_traits_mvp.cpp // // Phase 8 MVP — first tests for the new CGAL-style public API. diff --git a/code/tests/cgal/test_conformal_mesh.cpp b/code/tests/cgal/test_conformal_mesh.cpp index 17f9d4a..eab8a01 100644 --- a/code/tests/cgal/test_conformal_mesh.cpp +++ b/code/tests/cgal/test_conformal_mesh.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_conformal_mesh.cpp // // Phase 3a — CGAL Surface_mesh infrastructure tests. diff --git a/code/tests/cgal/test_cp_euclidean_functional.cpp b/code/tests/cgal/test_cp_euclidean_functional.cpp index b10802f..80c7530 100644 --- a/code/tests/cgal/test_cp_euclidean_functional.cpp +++ b/code/tests/cgal/test_cp_euclidean_functional.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_cp_euclidean_functional.cpp // // Phase 9a.1 — CPEuclideanFunctional (BPS 2010) tests. diff --git a/code/tests/cgal/test_euclidean_functional.cpp b/code/tests/cgal/test_euclidean_functional.cpp index e6f3773..2046262 100644 --- a/code/tests/cgal/test_euclidean_functional.cpp +++ b/code/tests/cgal/test_euclidean_functional.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_euclidean_functional.cpp // // Phase 3d — EuclideanCyclicFunctional ported to ConformalMesh. diff --git a/code/tests/cgal/test_euclidean_hessian.cpp b/code/tests/cgal/test_euclidean_hessian.cpp index 8ce14c1..94829b7 100644 --- a/code/tests/cgal/test_euclidean_hessian.cpp +++ b/code/tests/cgal/test_euclidean_hessian.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_euclidean_hessian.cpp // // Phase 3f — Euclidean cotangent-Laplace Hessian. diff --git a/code/tests/cgal/test_geometry_utils.cpp b/code/tests/cgal/test_geometry_utils.cpp index 1f6f279..303ab48 100644 --- a/code/tests/cgal/test_geometry_utils.cpp +++ b/code/tests/cgal/test_geometry_utils.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_geometry_utils.cpp // // Port of the Java ConformalLab geometry utility tests. diff --git a/code/tests/cgal/test_hyper_ideal_functional.cpp b/code/tests/cgal/test_hyper_ideal_functional.cpp index 5e6e3f8..fabc536 100644 --- a/code/tests/cgal/test_hyper_ideal_functional.cpp +++ b/code/tests/cgal/test_hyper_ideal_functional.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_hyper_ideal_functional.cpp // // Phase 3b — HyperIdealFunctional ported to ConformalMesh. diff --git a/code/tests/cgal/test_hyper_ideal_hessian.cpp b/code/tests/cgal/test_hyper_ideal_hessian.cpp index b91b694..c4cf599 100644 --- a/code/tests/cgal/test_hyper_ideal_hessian.cpp +++ b/code/tests/cgal/test_hyper_ideal_hessian.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_hyper_ideal_hessian.cpp // // Phase 9b — Hyper-ideal Hessian: block-FD vs full-FD cross-validation. diff --git a/code/tests/cgal/test_inversive_distance_functional.cpp b/code/tests/cgal/test_inversive_distance_functional.cpp index 9d7fa68..d0826bd 100644 --- a/code/tests/cgal/test_inversive_distance_functional.cpp +++ b/code/tests/cgal/test_inversive_distance_functional.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_inversive_distance_functional.cpp // // Phase 9a.2 — Inversive-distance functional (Luo 2004) tests. diff --git a/code/tests/cgal/test_layout.cpp b/code/tests/cgal/test_layout.cpp index 18d16b8..a01c339 100644 --- a/code/tests/cgal/test_layout.cpp +++ b/code/tests/cgal/test_layout.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_layout.cpp // // Phase 5 — Layout / embedding tests. diff --git a/code/tests/cgal/test_mesh_io.cpp b/code/tests/cgal/test_mesh_io.cpp index a2c7649..f767211 100644 --- a/code/tests/cgal/test_mesh_io.cpp +++ b/code/tests/cgal/test_mesh_io.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_mesh_io.cpp // // Phase 4b — CGAL::IO mesh round-trip tests. diff --git a/code/tests/cgal/test_newton_phase9a.cpp b/code/tests/cgal/test_newton_phase9a.cpp index 8cb3948..03e5a1e 100644 --- a/code/tests/cgal/test_newton_phase9a.cpp +++ b/code/tests/cgal/test_newton_phase9a.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_newton_phase9a.cpp // // Phase 9a Newton solvers — convergence tests for the two new diff --git a/code/tests/cgal/test_newton_solver.cpp b/code/tests/cgal/test_newton_solver.cpp index dc80e54..d28a6c7 100644 --- a/code/tests/cgal/test_newton_solver.cpp +++ b/code/tests/cgal/test_newton_solver.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_newton_solver.cpp // // Phase 4 — Newton solver tests. diff --git a/code/tests/cgal/test_phase6.cpp b/code/tests/cgal/test_phase6.cpp index c616bed..f77dfaf 100644 --- a/code/tests/cgal/test_phase6.cpp +++ b/code/tests/cgal/test_phase6.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_phase6.cpp // // Phase 6 — Tests for: diff --git a/code/tests/cgal/test_phase7.cpp b/code/tests/cgal/test_phase7.cpp index bd2673a..d806572 100644 --- a/code/tests/cgal/test_phase7.cpp +++ b/code/tests/cgal/test_phase7.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_phase7.cpp // // Phase 7 — Tests for Java-parity layout features: diff --git a/code/tests/cgal/test_pipeline.cpp b/code/tests/cgal/test_pipeline.cpp index 17c3109..9ca62cb 100644 --- a/code/tests/cgal/test_pipeline.cpp +++ b/code/tests/cgal/test_pipeline.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_pipeline.cpp // // Phase 4c — End-to-end pipeline tests and library-user examples. diff --git a/code/tests/cgal/test_scalability_smoke.cpp b/code/tests/cgal/test_scalability_smoke.cpp index 8ef2ee2..fbe4b96 100644 --- a/code/tests/cgal/test_scalability_smoke.cpp +++ b/code/tests/cgal/test_scalability_smoke.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_scalability_smoke.cpp // // Scalability smoke tests — convergence on large real-world meshes. diff --git a/code/tests/cgal/test_spherical_functional.cpp b/code/tests/cgal/test_spherical_functional.cpp index dd4df6b..7b91c2b 100644 --- a/code/tests/cgal/test_spherical_functional.cpp +++ b/code/tests/cgal/test_spherical_functional.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_spherical_functional.cpp (Phase 3c + 3e) // // Phase 3c — SphericalFunctional ported to ConformalMesh. diff --git a/code/tests/cgal/test_spherical_hessian.cpp b/code/tests/cgal/test_spherical_hessian.cpp index ff3727d..f23b9c8 100644 --- a/code/tests/cgal/test_spherical_hessian.cpp +++ b/code/tests/cgal/test_spherical_hessian.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // test_spherical_hessian.cpp // // Phase 3f — Spherical cotangent-Laplace Hessian. diff --git a/code/tests/test_clausen.cpp b/code/tests/test_clausen.cpp index 2463910..ab1abfb 100644 --- a/code/tests/test_clausen.cpp +++ b/code/tests/test_clausen.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.functional.ClausenTest (Java/JUnit). // Reference values computed with Mathematica. diff --git a/code/tests/test_discrete_elliptic_utility.cpp b/code/tests/test_discrete_elliptic_utility.cpp index 9554ea1..34c7379 100644 --- a/code/tests/test_discrete_elliptic_utility.cpp +++ b/code/tests/test_discrete_elliptic_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.util.DiscreteEllipticUtilityTest (Java/JUnit). // Tests the normalizeModulus function that moves a complex number tau into the // fundamental domain of the modular group SL(2,Z). diff --git a/code/tests/test_hyper_ideal_utility.cpp b/code/tests/test_hyper_ideal_utility.cpp index 71220fc..8c68577 100644 --- a/code/tests/test_hyper_ideal_utility.cpp +++ b/code/tests/test_hyper_ideal_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.functional.HyperIdealUtilityTest (Java/JUnit). #include "hyper_ideal_utility.hpp" diff --git a/code/tests/test_hyper_ideal_visualization_utility.cpp b/code/tests/test_hyper_ideal_visualization_utility.cpp index 8f73f6b..acd3742 100644 --- a/code/tests/test_hyper_ideal_visualization_utility.cpp +++ b/code/tests/test_hyper_ideal_visualization_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.plugin.HyperIdealVisualizationPluginTest (Java/JUnit). // // Tests the conversion from a hyperbolic circle (hyperboloid model) diff --git a/code/tests/test_matrix_utility.cpp b/code/tests/test_matrix_utility.cpp index c300c8f..4bdd1db 100644 --- a/code/tests/test_matrix_utility.cpp +++ b/code/tests/test_matrix_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.math.MatrixUtilityTest (Java/JUnit). #include "matrix_utility.hpp" diff --git a/code/tests/test_p2_utility.cpp b/code/tests/test_p2_utility.cpp index 7ecade7..7e06671 100644 --- a/code/tests/test_p2_utility.cpp +++ b/code/tests/test_p2_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.math.P2BigTest (Java/JUnit). // Tests 2-D projective geometry utilities: perpendicular bisectors, // point-from-lines, and direct isometries in the Euclidean plane. diff --git a/code/tests/test_surface_curve_utility.cpp b/code/tests/test_surface_curve_utility.cpp index 85db577..5fa71c3 100644 --- a/code/tests/test_surface_curve_utility.cpp +++ b/code/tests/test_surface_curve_utility.cpp @@ -1,3 +1,6 @@ +// Copyright (c) 2024-2026 Tarik Moussa. +// SPDX-License-Identifier: MIT + // Port of de.varylab.discreteconformal.uniformization.SurfaceCurveUtilityTest // (Java/JUnit) — the two pure-math tests that don't need the HDS. diff --git a/scripts/quality/README.md b/scripts/quality/README.md index 8067971..5fe0fb8 100644 --- a/scripts/quality/README.md +++ b/scripts/quality/README.md @@ -20,7 +20,9 @@ consistency + markdown links + end-to-end smoke via `try_it.sh`). |---|---|---|---| | `license-headers.sh` | every C++ source carries `SPDX-License-Identifier: MIT` | ~1 s | `bash` | | `cgal-conventions.py` | CGAL-1…6: include-guard format, `\file` brief, namespace nesting, tag-naming, no `using namespace`, no stray `#define` | ~1 s | `python3` | -| `clang-format.sh` | every source file matches `.clang-format` (dry-run by default; `--fix` to apply) | ~2 s | `clang-format` ≥ 15 | +| `clang-format.sh` | every C++ source matches `.clang-format` (dry-run by default; `--fix` to apply) | ~2 s | `clang-format` ≥ 15 | +| `cmake-format.sh` | every `CMakeLists.txt` matches `.cmake-format.yaml` + passes `cmake-lint` | ~2 s | `cmake-format` (pip: cmakelang) | +| `codespell.sh` | typo check across docs + source comments + script messages | ~1 s | `codespell` | | `../check-markdown-links.py` | every internal markdown link resolves | ~2 s | `python3` | ### Correctness / quality gates (run before tagging or reviewer demos) diff --git a/scripts/quality/cmake-format.sh b/scripts/quality/cmake-format.sh new file mode 100755 index 0000000..9a1cbbf --- /dev/null +++ b/scripts/quality/cmake-format.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# scripts/quality/cmake-format.sh +# +# Run cmake-format (drift check) + cmake-lint (semantic check) over +# every CMakeLists.txt and *.cmake we own. Skips code/deps/. +# +# Local-only. Promotion to CI once the existing CMakeLists.txt files +# pass `--strict`. +# +# Usage: +# bash scripts/quality/cmake-format.sh # dry-run, exit 0 always +# bash scripts/quality/cmake-format.sh --strict # dry-run, exit 1 on drift +# bash scripts/quality/cmake-format.sh --fix # apply formatting in place +# +# Exit codes: +# 0 no drift, or drift but --strict not set; lint produced no errors +# 1 drift and --strict, or lint reported errors, or --fix applied +# 2 prerequisite missing + +set -uo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$ROOT" + +# Allow ~/.local/bin (pip-installed tools) in PATH. +export PATH="$HOME/.local/bin:$PATH" + +command -v cmake-format >/dev/null 2>&1 || { + echo "FAIL: cmake-format not in PATH." >&2 + echo " pip3 install --user cmakelang" >&2 + echo " export PATH=\"\$HOME/.local/bin:\$PATH\"" >&2 + exit 2 +} +command -v cmake-lint >/dev/null 2>&1 || { + echo "FAIL: cmake-lint not in PATH (ships with cmakelang)." >&2 + exit 2 +} + +STRICT=0 +FIX=0 +for arg in "$@"; do + case "$arg" in + --strict) STRICT=1 ;; + --fix) FIX=1 ;; + *) echo "Unknown arg: $arg" >&2; exit 2 ;; + esac +done + +FILES="$(find code \ + \( -name "CMakeLists.txt" -o -name "*.cmake" \) \ + -type f 2>/dev/null \ + | grep -v "/deps/" \ + | grep -v "/build" \ + | grep -v " 2\." \ + | sort)" + +if [ -z "$FILES" ]; then + echo "FAIL: no CMakeLists.txt files found" >&2 + exit 2 +fi + +echo "cmake-format ($(cmake-format --version 2>&1 | head -1))" +echo "cmake-lint ($(cmake-lint --version 2>&1 | head -1))" + +# ── Drift check / fix ────────────────────────────────────────────────────── +n_total=0 +n_drift=0 +drift_list="" +while IFS= read -r f; do + [ -z "$f" ] && continue + n_total=$((n_total + 1)) + if [ "$FIX" -eq 1 ]; then + cmake-format -i "$f" + else + if ! cmake-format --check "$f" >/dev/null 2>&1; then + n_drift=$((n_drift + 1)) + drift_list="$drift_list $f +" + fi + fi +done <&1 || true)" + if [ -n "$out" ]; then + echo "$out" + # Each warning line begins with the filename → count them. + cnt=$(printf '%s' "$out" | grep -c "^$f:" || true) + n_lint_err=$((n_lint_err + cnt)) + fi +done </dev/null 2>&1 || { + echo "FAIL: codespell not in PATH." >&2 + echo " macOS: brew install codespell" >&2 + echo " Linux: sudo apt install codespell OR pip3 install codespell" >&2 + exit 2 +} + +FIX=0 +for arg in "$@"; do + case "$arg" in + --fix) FIX=1 ;; + *) echo "Unknown arg: $arg" >&2; exit 2 ;; + esac +done + +# Targets: everything except deps + build + generated. +TARGETS=( + "doc" + "code/include" + "code/src" + "code/tests" + "scripts" + "README.md" + "CHANGELOG.md" + "CLAUDE.md" + "CITATION.cff" + "CONTRIBUTING.md" +) + +# Filter to existing entries (CONTRIBUTING.md / CHANGELOG.md may not exist +# on every branch). +EXISTING=() +for t in "${TARGETS[@]}"; do + [ -e "$t" ] && EXISTING+=("$t") +done + +echo "codespell ($(codespell --version 2>&1 | head -1))" +echo "Targets: ${EXISTING[*]}" +echo + +if [ "$FIX" -eq 1 ]; then + codespell --write-changes "${EXISTING[@]}" + rc=$? +else + codespell "${EXISTING[@]}" + rc=$? +fi + +if [ "$rc" -ne 0 ]; then + echo + echo "Recovery:" + echo " bash scripts/quality/codespell.sh --fix # apply" + echo " # or add false-positives to .codespellrc → ignore-words-list" + exit 1 +fi + +echo +echo "OK: no typos found." +exit 0 diff --git a/scripts/quality/license-headers.sh b/scripts/quality/license-headers.sh index b045df6..035decc 100755 --- a/scripts/quality/license-headers.sh +++ b/scripts/quality/license-headers.sh @@ -28,6 +28,53 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "$ROOT" SPDX="SPDX-License-Identifier: MIT" +COPYRIGHT="Copyright (c) 2024-$(date +%Y) Tarik Moussa." + +FIX=0 +for arg in "$@"; do + case "$arg" in + --fix) FIX=1 ;; + *) echo "Unknown arg: $arg (only --fix supported)" >&2; exit 2 ;; + esac +done + +# Insert a 2-line header at the top of $1, but BELOW any existing +# `#pragma once` so the include-guard role is preserved. Idempotent — +# the caller has already verified the SPDX line is missing. +insert_header () { + local f="$1" + local tmp + tmp="$(mktemp)" + local first_line + first_line="$(head -1 "$f")" + if echo "$first_line" | grep -q "^#pragma once"; then + # Header form 1: keep `#pragma once` on line 1, then license, then blank. + { + echo "$first_line" + echo "// $COPYRIGHT" + echo "// $SPDX" + echo + tail -n +2 "$f" + } > "$tmp" + elif echo "$first_line" | grep -q "^#ifndef"; then + # Header form 2: insert license ABOVE the include guard. + { + echo "// $COPYRIGHT" + echo "// $SPDX" + echo + cat "$f" + } > "$tmp" + else + # Other (most likely a .cpp): just prepend. + { + echo "// $COPYRIGHT" + echo "// $SPDX" + echo + cat "$f" + } > "$tmp" + fi + mv "$tmp" "$f" +} # Files to check: code/include + code/src + code/tests. Skip code/deps. FILES_LIST="$(find code/include code/src code/tests \ @@ -39,6 +86,7 @@ FILES_LIST="$(find code/include code/src code/tests \ n_total=0 n_missing=0 +n_fixed=0 missing_list="" while IFS= read -r f; do [ -z "$f" ] && continue @@ -46,6 +94,10 @@ while IFS= read -r f; do # Check only the first 30 lines — SPDX must be near the top. if ! head -30 "$f" | grep -q "$SPDX"; then n_missing=$((n_missing + 1)) + if [ "$FIX" -eq 1 ]; then + insert_header "$f" + n_fixed=$((n_fixed + 1)) + fi missing_list="$missing_list $f " fi @@ -60,14 +112,20 @@ fi echo "Checked $n_total source files for SPDX header." +if [ "$FIX" -eq 1 ]; then + if [ "$n_fixed" -gt 0 ]; then + echo "FIX mode: inserted '$SPDX' into $n_fixed file(s)." + echo " Review with: git diff" + exit 0 + fi +fi + if [ "$n_missing" -gt 0 ]; then echo echo "FAIL: $n_missing file(s) missing '$SPDX' in their first 30 lines:" printf '%s' "$missing_list" echo - echo "Recovery: add this two-line header at the top of each file:" - echo " // Copyright (c) 2024-$(date +%Y) Tarik Moussa." - echo " // $SPDX" + echo "Recovery: bash scripts/quality/license-headers.sh --fix" exit 1 fi diff --git a/scripts/quality/run-all.sh b/scripts/quality/run-all.sh index 43a6796..22d2d24 100755 --- a/scripts/quality/run-all.sh +++ b/scripts/quality/run-all.sh @@ -37,6 +37,8 @@ GATES_FAST=( "License headers | bash scripts/quality/license-headers.sh" "CGAL conventions | python3 scripts/quality/cgal-conventions.py" "clang-format drift | bash scripts/quality/clang-format.sh" + "cmake-format/-lint | bash scripts/quality/cmake-format.sh" + "codespell | bash scripts/quality/codespell.sh" "Markdown links | python3 scripts/check-markdown-links.py" "Sanitizers | bash scripts/quality/sanitizers.sh" "clang-tidy | bash scripts/quality/clang-tidy.sh"