Commits

Tero Koskinen committed 5e6c3ee

Fix Adacontrol errors.

Comments (0)

Files changed (7)

 -- No long code blocks
 check Max_Size (if_branch, 30);
 check Max_Size (unnamed_loop, 20);
-check Max_Size (block, 25);
+Long_Blocks: check Max_Size (block, 25);
 
 check style (negative_condition);
 check style (casing_identifier, original);
 check style (compound_statement);
 check style (casing_keyword, lowercase);
 check style (no_closing_name);
-check style (exposed_literal, integer, 0, 1, 2, number, constant, var_init);
+search style (exposed_literal, integer, 0, 1, 2, number, constant, var_init);
 
 check with_clauses (reduceable);
 

src/ahven-astrings.ads

 with Ada.Strings.Bounded;
 
 package Ahven.AStrings is
-  new Ada.Strings.Bounded.Generic_Bounded_Length (Max => 160);
+  new Ada.Strings.Bounded.Generic_Bounded_Length (Max => Max_String_Len);

src/ahven-text_runner.adb

       loop
          exit Test_Loop when not Is_Valid (Position);
          Print_Test (Data (Position), Level, Status);
-         if Print_Log and Length (Get_Output_File (Data (Position))) > 0 then
+         if Print_Log and
+           (Length (Get_Output_File (Data (Position))) > 0) then
             Print_Log_File (To_String (Get_Output_File (Data (Position))));
          end if;
          Position := Next (Position);

test/assertion_tests.adb

       Exception_Got : Boolean;
    begin
       Assert (True, "Assert (True)");
-            
+
       begin
          Exception_Got := False;
          Assert (False, "assertion");

test/dummy_tests.adb

 
 with Ahven;
 
+
+--## rule off DIRECTLY_ACCESSED_GLOBALS
 package body Dummy_Tests is
    Instance_Count : Integer := 0;
 
       Instance_Count := 0;
    end Reset_Instance_Count;
 end Dummy_Tests;
+--## rule on DIRECTLY_ACCESSED_GLOBALS

test/framework_tests.adb

    begin
       Dummy_Tests.Reset_Instance_Count;
       Initial_Count := Dummy_Tests.Get_Instance_Count;
+      --## rule off Long_Blocks
       declare
          use Dummy_Tests;
 
          Parent      : Framework.Test_Suite;
          GParent     : Framework.Test_Suite;
          Dummy_Test  : Dummy_Tests.Test;
+
+         Test_Instance_Count : Natural := 1;
       begin
          Child := Framework.Create_Suite ("Child suite");
          Framework.Add_Static_Test (Child, Dummy_Test);
-         Assert_Eq_Int (Expected => 2,
+         Test_Instance_Count := Test_Instance_Count + 1; -- 2
+         Assert_Eq_Int (Expected => Test_Instance_Count,
                         Actual   => Dummy_Tests.Get_Instance_Count,
                         Message  => "Dummy_Tests instance count");
 
          Framework.Add_Test (Child, new Dummy_Tests.Test);
-         Assert_Eq_Int (Expected => 3,
+         Test_Instance_Count := Test_Instance_Count + 1; -- 3
+         Assert_Eq_Int (Expected => Test_Instance_Count,
                         Actual   => Dummy_Tests.Get_Instance_Count,
                         Message  => "Dummy_Tests instance count");
 
          Parent := Framework.Create_Suite ("Parent suite");
          Framework.Add_Static_Test (Parent, Child);
-         Assert_Eq_Int (Expected => 5,
+         Test_Instance_Count := Test_Instance_Count + 2; -- 1 + 2 + 2 = 5
+         Assert_Eq_Int (Expected => Test_Instance_Count,
                         Actual   => Dummy_Tests.Get_Instance_Count,
                         Message  => "Dummy_Tests instance count");
 
       Assert_Eq_Int (Expected => Initial_Count,
                      Actual   => Dummy_Tests.Get_Instance_Count,
                      Message  => "Not all tests freed");
-
+      --## rule on Long_Blocks
    end Test_Test_Suite_Cleanup;
 end Framework_Tests;

test/slist_tests.adb

    procedure Test_For_Each is
       use Simple_List;
 
-      Counter : Natural := 0;
+      Counter : Natural  := 0;
+      Max     : constant := 5;
 
       procedure My_Action (Obj : in out Simple_Type) is
       begin
 
       My_List  : List;
    begin
-      for A in Integer range 1 .. 5 loop
+      for A in Integer range 1 .. Max loop
          Append (My_List, (Value => A));
       end loop;
       Run_All (My_List);