The [rstrip-whitespace.py](https://github.com/geany/geany/blob/master/scripts/rstrip-whitespace.py) script contains redundant code.
This script performed the operation of applying [rstrip()](https://docs.python.org/3/library/stdtypes.html#str.rstrip) to all lines in a file three consecutive times. This a case of belt, suspenders and a safety pin. Only one such operation is required. Let's pick one possibly dependent on the size of the input file.
I suggest using [timeit ](https://docs.python.org/3/library/timeit.html)to determine which method has the best performance and under what circumstance each may be required in order to perform successfully for files up to some maximum size.
The aforementioned maximum size needs to be established.
I am willing to offer a patch.
No, it only applys it to each line once, the second rstrip call is to the whole contents, not sure what it and the third manual removal is for, I suspect that could be removed but maybe there is/was a Windows/python 2 reason?
That said, probably the whole script could be removed since Geany itself can do those things and wholesale applying it to files is risky since in markdown two trailing spaces are markup.
github-comments@lists.geany.org