Skip to content

Commit 9197705

Browse files
committed
Update the LKQL rule file section of the documentation
1 parent c2cdaf7 commit 9197705

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ described in the following paragraph).
462462

463463
By default, GNATcheck will look for a ``rules.lkql`` file besides the specified
464464
project file if any. If one is found and no other rule configuration has been
465-
provided (either through the LKQL --rule-file option, or by the now deprecated
466-
legacy -rules options), GNATcheck will load the rule configuration file as if
467-
it was provided by the --rule-file option.
465+
provided (either through the LKQL ``--rule-file`` option, or by the now
466+
deprecated legacy ``-rules`` options), GNATcheck will load the rule
467+
configuration file as if it was provided by the ``--rule-file`` option.
468468

469469
.. note::
470470

@@ -485,7 +485,7 @@ string, or the list of strings type, as shown in the simple example below:
485485
Forbidden_Attributes: {Forbidden: ["GNAT"], Allowed: ["First", "Last"]}
486486
}
487487

488-
Using the "@" object notation is strongly advised to make your configuration
488+
Using the ``@`` object notation is strongly advised to make your configuration
489489
file way more understandable:
490490

491491
Please read the :ref:`Predefined_Rules` documentation to view examples on how
@@ -524,7 +524,7 @@ to provide parameters to rules through LKQL rule files.
524524
}
525525

526526
Moreover, each instance must be identifiable through a unique name, thus the
527-
following configuration is invalid and will lead to a GNATCheck error:
527+
following configuration is invalid and will lead to a GNATcheck error:
528528

529529
::
530530

@@ -535,6 +535,10 @@ to provide parameters to rules through LKQL rule files.
535535
]
536536
}
537537

538+
However, if two instances have the same name **and** the same parameters,
539+
GNATcheck will just ignore the duplicate instance and emit a warning instead
540+
of an error so that the analysis can nevertheless be executed.
541+
538542
Additionally to the ``rules`` top-level symbol, an LKQL rule file may export
539543
``ada_rules`` and ``spark_rules`` symbols to enable associated rules,
540544
respectively, only on Ada code or only on SPARK code. Those symbols must also
@@ -624,8 +628,10 @@ defined in ``specific_rules.lkql``.
624628
are going to be searched in.
625629

626630
You can enable the same rule in multiple files, but the constraint about the
627-
instance name uniqueness remains valid, meaning that such configuration is
628-
invalid:
631+
instance name uniqueness remains valid: when two instances have the same name,
632+
GNATcheck will emit an error if the instances have different parameters but
633+
ignore duplicate instances that are configured identically. That means such a
634+
configuration is invalid:
629635

630636
.. code-block:: lkql
631637
@@ -649,6 +655,21 @@ invalid:
649655
})
650656
# error: This rule configuration defines two instances with the same name: "Forbid_Attr"
651657
658+
Note that GNATcheck will also detect instances that run the same check (i.e.,
659+
instances that have different names but are configured with the same
660+
parameters). In such cases, GNATcheck will emit a warning so that duplicate
661+
checks can be easily detected when combining rules object.
662+
663+
Same restrictions apply when combining LKQL rules files with rules specified
664+
with the command line interface (using the ``--rule``
665+
:ref:`switch<General_gnatcheck_Switches>`), or through the ``Check``
666+
:ref:`GPR package<Check_GPR_Package>`.
667+
668+
.. attention::
669+
670+
Combining :ref:`LKQL rule file<LKQL_options_file>` with the deprecated
671+
:ref:`GNATcheck Rule Options<gnatcheck_Rule_Options>` is undefined behavior.
672+
652673

653674
.. _gnatcheck_Rule_Options:
654675

0 commit comments

Comments
 (0)