Skip to content

Commit c089bdb

Browse files
committed
Merge branch 'topic/gnatcheck/cleanup_switches' into 'master'
Migrate more GNATcheck switches to Opt_Parse Closes #391 and #540 See merge request eng/libadalang/langkit-query-language!541
2 parents 207b3e0 + f36a70a commit c089bdb

32 files changed

+964
-1198
lines changed

lkql_checker/doc/gnatcheck_rm/using_gnatcheck.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The following switches control the general ``gnatcheck`` behavior
2222
.. index:: --help
2323

2424

25-
``--help``
25+
``-h, --help``
2626
Display usage, then exit disregarding all other options.
2727

2828
.. index:: -P file
@@ -85,6 +85,11 @@ The following switches control the general ``gnatcheck`` behavior
8585

8686
.. index:: --ignore-project-switches
8787

88+
``-vP level``
89+
Set the verbosity level when parsing a project file. The level is expressed
90+
as a natural number between ``0`` and ``2``; ``0`` being the less verbose and
91+
``2`` being very verbose (default is ``0``).
92+
8893
``--ignore-project-switches``
8994
Ignore gnatcheck switches specified in the package ``Check`` of the main
9095
project file.
@@ -100,10 +105,10 @@ The following switches control the general ``gnatcheck`` behavior
100105
``--RTS=rts-path``
101106
Specifies the default location of the runtime library.
102107

103-
.. index:: -h
108+
.. index:: --list-rules
104109

105-
``-h``
106-
List all the rules checked by the given ``gnatcheck`` version.
110+
``--list-rules``
111+
List all available GNATcheck rules and exit.
107112

108113
.. index:: -j
109114

@@ -391,10 +396,13 @@ GNATcheck:
391396
``Switches`` attribute:
392397

393398
* ``--version``
394-
* ``--help``
399+
* ``-h, --help``
400+
* ``--list-rules``
395401
* ``-P``
396402
* ``-U``
397403
* ``-Xname=value``
404+
* ``--no-subprojects``
405+
* ``-vP``
398406
* ``-eL``
399407
* ``-r, --rule [rule_name]`` (use ``Rules`` attribute instead)
400408
* ``--rule-file=filename`` (use ``Rule_File`` attribute instead)
@@ -691,8 +699,8 @@ can provide as many rule options as you want after the ``-rules`` switch.
691699
Create and enable an instance of the specified rule with the specified
692700
parameter(s), if any.
693701
`rule_id` must be the identifier of one of the currently implemented
694-
rules (use ``-h`` for the list of implemented rules). Rule identifiers
695-
are not case-sensitive.
702+
rules (use ``--list-rules`` for the list of implemented rules). Rule
703+
identifiers are not case-sensitive.
696704

697705
Each `param` item must be a non-empty string representing a valid parameter
698706
for the specified rule. If the part of the rule option that follows the
@@ -1150,11 +1158,11 @@ source locations will be generated on standard error, as well as in a file
11501158
called :file:`gnatkp.out`.
11511159

11521160
You can display the list of detectors without running them by specifying
1153-
additionally the ``-h`` switch, e.g.:
1161+
additionally the ``--list-rules`` switch, e.g.:
11541162

11551163
.. code-block:: none
11561164
1157-
gnatkp --kp-version=21.2 -h --target=<my_target> --RTS=<my_runtime>
1165+
gnatkp --kp-version=21.2 --list-rules --target=<my_target> --RTS=<my_runtime>
11581166
11591167
You can also combine the ``--kp-version`` switch with the ``--target`` switch
11601168
to filter out detectors not relevant for your target, e.g:
@@ -1177,10 +1185,10 @@ using the switch ``-r``:
11771185
gnatkp -Pproject --target=<my_target> --RTS=<my_runtime> -r kp_xxxx_xxx [-r kp_xxxx_xxx]
11781186
11791187
where ``kp_xxxx_xxx`` is the name of a relevant known-problem to detect. You
1180-
can get the list of available detectors via the command ``gnatkp -h``. When
1181-
combined with the ``--kp-version`` and possibly ``--target`` switches,
1182-
``gnatkp -h`` will only list the detectors relevant to the version
1183-
(and target) specified.
1188+
can get the list of available detectors via the command
1189+
``gnatkp --list-rules``. When combined with the ``--kp-version`` and possibly
1190+
``--target`` switches, ``gnatkp --list-rules`` will only list the detectors
1191+
relevant to the version (and target) specified.
11841192

11851193
.. attention::
11861194

lkql_checker/doc/gnatcheck_rm/writing_your_own_rules.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ Rules can take different optional arguments:
131131
* ``message``: The custom message that is to be shown for a given rule on the
132132
command line. Defaults to the name of the rule if not specified.
133133

134-
* ``help``: The help message that is to be shown via ``gnatcheck -h``. Defaults to
135-
message if not specified.
134+
* ``help``: The help message that is to be shown via
135+
``gnatcheck --list-rules``. Defaults to message if not specified.
136136

137137
* ``follow_generic_instantiations``: Whether to follow generic instantiations
138138
during the traversal of given Ada units. If ``true``, generic instantiations
@@ -147,8 +147,8 @@ Rules can take different optional arguments:
147147
* MEDIUM
148148
* MAJOR
149149

150-
Used by ``gnatcheck -h`` and by the SonarQube integration to compute technical debt.
151-
Defaults to `MEDIUM`.
150+
Used by ``gnatcheck --list-rules`` and by the SonarQube integration to
151+
compute technical debt. Defaults to `MEDIUM`.
152152

153153
Here is an example rule:
154154

@@ -537,4 +537,3 @@ which gives us this complete rule:
537537
when not [t for t in types() if t == node]
538538
and not [t for t in instantiations() if t == node]
539539
and not [t for t in arithmetic_ops() if t == node]
540-

lkql_checker/src/checker_app.ads

Lines changed: 0 additions & 55 deletions
This file was deleted.

lkql_checker/src/gnatcheck-compiler.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ package body Gnatcheck.Compiler is
18851885
Num_Args := @ + 1;
18861886
Args (Num_Args) := new String'(LKQL_RF_Name);
18871887

1888-
if Verbose_Mode then
1888+
if Arg.Verbose.Get then
18891889
Num_Args := @ + 1;
18901890
Args (Num_Args) := new String'("--verbose");
18911891
end if;
@@ -1963,7 +1963,7 @@ package body Gnatcheck.Compiler is
19631963
-- If files are specified explicitly, only compile these files
19641964

19651965
if (Argument_File_Specified and then not Arg.Transitive_Closure.Get)
1966-
or else File_List_Specified
1966+
or else Arg.Source_Files_Specified
19671967
then
19681968
Num_Args := @ + 1;
19691969
Args (Num_Args) := new String'("-u");

0 commit comments

Comments
 (0)