Using a customized Naming script file

In HCL DevOps Test Embedded for Eclipse IDE (Test Embedded for Eclipse IDE), you can utilize the capabilities of Code Review to edit and customize a Perl Naming script file, adapting it to comply with your specific naming rules. With this feature, you have the flexibility to verify only the symbols found within the sources under test.

Testing symbols name with a customized script file

In Test Embedded or Test Embedded Studio, you can use Code Review to perform naming rule checks on the symbols in your source code under test.

These symbol can be:
  • Enum names
  • Struct/union fields names
  • Variables names
  • Functions names

These checks are performed using a Perl Naming script file that you can customize to your specific naming rules. The Rules raised can be Rule U99.1 to Rule U99.10. You have the flexibility to adjust their level (error/warning) within the confure_2012.xml and confrule.xml files. The rule description is passed as a parameter, that allow you to set it inside the Perl script.

The build phases are:
  1. Generate a .xob for each source
    • Use the crccc to create a .xob file for each source, incorporating symbols such as @vars, @types, @fields, @enums, @fcts, @files, and @basetypes. This process results in the generation of the Naming database in Perl.
  2. Generate a cross reference file in Perl format
    • Utilize crcld with the -xref option to generate a cross-reference file in Perl format (<xref_file_name.pl>), which includes information on files, types, variables, and functions.
  3. Create a Perl script with custom rules
    • Create a Perl script that incorporates specific rules, by using the database created (<xref_file_name.pl>). See the database array description in the example script "NamingRules1.pl" located in <Installation folder>\lib\scripts. The Perl script creates an additional .xob file containing the application of your user-defined rules to the existing database.
  4. Generate the Code Review report
    • Utilize crcld on all .xob files, which include those generated by crccc and your custom script file.

Setting the path to a customized Naming script file:

  1. From the Project Explorer view, select the project node.

    settings

  2. Right-click and select Settings.

    select settings

  3. Select Code Review > Naming script file and then select the Perl script checking your naming rules.

  4. Select the Code Review checkbox.

    enable code review

  5. Select the sample file that you installed: Example “NamingRules1.pl".
  6. Click Apply.

Modifying the naming rules

You are provided with a tool along with the file 'NamingRules1.pl,' located in the folder <Installation folder>\lib\scripts.

The 'NamingRules1.pl' file contains several examples of Naming Rule checkers, all linked to the first rule, U99.1. You can copy and edit this example. Modify existing rules or add new rules based on the documentation found in the header file (database array description).

Using naming script from the command line in Makefile

Analyze C source code under test and generate an object file (.xob).
crccc <source> <xob> <def> <opp> [<options>]
where:

<source> is the C source file under analysis.

<xob> is the name of the generated object file.

<def> is the standard definitions file. This file is searched in the $ATLTGT directory.

<opp> is the parser options file. This file is searched in the $ATLTGT directory.

For example,
crccc mysource.c output.xob atus_c.def atl.opp  rule=$TESTRT_DIR/plugins/Common/lib/confrule.xml
For more information about the options, see C Code Review Compiler - crccc.
You can use crcld in the following manner:
crcld -xref="<model_file>.pl" "<crccc_result_file>.xob" -RULE="<confrule file>.xml" -TEST
  • <model_file>.pl: Contains data needed for custom namecheck rules.
  • <model_file>.R99.1.xob: File to be used in the final launch of crcld.

You can use this xob file as usual on next call to crcld:

crcld -crc="<crc_file_name>.crc" "<all other xob file name>.xob" "<model_file>.R99.1.xob" -RULE="<confrule_file>.xml" -TEST