@@ -239,6 +239,13 @@ The following switches control the general ``gnatcheck`` behavior
239
239
Specify the charset of the source files. By default, ``ISO-8859-1 `` is
240
240
used if no charset is specified.
241
241
242
+ .. index :: --lkql-path
243
+
244
+ ``--lkql-path=dir ``
245
+ Specify directory to add to the ``LKQL_PATH `` environment variable when
246
+ GNATcheck is spawning the LKQL engine. You can specify this option multiple
247
+ times to add multiple directories.
248
+
242
249
.. index :: --rules-dir
243
250
244
251
``--rules-dir=dir ``
@@ -361,6 +368,16 @@ GNATcheck:
361
368
file defining this attribute, then, an error is emitted and ``gnatcheck ``
362
369
will exit with an error code.
363
370
371
+ ``Lkql_Path ``
372
+ Value is a list of directories to add to the ``LKQL_PATH `` environment
373
+ variable when GNATcheck is spawning the LKQL engine. This variable is
374
+ used to resolve module importations in LKQL sources. If not absolute, paths
375
+ provided through this attribute are relatives to the project file defining
376
+ it.
377
+
378
+ This attributes may work combined with the ``--lkql-path `` switch, in that
379
+ case, all directories are added to the ``LKQL_PATH `` environment variable.
380
+
364
381
``Switches ``
365
382
Index is a language name. Value is a list of additional switches to be used
366
383
when invoking ``gnatcheck ``.
@@ -381,6 +398,7 @@ GNATcheck:
381
398
* ``-eL ``
382
399
* ``-r, --rule [rule_name] `` (use ``Rules `` attribute instead)
383
400
* ``--rule-file=filename `` (use ``Rule_File `` attribute instead)
401
+ * ``--lkql-path=dir `` (use ``Lkql_Path `` attributes instead)
384
402
* ``--target `` (use the ``Target `` GPR attribute instead)
385
403
* ``--RTS `` (use the ``Runtime `` GPR attribute instead)
386
404
@@ -456,9 +474,9 @@ it was provided by the --rule-file option.
456
474
An LKQL rule file can be any valid LKQL file, the only requirement is that it
457
475
must export a ``rules `` top-level symbol. This symbol defines an object value
458
476
containing rules configuration; keys are GNATcheck rules to enable; and values
459
- are objects containing the rule parameters. A rule parameter value can be of
460
- the boolean, the integer, the string, or the list of strings type, as shown in
461
- the simple example below:
477
+ are list of objects, each one representing an instance of the rule with its
478
+ parameters. A rule parameter value can be of the boolean, the integer, the
479
+ string, or the list of strings type, as shown in the simple example below:
462
480
463
481
::
464
482
@@ -467,6 +485,9 @@ the simple example below:
467
485
Forbidden_Attributes: {Forbidden: ["GNAT"], Allowed: ["First", "Last"]}
468
486
}
469
487
488
+ Using the "@" object notation is strongly advised to make your configuration
489
+ file way more understandable:
490
+
470
491
Please read the :ref: `Predefined_Rules ` documentation to view examples on how
471
492
to provide parameters to rules through LKQL rule files.
472
493
@@ -543,7 +564,7 @@ the following configuration will raise an error:
543
564
::
544
565
545
566
val spark_rules = @{
546
- Warnings: "a"
567
+ Warnings: {Arg: "a"}
547
568
}
548
569
549
570
.. attention ::
@@ -569,6 +590,62 @@ the following configuration will raise an error:
569
590
Forbidden_Attributes: {Forbidden: ["Length"], instance_name: "Forbid_Attr"}
570
591
}
571
592
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
+
572
649
573
650
.. _gnatcheck_Rule_Options :
574
651
0 commit comments