Skip to content

Commit 9bff594

Browse files
committed
Rework the 'Metrics Related' documentation to include the 'N' parameter in all rules
Do this to avoid confusion when reading the GNATcheck RM and to don't rely on the fact that the reader should have the context of "Metrics Related Rules" heading section when reading a rule documentation.
1 parent af6f4b8 commit 9bff594

File tree

5 files changed

+56
-66
lines changed

5 files changed

+56
-66
lines changed

lkql_checker/doc/generated/predefined_rules.rst

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7927,9 +7927,6 @@ LKQL rule options files:
79277927
The rules in this section can be used to enforce compliance with
79287928
specific code metrics, by checking that the metrics computed for a program
79297929
lie within user-specifiable bounds.
7930-
Depending on the metric, there may be a lower bound, an upper bound, or both.
7931-
A construct is flagged if the value of the metric exceeds the upper bound
7932-
or is less than the lower bound.
79337930

79347931
The name of any metrics rule consists of the prefix ``Metrics_``
79357932
followed by the name of the corresponding metric:
@@ -7939,25 +7936,6 @@ followed by the name of the corresponding metric:
79397936
The meaning and the computed values of the metrics are
79407937
the same as in *gnatmetric*.
79417938

7942-
For the ``+R`` option, each metrics rule has a numeric parameter
7943-
specifying the bound (integer or real, depending on a metric).
7944-
7945-
*Example:* the rule
7946-
7947-
::
7948-
7949-
+RMetrics_Cyclomatic_Complexity : 7
7950-
7951-
7952-
means that all bodies with cyclomatic complexity exceeding 7 will be flagged.
7953-
7954-
To turn OFF the check for cyclomatic complexity metric,
7955-
use the following option:
7956-
7957-
::
7958-
7959-
-RMetrics_Cyclomatic_Complexity
7960-
79617939

79627940

79637941
.. _Metrics_Cyclomatic_Complexity:
@@ -7970,8 +7948,12 @@ use the following option:
79707948
The ``Metrics_Cyclomatic_Complexity`` rule takes a positive integer as
79717949
upper bound. A program unit that is an executable body exceeding this limit will be flagged.
79727950

7973-
This rule has the following optional parameter for the ``+R`` option and for
7974-
LKQL rule options files:
7951+
This rule has the following parameters for the ``+R`` option and for LKQL rule
7952+
options files:
7953+
7954+
*N: int*
7955+
Maximum cyclomatic complexity a body can have without being flagged, all
7956+
bodies with a higher index will be flagged.
79757957

79767958
*Exempt_Case_Statements: bool*
79777959
Whether to count the complexity introduced by ``case`` statement or ``case``
@@ -8018,12 +8000,19 @@ of tests needed to satisfy paths coverage testing completeness criterion.
80188000

80198001
.. index:: Metrics_Essential_Complexity
80208002

8021-
The ``Metrics_Essential_Complexity`` rule takes a positive integer as
8022-
upper bound. A program unit that is an executable body exceeding this limit will be flagged.
8003+
The ``Metrics_Essential_Complexity`` rule takes a positive integer as upper bound.
8004+
A program unit that is an executable body exceeding this limit will be flagged.
80238005

80248006
The Ada essential complexity metric is a McCabe cyclomatic complexity metric counted
80258007
for the code that is reduced by excluding all the pure structural Ada control statements.
80268008

8009+
This rule has the following (mandatory) parameter for the ``+R`` option and
8010+
for LKQL rule options files:
8011+
8012+
*N: int*
8013+
Maximum essential complexity a body can have without being flagged, all
8014+
bodies with a higher index will be flagged.
8015+
80278016
.. rubric:: Example
80288017

80298018
.. code-block:: ada
@@ -8057,17 +8046,23 @@ for the code that is reduced by excluding all the pure structural Ada control st
80578046

80588047
.. index:: Metrics_LSLOC
80598048

8060-
The ``Metrics_LSLOC`` rule takes a positive integer as
8061-
upper bound. A program unit declaration or a program unit body exceeding
8062-
this limit will be flagged.
8049+
The ``Metrics_LSLOC`` rule takes a positive integer as upper bound. A program
8050+
unit declaration or a program unit body exceeding this limit will be flagged.
80638051

8064-
The metric counts the total number of declarations and the total number of statements.
8052+
The metric counts the total number of declarations and the total number of
8053+
statements.
80658054

8066-
This rule has the following optional parameter for the ``+R`` option and for
8067-
LKQL rule options files:
8055+
This rule has the following parameters for the ``+R`` option and for LKQL rule
8056+
options files:
8057+
8058+
*N: int*
8059+
Maximum number of logical source lines a program declaration / body can have
8060+
without being flagged, all bodies with a higher number of LSLOC will be
8061+
flagged.
80688062

80698063
*Subprograms: bool*
8070-
Whether to check the rule for subprogram bodies only.
8064+
Optional parameter specifying whether to check the rule for subprogram
8065+
bodies only.
80718066

80728067
.. rubric:: Example
80738068

