Skip to content

Commit

Permalink
Ignore accept statement bodies in 'one_construct_per_line'
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoGGuerrier committed Oct 29, 2024
1 parent ef4aa57 commit b378f42
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lkql_checker/share/lkql/one_construct_per_line.lkql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fun one_construct_per_line(node) =
LabelDecl | GenericSubpInternal |
ConcreteFormalSubpDecl |
ExtendedReturnStmtObjectDecl |
NamedStmtDecl))
NamedStmtDecl | AcceptStmtBody))
and (node.token_end().end_line ==
stdlib.next_non_blank_token_line(node.token_end())
or node.token_start().start_line ==
Expand Down
21 changes: 21 additions & 0 deletions testsuite/tests/checks/one_construct_per_line/line.adb
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
package body Line is

task type Tsk is
entry Start (I : Integer; B : Boolean); -- NOFLAG
end Tsk;

task type Other_Tsk is
entry Start (I : Integer; B : Boolean); -- NOFLAG
end Other_Tsk;

task body Tsk is
begin
accept Start (I : Integer; B : Boolean) do -- NOFLAG
null;
end Start;
end Tsk;

task body Other_Tsk is
begin
accept Start (I : Integer; B : Boolean) do null; -- FLAG
end Start;
end Other_Tsk;

procedure Proc (I : in out Integer) is
Tmp : Integer;

Expand Down
48 changes: 26 additions & 22 deletions testsuite/tests/checks/one_construct_per_line/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,50 @@ line.ads:9:14: rule violation: more than one construct on the same line
9 | procedure Proc (I : in out Integer); end Line; -- FLAG
| ^^^^

line.adb:8:7: rule violation: more than one construct on the same line
8 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
| ^^
line.adb:20:50: rule violation: more than one construct on the same line
20 | accept Start (I : Integer; B : Boolean) do null; -- FLAG
| ^^^^^

line.adb:8:21: rule violation: more than one construct on the same line
8 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
| ^^
line.adb:29:7: rule violation: more than one construct on the same line
29 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
| ^^

line.adb:12:10: rule violation: more than one construct on the same line
12 | I := J; if I > 0 then -- FLAG (2)
line.adb:29:21: rule violation: more than one construct on the same line
29 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
| ^^

line.adb:33:10: rule violation: more than one construct on the same line
33 | I := J; if I > 0 then -- FLAG (2)
| ^^^^^^^

line.adb:12:18: rule violation: more than one construct on the same line
12 | I := J; if I > 0 then -- FLAG (2)
line.adb:33:18: rule violation: more than one construct on the same line
33 | I := J; if I > 0 then -- FLAG (2)
| __________________^
13 || I := 0; end if; -- FLAG
34 || I := 0; end if; -- FLAG
||__________________________^

line.adb:13:12: rule violation: more than one construct on the same line
13 | I := 0; end if; -- FLAG
line.adb:34:12: rule violation: more than one construct on the same line
34 | I := 0; end if; -- FLAG
| ^^^^^^^

line.adb:26:18: rule violation: more than one construct on the same line
26 | My_Loop_2: for I in 1 .. 2 loop -- FLAG
line.adb:47:18: rule violation: more than one construct on the same line
47 | My_Loop_2: for I in 1 .. 2 loop -- FLAG
| __________________^
||
|| ~~~ 1 other lines ~~~
||
28 || end loop My_Loop_2;
49 || end loop My_Loop_2;
||_________________________^

line.adb:30:7: rule violation: more than one construct on the same line
30 | Tmp := I; I := I + 1; -- FLAG (2)
line.adb:51:7: rule violation: more than one construct on the same line
51 | Tmp := I; I := I + 1; -- FLAG (2)
| ^^^^^^^^^

line.adb:30:17: rule violation: more than one construct on the same line
30 | Tmp := I; I := I + 1; -- FLAG (2)
line.adb:51:17: rule violation: more than one construct on the same line
51 | Tmp := I; I := I + 1; -- FLAG (2)
| ^^^^^^^^^^^

line.adb:32:7: rule violation: more than one construct on the same line
32 | I := I + 1; end Proc; -- FLAG
line.adb:53:7: rule violation: more than one construct on the same line
53 | I := I + 1; end Proc; -- FLAG
| ^^^^^^^^^^^

0 comments on commit b378f42

Please sign in to comment.