1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
  
     | 
    
      ------------------------------------------------------------------------------
--                                                                          --
--                          GNATCHECK COMPONENTS                            --
--                                                                          --
--              G N A T C H E C K . R U L E S . M E T R I C S               --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--                     Copyright (C) 2008-2012, AdaCore                     --
--                                                                          --
-- GNATCHECK  is  free  software;  you can redistribute it and/or modify it --
-- under terms of the  GNU  General Public License as published by the Free --
-- Software Foundation;  either version 2, or ( at your option)  any  later --
-- version.  GNATCHECK  is  distributed in the hope that it will be useful, --
-- but  WITHOUT  ANY  WARRANTY;   without  even  the  implied  warranty  of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details.  You should have received a copy of the --
-- GNU  General Public License distributed with GNAT; see file  COPYING. If --
-- not,  write to the  Free Software Foundation,  51 Franklin Street, Fifth --
-- Floor, Boston, MA 02110-1301, USA.                                       --
--                                                                          --
-- GNATCHECK is maintained by AdaCore (http://www.adacore.com).             --
--                                                                          --
------------------------------------------------------------------------------
--  This package defines the gnatcheck rules based on metrics.
pragma Ada_2005;
package Gnatcheck.Rules.Metrics is
   --  All the rules in this package have a positive numeric (integer or real,
   --  depending on a rule) parameter for +R option that specifies the upper
   --  or lower (also depending on a rule) limit for a given metric. -R option
   --  for metric rule does not have a parameter.
   -----------------------------------
   -- Metrics_Cyclomatic_Complexity --
   -----------------------------------
   type Metrics_Cyclomatic_Complexity_Rule_Type is new
     One_Integer_Parameter_Rule_Template with null record;
   procedure Rule_Check_Pre_Op
     (Rule    : in out Metrics_Cyclomatic_Complexity_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State);
   --  If cyclomatic complexity metric is applicable to the argument Element,
   --  checks if the metric value is not greater than is specified for this
   --  metric check. Flags a construct if this check fails.
   procedure Init_Rule (Rule : in out Metrics_Cyclomatic_Complexity_Rule_Type);
   Metrics_Cyclomatic_Complexity_Rule :
     aliased Metrics_Cyclomatic_Complexity_Rule_Type;
   ----------------------------------
   -- Metrics_Essential_Complexity --
   ----------------------------------
   type Metrics_Essential_Complexity_Rule_Type is new
     One_Integer_Parameter_Rule_Template with null record;
   procedure Rule_Check_Pre_Op
     (Rule    : in out Metrics_Essential_Complexity_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State);
   --  If essential complexity metric is applicable to the argument Element,
   --  checks if the metric value is not greater than is specified. Flags a
   --  construct if this check fails.
   procedure Init_Rule (Rule : in out Metrics_Essential_Complexity_Rule_Type);
   Metrics_Essential_Complexity_Rule :
     aliased Metrics_Essential_Complexity_Rule_Type;
   -------------------
   -- Metrics_LSLOC --
   -------------------
   type Metrics_LSLOC_Rule_Type is new One_Integer_Parameter_Rule_Template
     with null record;
   overriding procedure Activate_In_Test_Mode
     (Rule : in out Metrics_LSLOC_Rule_Type);
   --  Activates the rule with the parameter equals to 30 (the default 4 is
   --  too small for this rule).
   procedure Rule_Check_Pre_Op
     (Rule    : in out Metrics_LSLOC_Rule_Type;
      Element :        Asis.Element;
      Control : in out Traverse_Control;
      State   : in out Rule_Traversal_State);
   --  If LSLOC metric is applicable to the argument Element, checks if the
   --  metric value is not greater than is specified. Flags a construct if this
   --  check fails.
   procedure Init_Rule (Rule : in out Metrics_LSLOC_Rule_Type);
   Metrics_LSLOC_Rule : aliased Metrics_LSLOC_Rule_Type;
end Gnatcheck.Rules.Metrics;
 
     |