lkql_checker/share/lkql/metrics_cyclomatic_complexity.lkql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ fun metrics_cyclomatic_complexity(unit, n : int = 5,
66
|" The ``Metrics_Cyclomatic_Complexity`` rule takes a positive integer as
77
|" upper bound. A program unit that is an executable body exceeding this limit will be flagged.
88
|"
9-
|" This rule has the following optional parameter for the ``+R`` option and for
10-
|" LKQL rule options files:
9+
|" This rule has the following parameters for the ``+R`` option and for LKQL rule
10+
|" options files:
11+
|"
12+
|" *N: int*
13+
|" Maximum cyclomatic complexity a body can have without being flagged, all
14+
|" bodies with a higher index will be flagged.
1115
|"
1216
|" *Exempt_Case_Statements: bool*
1317
|" Whether to count the complexity introduced by ``case`` statement or ``case``

lkql_checker/share/lkql/metrics_essential_complexity.lkql

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ import metrics
22

33
@unit_check(help="essential complexity", execution_cost=3, category="Metrics")
44
fun metrics_essential_complexity(unit, n : int = 3) =
5-
|" The ``Metrics_Essential_Complexity`` rule takes a positive integer as
6-
|" upper bound. A program unit that is an executable body exceeding this limit will be flagged.
5+
|" The ``Metrics_Essential_Complexity`` rule takes a positive integer as upper bound.
6+
|" A program unit that is an executable body exceeding this limit will be flagged.
77
|"
88
|" The Ada essential complexity metric is a McCabe cyclomatic complexity metric counted
99
|" for the code that is reduced by excluding all the pure structural Ada control statements.
1010
|"
11+
|" This rule has the following (mandatory) parameter for the ``+R`` option and
12+
|" for LKQL rule options files:
13+
|"
14+
|" *N: int*
15+
|" Maximum essential complexity a body can have without being flagged, all
16+
|" bodies with a higher index will be flagged.
17+
|"
1118
|" .. rubric:: Example
1219
|"
1320
|" .. code-block:: ada

lkql_checker/share/lkql/metrics_lsloc.lkql

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ import metrics
33
@unit_check(help="Logical source lines", execution_cost=3,
44
rule_name="Metrics_LSLOC", category="Metrics")
55
fun metrics_lsloc(unit, n : int = 5, subprograms=false) =
6-
|" The ``Metrics_LSLOC`` rule takes a positive integer as
7-
|" upper bound. A program unit declaration or a program unit body exceeding
8-
|" this limit will be flagged.
6+
|" The ``Metrics_LSLOC`` rule takes a positive integer as upper bound. A program
7+
|" unit declaration or a program unit body exceeding this limit will be flagged.
98
|"
10-
|" The metric counts the total number of declarations and the total number of statements.
9+
|" The metric counts the total number of declarations and the total number of
10+
|" statements.
1111
|"
12-
|" This rule has the following optional parameter for the ``+R`` option and for
13-
|" LKQL rule options files:
12+
|" This rule has the following parameters for the ``+R`` option and for LKQL rule
13+
|" options files:
14+
|"
15+
|" *N: int*
16+
|" Maximum number of logical source lines a program declaration / body can have
17+
|" without being flagged, all bodies with a higher number of LSLOC will be
18+
|" flagged.
1419
|"
1520
|" *Subprograms: bool*
16-
|" Whether to check the rule for subprogram bodies only.
21+
|" Optional parameter specifying whether to check the rule for subprogram
22+
|" bodies only.
1723
|"
1824
|" .. rubric:: Example
1925
|"

lkql_jit/cli/src/main/java/com/adacore/lkql_jit/LKQLDocRules.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,6 @@ The rule identifier is used as a key for LKQL rule configuration objects (see
515515
The rules in this section can be used to enforce compliance with
516516
specific code metrics, by checking that the metrics computed for a program
517517
lie within user-specifiable bounds.
518-
Depending on the metric, there may be a lower bound, an upper bound, or both.
519-
A construct is flagged if the value of the metric exceeds the upper bound
520-
or is less than the lower bound.
521518
522519
The name of any metrics rule consists of the prefix ``Metrics_``
523520
followed by the name of the corresponding metric:
@@ -526,25 +523,6 @@ The rule identifier is used as a key for LKQL rule configuration objects (see
526523
(The 'LSLOC' acronym stands for 'Logical Source Lines Of Code'.)
527524
The meaning and the computed values of the metrics are
528525
the same as in *gnatmetric*.
529-
530-
For the ``+R`` option, each metrics rule has a numeric parameter
531-
specifying the bound (integer or real, depending on a metric).
532-
533-
*Example:* the rule
534-
535-
::
536-
537-
+RMetrics_Cyclomatic_Complexity : 7
538-
539-
540-
means that all bodies with cyclomatic complexity exceeding 7 will be flagged.
541-
542-
To turn OFF the check for cyclomatic complexity metric,
543-
use the following option:
544-
545-
::
546-
547-
-RMetrics_Cyclomatic_Complexity
548526
""");
549527

550528
printCategory(

0 commit comments

Comments
 (0)