pecos / tps

Torch Plasma Simulator
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

add a code style checker mechanism #64

Closed koomie closed 3 years ago

koomie commented 3 years ago

I tend to like elements from https://google.github.io/styleguide/cppguide.html

koomie commented 3 years ago

With the changes from #66, two new build targets have been introduced and are highlighted below. License headers have been added to all .cpp/.hpp files in src and formatting changes have been applied to meet the style guidelines. Finally, an additional CI job is added to check the code style.

  1. Check source code files in src/ using the cpplint tool from https://github.com/cpplint/cpplint. This python script is included now in utils/cpplint. Note that this check will not modify any files.
$ make style
Making style in src
make[1]: Entering directory '/home/karl/repos/tps/src'

-------------------------------------------
Checking source code style using cpplint.py
-------------------------------------------

Done processing BCintegrator.cpp
Done processing BCintegrator.hpp
Done processing BoundaryCondition.cpp
Done processing BoundaryCondition.hpp
Done processing M2ulPhyS.cpp
Done processing M2ulPhyS.hpp
Done processing averaging_and_rms.cpp
Done processing averaging_and_rms.hpp
Done processing dataStructures.hpp
Done processing dgNonlinearForm.cpp
Done processing dgNonlinearForm.hpp
Done processing dgNonlinearForm.hpp
Done processing domain_integrator.cpp
Done processing domain_integrator.hpp
Done processing equation_of_state.cpp
Done processing equation_of_state.hpp
Done processing faceGradientIntegration.cpp
Done processing faceGradientIntegration.hpp
Done processing face_integrator.cpp
Done processing face_integrator.hpp
Done processing fluxes.cpp
Done processing fluxes.hpp
Done processing forcing_terms.cpp
Done processing forcing_terms.hpp
Done processing gradNonLinearForm.cpp
Done processing gradNonLinearForm.hpp
Done processing gradients.cpp
Done processing inletBC.cpp
Done processing inletBC.hpp
Done processing io.cpp
Done processing io.hpp
Done processing masa_handler.cpp
Done processing masa_handler.hpp
Done processing mpi_groups.cpp
Done processing mpi_groups.hpp
Done processing outletBC.cpp
Done processing outletBC.hpp
Done processing rhs_operator.cpp
Done processing rhs_operator.hpp
Done processing riemann_solver.cpp
Done processing riemann_solver.hpp
Done processing run_configuration.cpp
Done processing run_configuration.hpp
Done processing sbp_integrators.cpp
Done processing sbp_integrators.hpp
Done processing utils.cpp
Done processing wallBC.cpp
Done processing wallBC.hpp
  1. Modify files to enforce google c++ style using clang-format. Note that this binary must be present locally and is not carried in our repo. Caveat: the MFEM macros like MFEM_FORALL_2D confuse the linter and clang-format and can result in odd file indentation.
$ make enforcestyle
koomie commented 3 years ago

Small addendum to the make enforcestyle target. Instead of using clang-format, PR #66 was updated to use astyle instead which does not introduce code formatting problems with the MFEM GPU for macros.

Completed with landing of #66.