[MapServer-dev] Whole code base reformatting

Michael Smith michael.smith.erdc at gmail.com
Thu Sep 28 12:58:55 PDT 2023


On 9/28/23, 3:56 PM, "MapServer-dev on behalf of jbo-ads--- via MapServer-dev" <mapserver-dev-bounces at lists.osgeo.org <mailto:mapserver-dev-bounces at lists.osgeo.org> on behalf of mapserver-dev at lists.osgeo.org <mailto:mapserver-dev at lists.osgeo.org>> wrote:



Le 28/09/2023 à 16:24, Even Rouault via MapServer-dev a écrit :
> Hi,
> Below text from https://github.com/MapServer/MapServer/pull/6937 <https://github.com/MapServer/MapServer/pull/6937>:
> I propose to apply to Mapserver the same set of tools that have been 
> applied to GDAL and PROJ recently to have consistent code formatting 
> for C/C++ and .py files
> This uses the pre-commit tool that installs hooks run by git commit to 
> automatically apply the formatting rules:
> - clang-format for C/C++ code using a .clang-format style based on the 
> LLVMStyle with a minimal customization to do 2-space indentation 
> (which is the general practice in Mapserver), and not sorting includes 
> (as this breaks compilation due to includes unfortunately not being 
> clean/standalone, with inconsistencies like "a.h needs a type of b.h, 
> but b.h includes a.h"). Third-party code is excluded from reformating 
> (in .pre-commit-config.yaml)
> - black and isort to format Python code
> - flake8 to enforce some rules on Python code (with tons of exceptions 
> in .flake8, directly borrowed from the ones of GDAL). I had to 
> manually fixup a few things in the .py files
> Cf https://gdal.org/development/rfc/rfc69_cplusplus_formatting.html <https://gdal.org/development/rfc/rfc69_cplusplus_formatting.html> on 
> how to install pre-commit (one time operation to do), and 
> https://gdal.org/development/dev_practices.html#commit-hooks <https://gdal.org/development/dev_practices.html#commit-hooks>
> A .git-blame-ignore-revs file is also added to identify the 
> reformatting commit as to be ignored for the purpose of "git blame". 
> It needs to be manually declared to git with "git config 
> blame.ignoreRevsFile .git-blame-ignore-revs", for local use (one time 
> operation) but it is automatically pickedup by GitHub.
> We should probably apply that to the stable branch as well to make 
> backports easier.
> This also adds a .github/workflows/code_checks.yml GitHub Action that 
> runs pre-commit on pull requests to detect violations. Such sitaution 
> shouldn't happen for developers that have already set it up locally, 
> but useful to catch issues coming from casual contributors (e.g. 
> simulation of a commit that would break formatting: 
> https://github.com/rouault/mapserver/actions/runs/6340096023/job/17220740975 <https://github.com/rouault/mapserver/actions/runs/6340096023/job/17220740975>)
> Upon acceptance, I'll add a "Code formatting rules" section to 
> https://mapserver.org/development/index.html <https://mapserver.org/development/index.html> to gather all above 
> information
> Even

MapServer-dev mailing list
MapServer-dev at lists.osgeo.org <mailto:MapServer-dev at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/mapserver-dev <https://lists.osgeo.org/mailman/listinfo/mapserver-dev>

More information about the MapServer-dev mailing list