Skip to content

Commit

Permalink
Merge branch 'topic/all_rule_casing' into 'master'
Browse files Browse the repository at this point in the history
Make '+All' rule case insensitive

Closes #56

See merge request eng/libadalang/langkit-query-language!178
  • Loading branch information
HugoGGuerrier committed Feb 21, 2024
2 parents fbdcc09 + 93094b2 commit 6e5f7eb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lkql_checker/src/gnatcheck-rules-rule_table.adb
Expand Up @@ -761,8 +761,9 @@ package body Gnatcheck.Rules.Rule_Table is
(Option : String;
Defined_At : String)
is
First_Idx : constant Natural := Option'First;
Last_Idx : constant Natural := Option'Last;
First_Idx : constant Natural := Option'First;
Last_Idx : constant Natural := Option'Last;
Lower_Option : constant String := To_Lower (Option);

Word_Start : Natural := 0;
Word_End : Natural := 0;
Expand Down Expand Up @@ -828,10 +829,10 @@ package body Gnatcheck.Rules.Rule_Table is
end Set_Parameter;

begin
if Option = "-ALL" then
if Lower_Option = "-all" then
Turn_All_Rules_Off;
return;
elsif Option = "+ALL" then
elsif Lower_Option = "+all" then
Turn_All_Rules_On;
return;
end if;
Expand Down Expand Up @@ -879,7 +880,7 @@ package body Gnatcheck.Rules.Rule_Table is
-- Separate processing for restrictions, style_checks, warnings, and
-- ordinary rules.

if To_Lower (Option (Word_Start .. Word_End)) = "restrictions" then
if Lower_Option (Word_Start .. Word_End) = "restrictions" then
Set_Parameter;

if Word_Start = 0 then
Expand All @@ -895,7 +896,7 @@ package body Gnatcheck.Rules.Rule_Table is
Set_Parameter;
end loop;

elsif To_Lower (Option (Word_Start .. Word_End)) = "style_checks" then
elsif Lower_Option (Word_Start .. Word_End) = "style_checks" then
if not Enable then
Error ("there is no -R option for style checks, " &
"use style options to turn checks OFF" &
Expand Down
9 changes: 9 additions & 0 deletions testsuite/tests/gnatcheck/all_rules/main.adb
@@ -0,0 +1,9 @@
with Ada.Text_IO; use Ada.Text_IO; -- FLAG (3)

procedure Main is -- FLAG (3)
begin
Put_Line ("Hello!");
goto lbl -- FLAG (2)

<<lbl>>
end Main;
8 changes: 8 additions & 0 deletions testsuite/tests/gnatcheck/all_rules/test.out
@@ -0,0 +1,8 @@
main.adb:1:19: use clause for package
main.adb:1:23: use clause
main.adb:1:37: end of line comment
main.adb:3:01: possible occurrence of KP U727-033 if float operation performed before first context switch on leon targets
main.adb:3:11: declaration of library level subprogram
main.adb:3:37: end of line comment
main.adb:6:05: goto statement
main.adb:6:37: end of line comment
6 changes: 6 additions & 0 deletions testsuite/tests/gnatcheck/all_rules/test.yaml
@@ -0,0 +1,6 @@
driver: gnatcheck
format: brief
input_sources:
- "main.adb"
rules:
- "+aLl"

0 comments on commit 6e5f7eb

Please sign in to comment.