Skip to content

Commit 58f571e

Browse files
committed
Merge branch 'topic/deprecate_rules' into 'master'
First step of deprecating the GNATcheck '-rules' section Closes #281, #283, #282, and #276 See merge request eng/libadalang/langkit-query-language!259
2 parents 9fffdd0 + 7dfaefb commit 58f571e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1162
-643
lines changed

lkql_checker/doc/gnatcheck_rm/getting_started.rst

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@ It can also be used as a static analysis tool to detect potential errors
1515

1616
A number of rules are predefined in ``gnatcheck`` and are described
1717
in :ref:`Predefined_Rules`. In addition, it is possible to write new rules
18-
as described in :ref:`Writing_Your_Own_Rules`
19-
using a dedicated pattern matching language called `LKQL`,
20-
used to implement all the predefined rules.
18+
as described in :ref:`Writing_Your_Own_Rules` using a dedicated pattern
19+
matching language called `LKQL`, used to implement all the predefined rules.
2120

2221
Invoking ``gnatcheck`` on the command line has the form::
2322

2423
$ gnatcheck [switches] {filename}
2524
[-files=arg_list_filename]
26-
-rules rule_options [-cargs gcc_switches]
25+
[-r rule_names]
26+
[--rules=lkql_rule_filename]
27+
[-cargs gcc_switches]
28+
29+
30+
or the deprecated form::
31+
32+
$ gnatcheck [switches] {filename}
33+
[-files=arg_list_filename]
34+
-rules rule_options
35+
[-cargs gcc_switches]
2736

2837
where
2938

@@ -36,6 +45,12 @@ where
3645
file containing the names of the source files to process, separated by spaces
3746
or line breaks.
3847

48+
* `rules_names` is a list of rule to enable for the GNATcheck run.
49+
50+
* `lkql_rule_filename` is the name (including the extension) of an LKQL rule
51+
configuration file used to control and configure the enabled rules for the
52+
GNATcheck run (see :ref:`LKQL_options_file` for more information about it).
53+
3954
* `rule_options` is a list of options for controlling a set of
4055
rules to be checked by ``gnatcheck`` (:ref:`gnatcheck_Rule_Options`).
4156

@@ -66,30 +81,31 @@ project file named :file:`gnatcheck_example.gpr` with the following content:
6681
for Main use ("main.adb");
6782
6883
package Check is
69-
for Default_Switches ("ada") use ("-rules", "-from=coding_standard");
84+
for Default_Switches ("ada") use ("--rules", "coding_standard.lkql");
7085
end Check;
7186
7287
end Gnatcheck_Example;
7388
7489
75-
And the file named :file:`coding_standard` is also located in the current
76-
directory and has the following content::
90+
And the file named :file:`coding_standard.lkql` is also located in the current
91+
directory and has the following content
92+
93+
.. code-block:: lkql
7794
78-
-----------------------------------------------------
79-
-- This is a sample gnatcheck coding standard file --
80-
-----------------------------------------------------
95+
# This is a sample gnatcheck coding standard file
8196
82-
-- First, turning on rules, that are directly implemented in gnatcheck
83-
+RAbstract_Type_Declarations
84-
+RAnonymous_Arrays
85-
+RLocal_Packages
86-
+RFloat_Equality_Checks
87-
+REXIT_Statements_With_No_Loop_Name
97+
# The 'rules' value must be an object value containing rule configs
98+
val rules = @{
99+
# Turning on rules directly implemented in GNATcheck
100+
Abstract_Type_Declarations,
101+
Anonymous_Arrays,
102+
Local_Packages,
103+
Float_Equality_Checks,
104+
EXIT_Statements_With_No_Loop_Name,
88105
89-
-- Then, activating compiler checks of interest:
90-
+RStyle_Checks:e
91-
-- This style check checks if a unit name is present on END keyword that
92-
-- is the end of the unit declaration
106+
# Turning on a compiler check
107+
Style_Checks: [{arg: "e"}]
108+
}
93109
94110
95111
And the subdirectory :file:`src` contains the following Ada sources:
@@ -158,9 +174,9 @@ the project file as the only parameter of the call::
158174

159175
As a result, ``gnatcheck`` is called to check all the files from the
160176
project :file:`gnatcheck_example.gpr` using the coding standard defined by
161-
the file :file:`coding_standard`. The ``gnatcheck``
162-
report file named :file:`gnatcheck.out` will be created in the ``obj``
163-
directory, and it will have the following content::
177+
the file :file:`coding_standard.lkql`. The ``gnatcheck`` report file named
178+
:file:`gnatcheck.out` will be created in the ``obj`` directory, and it will
179+
have the following content::
164180

165181
GNATCheck report
166182

0 commit comments

Comments
 (0)