Open ZedThree opened 2 weeks ago
The linked rule tries to avoid catching invalid characters in comments or strings. My idea for avoiding those in all text-based rules is to perform a first pass over the code to replace all characters in comments with more exclamation marks, and replace every character inside strings with a space. This would make it much easier to write any regex-based rules, and we would still be able to get lines/columns right for rules like line length. The annotations would still be built using the original unaltered code.
See: https://github.com/MetOffice/stylist/blob/b121ef846eb0ac8a02eff469b04dbc16d7f034cb/source/stylist/fortran.py#L76-L86
e.g. Tabs are technically not valid in Fortran source