Skip to content

Commit 23bc091

Browse files
committed
Merge branch 'topic/509' into 'master'
Do not rely on Full_Name when processing rule files Closes #509 See merge request eng/libadalang/langkit-query-language!492
2 parents 7b7a1ad + 80689e4 commit 23bc091

File tree

6 files changed

+61
-3
lines changed

6 files changed

+61
-3
lines changed

lkql_checker/src/rules_factory.adb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
-- SPDX-License-Identifier: GPL-3.0-or-later
44
--
55

6+
with Ada.Containers.Ordered_Sets;
67
with Ada.Environment_Variables;
78

89
with GNAT.OS_Lib;
@@ -35,9 +36,12 @@ package body Rules_Factory is
3536
(Ctx : L.Analysis_Context; Dirs : Path_Array := No_Paths)
3637
return Rule_Vector
3738
is
39+
package Virtual_File_Sets is new
40+
Ada.Containers.Ordered_Sets (Element_Type => Virtual_File);
41+
3842
Rules_Dirs : constant Virtual_File_Array := Get_Rules_Directories (Dirs);
3943
Rules : Rule_Vector := Rule_Vectors.Empty_Vector;
40-
Seen : String_Sets.Set := String_Sets.Empty_Set;
44+
Seen : Virtual_File_Sets.Set := Virtual_File_Sets.Empty_Set;
4145
Impacts : constant JSON_Value := Get_Impacts (Rules_Dirs);
4246

4347
begin
@@ -53,7 +57,7 @@ package body Rules_Factory is
5357
begin
5458
for File of Dir.all loop
5559
if File.File_Extension = +".lkql"
56-
and then not Seen.Contains (+File.Full_Name)
60+
and then not Seen.Contains (File)
5761
then
5862
declare
5963
Rc : Rule_Command;
@@ -64,7 +68,7 @@ package body Rules_Factory is
6468
begin
6569
if Has_Rule then
6670
Rules.Append (Rc);
67-
Seen.Include (+File.Full_Name);
71+
Seen.Include (File);
6872
end if;
6973
end;
7074
end if;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Prj is
2+
end Prj;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@check(help="help", message="message")
2+
fun my_rule(node) =
3+
node is DefiningName
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Test is -- FLAG
2+
begin
3+
null;
4+
end;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
1. Summary
2+
3+
fully compliant sources : 0
4+
sources with exempted violations only : 0
5+
sources with non-exempted violations : 1
6+
unverified sources : 0
7+
total sources : 1
8+
ignored sources : 0
9+
10+
non-exempted violations : 1
11+
rule exemption warnings : 0
12+
compilation errors : 0
13+
exempted violations : 0
14+
internal errors : 0
15+
16+
2. Exempted Coding Standard Violations
17+
18+
no exempted violations detected
19+
20+
3. Non-exempted Coding Standard Violations
21+
22+
test.adb:1:11: rule violation: message
23+
24+
4. Rule exemption problems
25+
26+
no rule exemption problems detected
27+
28+
5. Language violations
29+
30+
no language violations detected
31+
32+
6. Gnatcheck internal errors
33+
34+
no internal error detected
35+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
description: |
2+
Ensure GNATCheck can handle several times the same rule directory and properly
3+
builds a set of unique rules.
4+
driver: gnatcheck
5+
project: prj.gpr
6+
rules_dirs:
7+
- rules
8+
- ./rules/../rules
9+
rules:
10+
- +Rmy_rule

0 commit comments

Comments
 (0)