Configuring gnatcheck and gnatmetric

It is possible to incorporate gnatcheck and gnatmetric results in the TICS output for ADA files. Gnatcheck and gnatmetric are ASIS-based utilities. Gnatcheck checks properties of ADA source files according to a given set of semantic rules. Gnatmetric takes an Ada source file as input and calculates the metrics data, such as cyclometic complexity.

Which gnatmetric and gnatcheck version should be used

The integration of gnatcheck and gnatmetric within TICS is based on the versions that are built with ASIS 2.0.R for GNAT GPL 2008 (20080521). It is not recommended to use an other version.

Prerequisites

For a successful integration, the following prerequisites must be met:

Basic configuration

The gnatmetric tool can be configured via the METRICS property in the 'LANGUAGES' section of the SERVER.txt. As mentioned above, the tools require a file's buildoptions that can be obtained by the build integration within TICS. This is configured in the BUILDTYPE in the 'LANGUAGES' section of the SERVER.txt.

  'LANGUAGES' => {
    'ADA' => {
      'EXTENSIONS' => [ 'ads', 'ada', 'adb' ],
      'BUILDTYPE' => [
        { 'name' => 'Make', 'compiler' => [ 'GNAT' ] },
      ],
      'METRICS' => [ 'gnatmetric' ],
      ...
    },
    ...
  },

Configuring which rules of gnatmetric should be checked

A number of rules are predefined in gnatcheck. You can also add new rules, by modifying the gnatcheck code and rebuilding the tool. In order to add a simple rule making some local checks, a small amount of straightforward ASIS-based programming is usually needed. All the predefined rules are listed when running gnatcheck -h. The user is free to choose any set of rules that should be reported by TICS. As with other codecheckers, this is done by editing the RULES.txt and the IMPL.txt files within the cfg directory on the TICS FileServer. The user is free to choose the rule's identifier, severity level, category and synopsis in the RULES.txt. How TICS invokes gnatcheck is configured in the IMPL.txt. In this file, the rule identifiers of gnatcheck should be used. These are the first string before the "-" in the gnatcheck -h output. A short example of the IMPL.txt file is given below:

GC@001	gnatcheck	Abstract_Type_Declarations
GC@002	gnatcheck	Anonymous_Arrays
GC@003	gnatcheck	Anonymous_Subtypes
GC@004	gnatcheck	Blocks
GC@005	gnatcheck	Boolean_Relational_Operators

A standard gnatcheck rule configuration is available in the form of a IMPL.txt, RULES.txt pair.