Trim trailing whitespaces in all codebase
In the programming community, trailing whitespaces are generally perceived as a bad practice, since they do not have advantages but introduce many problems, including causing unnecessary diff changes. With commit 8569864c, modern IDEs are now able to automatically trim trailing whitespaces in files touched by the users. However, there are still many lingering trailing whitespaces in the codebase.
This issue proposes to clean the entire codebase by trimming trailing whitespaces in all text files. For that purpose, I submitted MR !839 (closed), which adds a very simple bash script utils/trim-trailing-whitespaces.sh
that trims trailing whitespaces in all text files in a given directory (e.g., the ns-3 root directory or a specific subdirectory). For comments regarding the script itself, please refer to the corresponding MR. The script can be further extended to exclude certain paths, files or file extensions.
To check that this script does not change any functionality, I created a branch in my fork and applied this change. The results of the CI/CD pipeline can be checked here. There were 1400+ files touched by this script. Therefore, my suggestion is to either apply this script to the entire codebase at once, or split it in smaller commits (one for each subdirectory, for instance). I incline to the latter, since it generates smaller commits that are more manageable to be processed.
I understand that this might affect some pending MRs, as they might need to be rebased. However, I think that this clean-up will avoid problems in the future.
In the future, this script may be added as a pre-commit hook to ensure all files respect this convention, although modern IDEs already respect the rules defined in .editorconfig
.