-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow user to overwrite line-length flags for gfortran linter #924
Allow user to overwrite line-length flags for gfortran linter #924
Conversation
Codecov Report
@@ Coverage Diff @@
## main #924 +/- ##
==========================================
+ Coverage 83.58% 83.60% +0.01%
==========================================
Files 12 12
Lines 2303 2305 +2
Branches 205 205
==========================================
+ Hits 1925 1927 +2
Misses 373 373
Partials 5 5
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good, nice catch. Can you also update the CHANGELOG and add a comment in the source-code about why we use unshift
there.
I think this warrants a more robust fix in the future, but it looks good for now.
Currently, the default line length arguments for the gfortran linter are appended AFTER the users extraArgs. Since in gfortran, the last occurrence of an argument that is passed multiple times will be taken, the default line length arguments will always overwrite what a user has explicitly set in extraArgs. By prepending the default line length arguments instead, a user should now have the possibility to overwrite the default.
1b6f4c1
to
3485ae0
Compare
Done.
Yes, that was my impression as well. If you have any specific idea how this should be handled, let me know and I would be glad to create a subsequent PR. |
Thanks @albertziegenhagel for the PR. The more robust way will be to add a separate diagnostic option in fortls, propagate that option to vscode, and if an option that overrides the fortls line length diagnostics (, or linter defaults) is specified in the |
Currently, the code appends
-ffree-line-length-none
and-ffixed-line-length-none
by default to the argument list when invokinggfortran
as linter. While it is possible to overwrite the line-length by settingfortls.maxLineLength
, this does only allow to set the same value for both, free-form as well es fixed-form Fortran code. What I need is to keep the common default values (72 for fixed-form and 132 (or none) for free-form Fortran).A comment in the code at src/lint/provider.ts#L554 states that it should be possible to overwrite those defaults by setting them explicitly in
extraArgs
, but this does not currently work. The reason is that the default arguments are pushed to the argument list after the user provided arguments. Hence the defaults will always overwrite the user provided flags.The proposed fix here is to put the default arguments before the user provided flags. This way, if a user puts
-ffixed-line-length-X
or-ffree-line-length-X
intoextraArgs
, these will always overwrite the defaults.If there is any other preferred way to solve this issue, just let me know and I will update the PR. I choose the current approach because it seemed to be the least invasive change and the comment in the code made me feel that this was actually the desired behavior in the first place.