Skip to content

Commit 3a4d6ff

Browse files
committed
Merge branch 'topic/rules_in_doc' into 'master'
Update the GNATcheck RM to promote the new LKQL rule file feature Closes #356 See merge request eng/libadalang/langkit-query-language!329
2 parents 2a4c8dd + 904383b commit 3a4d6ff

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

lkql_checker/doc/generated/predefined_rules.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Predefined Rules
88

99
The description of the rules currently implemented in ``gnatcheck`` is
1010
given in this chapter.
11-
The rule identifier is used as a parameter of ``gnatcheck``'s ``+R`` or ``-R``
12-
switches.
11+
The rule identifier is used as a key for LKQL rule configuration objects (see
12+
:ref:`LKQL rule file<LKQL_options_file>`), and as first parameter of
13+
``gnatcheck``'s ``+R`` or ``-R`` switches.
1314

1415
Be aware that most of these rules apply to specialized coding
1516
requirements developed by individual users and may well not make sense in
@@ -4467,8 +4468,8 @@ options files:
44674468
44684469
Note that if you specify the rule with parameters in a command shell, you may
44694470
need to escape its parameters. The best and the safest way of using this rule
4470-
is to place it into a rule file and to use this rule file as a parameter of the
4471-
``-from=`` option, no escaping is needed in this case.
4471+
is to place it into an LKQL rule file and to use this rule file with the
4472+
``--rule-file`` switch, no escaping is needed in this case.
44724473

44734474
.. rubric:: Example
44744475

lkql_checker/doc/gnatcheck_rm/getting_started.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,3 @@ have the following content::
225225
6. Gnatcheck internal errors
226226

227227
no internal error detected
228-

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ The following switches control the general ``gnatcheck`` behavior
287287
All switches and options provided after this flag will be parse as
288288
:ref:`rule options<gnatcheck_Rule_Options>`.
289289

290+
.. attention::
291+
292+
This CLI section is **deprecated**, consider converting your rule
293+
configuration to the new :ref:`LKQL rule file<LKQL_options_file>` format
294+
using the ``--emit-lkql-rule-file`` switch.
295+
290296
If a project file is specified and no argument source is explicitly
291297
specified (either directly or by means of ``-files`` option), and no
292298
``-U`` or ``--no-subprojects`` is specified, then the set of processed
@@ -384,14 +390,21 @@ LKQL Rule Files
384390
===============
385391

386392
You can configure GNATcheck rules using an LKQL file, provided through the
387-
``--rule-file`` command-line option.
393+
``--rule-file`` command-line option or implicitly fetched by GNATcheck (as
394+
described in the following paragraph).
388395

389396
By default, GNATcheck will look for a ``rules.lkql`` file in the current working
390397
directory or besides the specified project file if any. If there is one and
391398
no other rule configuration has been provided (through an LKQL rule file, or
392399
through the rule options), GNATcheck will load it as the LKQL rule options
393400
file, as if it was provided through the ``--rule-file`` option.
394401

402+
.. note::
403+
404+
You can use the ``--emit-lkql-rule-file`` CLI switch to generate an LKQL rule
405+
file from a legacy rule configuration provided through the ``-rules``
406+
section.
407+
395408
This file must be a valid LKQL file that exports at least a ``rules`` top-level
396409
symbol. This symbol must refer to an object value containing rules
397410
configuration; keys are GNATcheck rules to enable; and values are objects
@@ -405,8 +418,8 @@ integer, a string, or a list of strings.
405418
Forbidden_Attributes: {Forbidden: ["GNAT"], Allowed: ["First", "Last"]}
406419
}
407420

408-
You can map a boolean parameter from a ``+R`` option to an LKQL rule options file by
409-
passing an LKQL boolean value to it. For example:
421+
For example, to map a boolean parameter from a ``+R`` rule option to an LKQL
422+
rule file, you have to associate a boolean LKQL value to the parameter name:
410423

411424
::
412425

@@ -422,8 +435,8 @@ maps to:
422435

423436
.. attention::
424437

425-
You cannot provide the same key twice; thus, the following code will
426-
result in a runtime error.
438+
You cannot provide the same key twice; thus, the following code will result
439+
in a runtime error.
427440

428441
::
429442

@@ -481,8 +494,9 @@ GNATcheck Rule Options
481494

482495
.. attention::
483496

484-
GNATcheck rule options are deprecated, please use :ref:`LKQL_options_file`
485-
instead.
497+
Rules options are **deprecated**, consider converting your rule
498+
configuration to the new :ref:`LKQL rule file<LKQL_options_file>` format
499+
using the ``--emit-lkql-rule-file`` CLI switch.
486500

487501
The following options control the processing performed by ``gnatcheck``. You
488502
can provide as many rule options as you want after the ``-rules`` switch.
@@ -652,7 +666,7 @@ GNATcheck Exit Codes
652666
* ``3``: No tool failure, no problem with rule specification, but
653667
there is at least one missing argument source.
654668

655-
* ``4``: Parameter of the rule ``-from`` option denotes a nonexistent file.
669+
* ``4``: Provided rule configuration file doesn't exist.
656670

657671
* ``5``: The name of an unknown rule in a rule option or some problem with
658672
rule parameters.

0 commit comments

Comments
 (0)