Skip to content

Commit 79c2cc8

Browse files
raph-amiardHugoGGuerrier
authored andcommitted
Do all requested renamings
1 parent bc5716d commit 79c2cc8

File tree

15 files changed

+58
-46
lines changed

15 files changed

+58
-46
lines changed

lkql_checker/doc/generated/list_of_rules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ GNATcheck rules.
140140
* :ref:`Overloaded_Operators`
141141
* :ref:`Overly_Nested_Control_Structures`
142142
* :ref:`Overly_Nested_Scopes`
143-
* :ref:`Overriding_Marks`
143+
* :ref:`Overriding_Indicators`
144144
* :ref:`Parameters_Aliasing`
145145
* :ref:`Parameters_Out_Of_Order`
146146
* :ref:`POS_On_Enumeration_Types`

lkql_checker/doc/generated/predefined_rules.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6251,12 +6251,12 @@ first construct is flagged
62516251
62526252
62536253
6254-
.. _Overriding_Marks:
6254+
.. _Overriding_Indicators:
62556255

6256-
``Overriding_Marks``
6257-
^^^^^^^^^^^^^^^^^^^^
6256+
``Overriding_Indicators``
6257+
^^^^^^^^^^^^^^^^^^^^^^^^^
62586258

6259-
.. index:: Overriding_Marks
6259+
.. index:: Overriding_Indicators
62606260

62616261
Check that overriding subprograms are explicitly marked as such.
62626262

lkql_checker/share/lkql/lowercase_keywords.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fun lowercase_keywords(unit, language_version="ada_2022") =
4545
|" packagE Foo is -- FLAG
4646
|" END Foo; -- FLAG
4747
[
48-
{message: "Keyword should be lowercase", loc: tok}
48+
{message: "reserved words should be lowercase", loc: tok}
4949
for tok in unit.tokens
5050
if tok.text.to_lower_case.contains(keyword_matcher(language_version))
5151
and not tok.previous().kind == "tick"

lkql_checker/share/lkql/no_dependence.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import stdlib
22

3-
@check(category="Style", subcategory="Readability", message="Forbidden dependency")
3+
@check(category="Style", subcategory="Readability", message="forbidden dependence")
44
fun no_dependence(node, unit_names=[]) =
55
|" Flag every explicit dependency (with clause) to any of the library units
66
|" designated by names passed as parameters.

lkql_checker/share/lkql/overriding_marks.lkql renamed to lkql_checker/share/lkql/overriding_indicators.lkql

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,23 @@ fun match_signature(child_prim, parent_prim, child_type, parent_type) =
4242
}
4343
}
4444

45-
@check(category="Style", subcategory="Readability", message="Missing overriding mark")
46-
fun overriding_marks(node) =
45+
fun is_overriding_subprogram(node) =
46+
|" Returns whether the node passed as argument corresponds to an overriding
47+
|" subprogram
48+
node is (BasicSubpDecl | BaseSubpBody) (
49+
p_subp_spec_or_null(): BaseSubpSpec(
50+
p_primitive_subp_first_type(): t@TypeDecl(
51+
p_base_type(): bt@TypeDecl(
52+
p_get_primitives(): primitives@(not null)
53+
when stdlib.any([p for p in primitives if match_signature(node, p, t, bt)])
54+
)
55+
)
56+
)
57+
)
58+
59+
60+
@check(category="Style", subcategory="Readability", message="missing overriding indicator")
61+
fun overriding_indicators(node) =
4762
|" Check that overriding subprograms are explicitly marked as such.
4863
|"
4964
|" This applies to all subprograms of a derived type that override a
@@ -70,18 +85,15 @@ fun overriding_marks(node) =
7085
|" procedure Prim (Self : B) is null; -- FLAG
7186
|" end Foo;
7287
# Select primitives subprograms
73-
node is (BasicSubpDecl | BaseSubpBody) (
74-
p_subp_spec_or_null(): BaseSubpSpec(
75-
p_primitive_subp_first_type(): t@TypeDecl(
76-
p_base_type(): bt@TypeDecl(
77-
p_get_primitives(): primitives@(not null)
78-
when stdlib.any([p for p in primitives if match_signature(node, p, t, bt)])
79-
)
80-
)
81-
),
82-
f_overriding: OverridingUnspecified
88+
(
89+
node is (BasicSubpDecl | BaseSubpBody) (f_overriding: OverridingUnspecified)
90+
when is_overriding_subprogram(node)
8391
)
8492

8593
# Body stubs can also take an "overriding" indicator. In that case, check
8694
# the body.
87-
or node is SubpBodyStub(p_previous_part_for_decl(): dcl) when overriding_marks(dcl)
95+
or (
96+
node is SubpBodyStub(p_previous_part_for_decl(): dcl,
97+
f_overriding: OverridingUnspecified)
98+
when is_overriding_subprogram(dcl)
99+
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
test_83.adb:1:1: rule violation: Keyword should be lowercase
1+
test_83.adb:1:1: rule violation: reserved words should be lowercase
22
1 | procedurE Test_83 IS -- FLAG (2)
33
| ^^^^^^^^^
44

5-
test_83.adb:1:19: rule violation: Keyword should be lowercase
5+
test_83.adb:1:19: rule violation: reserved words should be lowercase
66
1 | procedurE Test_83 IS -- FLAG (2)
77
| ^^
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
test_95.adb:2:14: rule violation: Keyword should be lowercase
1+
test_95.adb:2:14: rule violation: reserved words should be lowercase
22
2 | type A is Abstract Tagged null record; -- FLAG (2)
33
| ^^^^^^^^
44

5-
test_95.adb:2:23: rule violation: Keyword should be lowercase
5+
test_95.adb:2:23: rule violation: reserved words should be lowercase
66
2 | type A is Abstract Tagged null record; -- FLAG (2)
77
| ^^^^^^
88

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
test.adb:1:1: rule violation: Keyword should be lowercase
1+
test.adb:1:1: rule violation: reserved words should be lowercase
22
1 | procedurE Test is -- FLAG
33
| ^^^^^^^^^
44

5-
test.adb:5:4: rule violation: Keyword should be lowercase
5+
test.adb:5:4: rule violation: reserved words should be lowercase
66
5 | DECLARE -- FLAG
77
| ^^^^^^^
88

9-
test.adb:7:7: rule violation: Keyword should be lowercase
9+
test.adb:7:7: rule violation: reserved words should be lowercase
1010
7 | NULL; -- FLAG
1111
| ^^^^
1212

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
test.adb:1:6: rule violation: Forbidden dependency
1+
test.adb:1:6: rule violation: forbidden dependence
22
1 | with Ada.Unchecked_Conversion; -- FLAG
33
| ^^^^^^^^^^^^^^^^^^^^^^^^
44

5-
test.adb:2:6: rule violation: Forbidden dependency
5+
test.adb:2:6: rule violation: forbidden dependence
66
2 | with Unchecked_Conversion; -- FLAG
77
| ^^^^^^^^^^^^^^^^^^^^
88

0 commit comments

Comments
 (0)