Skip to content

Commit c4c444b

Browse files
committed
Add documentation about LKQL rule file composition
1 parent 3b57b4a commit c4c444b

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

+56
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,62 @@ the following configuration will raise an error:
590590
Forbidden_Attributes: {Forbidden: ["Length"], instance_name: "Forbid_Attr"}
591591
}
592592

593+
You cannot provide more than **one** LKQL rule file when running GNATcheck. In
594+
order to compose a rule file with another you have to use the
595+
:ref:`LKQL importation mechanism<module_importation>` and concatenate rule
596+
objects. Here is an example of LKQL rule file composition:
597+
598+
.. code-block:: lkql
599+
600+
# common_rules.lkql
601+
602+
val rules = @{
603+
Goto_Statements
604+
}
605+
606+
.. code-block:: lkql
607+
608+
# specific_rules.lkql
609+
610+
import common_rules
611+
612+
val rules = common_rules.rules & @{
613+
Redundant_Null_Statements
614+
}
615+
616+
Then you can run GNATcheck with the ``specific_rules.lkql`` file as coding
617+
standard to perform rules defined in ``common_rules.lkql`` combined to the ones
618+
defined in ``specific_rules.lkql``.
619+
620+
.. note::
621+
622+
You can use the ``--lkql-path`` command-line switch and the
623+
``Check'Lkql_Path`` GPR attribute to configure directories LKQL rule files
624+
are going to be searched in.
625+
626+
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:
629+
630+
.. code-block:: lkql
631+
632+
# common_rules.lkql
633+
634+
val rules = @{
635+
Forbidden_Attributes: {Forbidden: ["First"], instance_name: "Forbid_Attr"}
636+
}
637+
638+
.. code-block:: lkql
639+
640+
# specific_rules.lkql
641+
642+
import common_rules
643+
644+
val rules = common_rules.rules & @{
645+
Forbidden_Attributes: {Forbidden: ["Last"], instance_name: "Forbid_Attr"}
646+
}
647+
# error: This rule configuration defines two instances with the same name: "Forbid_Attr"
648+
593649
594650
.. _gnatcheck_Rule_Options:
595651

user_manual/source/language_reference.rst

+2
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,8 @@ LKQL has a few built-in operators available:
776776
{a: 1} & {a: 2} # Runtime error! Impossible to concatenate `Int`s
777777
778778
779+
.. _module_importation:
780+
779781
Module Importation
780782
^^^^^^^^^^^^^^^^^^
781783

0 commit comments

Comments
 (0)