-
Notifications
You must be signed in to change notification settings - Fork 4
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
Rule: multiple-statements-per-line
#246
base: main
Are you sure you want to change the base?
Conversation
Could you do this without the blanking by something like: find |
As far as I can tell |
While working on this further I've found something that might be a program p
implicit none
integer :: i, j
! 1st, 2nd/3rd, and 4th semicolons are superfluous
! 3rd/2nd separates the two statements
;i = 1;; j = 2;
write (*,*) i, j
end program p It doesn't like a semicolon at the start of a line or multiples grouped together. I can't see a single instance of either one of these scenarios in my limited collection of test projects, so this is a very low priority bug. |
I've added a rule Blanking all comments and strings is a very expensive operation, and as we can't have one rule return multiple kinds of violation, it has to be done twice per file if both rules are active. Benchmarking suggests this slows the code by ~7%: ❯ hyperfine -i './target/release/fortitude check --output-format=concise --preview --ignore=S081,S082 ../geos-chem'
Benchmark 1: ./target/release/fortitude check --output-format=concise --preview --ignore=S081,S082 ../geos-chem
Time (mean ± σ): 1.763 s ± 0.046 s [User: 8.042 s, System: 0.396 s]
Range (min … max): 1.684 s … 1.808 s 10 runs
Warning: Ignoring non-zero exit code.
❯ hyperfine -i './target/release/fortitude check --output-format=concise --preview ../geos-chem'
Benchmark 1: ./target/release/fortitude check --output-format=concise --preview ../geos-chem
Time (mean ± σ): 1.883 s ± 0.075 s [User: 8.973 s, System: 0.414 s]
Range (min … max): 1.761 s … 1.996 s 10 runs
Warning: Ignoring non-zero exit code.
The difference would be a lot less noticeable in a realistic IO-constrained run ( @ZedThree Would it be possible to have |
Ah, I think the issue is that "end-of-statement" is an unnamed node and done entirely through an external scanner. We could change the grammar to something like:
|
Fixes #64
This was a lot harder to implement than I expected!
I've left this as a draft as I'd like to add a companion rule,
superfluous-semicolon
, for a semicolon at the end of a line, and I still need to add tests.