fortran-lang / fprettify

auto-formatter for modern fortran source code
https://pypi.python.org/pypi/fprettify
Other
376 stars 78 forks source link

Introduce automatic splitting of long lines #6

Open pseewald opened 8 years ago

pseewald commented 8 years ago

It's a useful feature and should not be too hard to implement

giovannipizzi commented 6 years ago

Hi, at the moment even if the splitting is not done automatically, I would like to stop as an error if the line is too long, and switching this on with a command-line switch. The reason is that I'm using

By looking at the code, the way I would do it is to have a flag that converts WARNING level logs to errors and stop. What do you think? (Another option: if there is any output from the code, then stop) Or is there an easy way to say to pre-commit "if there is output in stderr, please stop"?

pseewald commented 6 years ago

I'd prefer to not introduce such a flag and to stop only for failures. It is not a problem for fprettify to handle long lines. As long as the input code is standard conforming, fprettify should not stop with an error. So I leave it up to you to check the warning message (but I don't know how to do that with pre-commit).

giovannipizzi commented 6 years ago

I see your point, but at the moment the indentation is wrong and until this issue is fixed we get a "wrong" output... a person can easily split and run again fprettify.

I understand you don't want to change the code, but would you accept an extension (optional for users) to the pre-commit file in your repo, that wraps fprettify and exits with a non-zero error code if there is any output? Most people wouldn't notice but I could use it.

giovannipizzi commented 6 years ago

Never mind, I think I found a way to do this directly in my repo: https://github.com/giovannipizzi/wannier90/commit/01d1231e64f6d80a51054bc003fd0cac5fb9d98a

varchasgopalaswamy commented 4 years ago

is line splitting going to be implemented? It would be very helpful for legacy code

pseewald commented 4 years ago

I still agree that this should be a feature, unfortunately I won't have time in the near future to implement this.