nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
41.3k stars 6.58k forks source link

Use Clang-Format #4226

Open nlohmann opened 7 months ago

nlohmann commented 7 months ago

This PR replaces Artistic Style by Clang-Format as tool to indent the code. Astyle introduced a breaking change a while ago which made working with the tool very cumbersome.

github-actions[bot] commented 7 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @nlohmann Please read and follow the Contribution Guidelines.

coveralls commented 7 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling af3f87e84e63e883701502f5c6338d025593362b on clang-format into 9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03 on develop.

github-actions[bot] commented 7 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @nlohmann Please read and follow the Contribution Guidelines.

github-actions[bot] commented 7 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @nlohmann Please read and follow the Contribution Guidelines.

github-actions[bot] commented 7 months ago

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @nlohmann Please read and follow the Contribution Guidelines.

nlohmann commented 7 months ago

I call it a day. There seems to be some work needed to move the NOLINT comments to the right place after reformatting. Could have been crazy to expect Clang-Format to know what Clang-Tidy is doing...

Furthermore, there seems to be the same version nightmare as with astyle. I am using Clang-Format 17.0.6 locally and Clang-Format 18.0.0 in the CI, and already the results are not the same. Not sure how to make it easy for contributors to use the "right" version.

Finally, Clang-Format is incredibly slow. Like 7 minutes to format single_include/json.hpp. Astyle took some seconds.

I'll pick this up next week.

t-b commented 7 months ago

I am using Clang-Format 17.0.6 locally and Clang-Format 18.0.0 in the CI, and already the results are not the same.

This is to be expected unforunately. Due to the complexity the devs decided not to be backwards compatible for every edge case.

Finally, Clang-Format is incredibly slow. Like 7 minutes to format single_include/json.hpp. Astyle took some seconds.

clang-format 17.03 takes here ~19minutes locally.