Managing stored metrics in Validate

To decrease the build load time and disc space required for larger projects, use a stored metrics configuration (SMC) file that specifies which metrics are stored in Validate. Excluded metrics are filtered out while the database is loading.

The SMC file affects the metrics stored in Validate, not the metrics analyzed. During a build, the analysis engine(s) generate metrics for your entire project, regardless of which metrics are specified in the SMC file.

For a full list of metrics, see the Metrics reference.

Choosing from a default SMC file

In Validate, you can manage SMC files from the project Configuration tab, in the left pane under the CONFIGURATION FILES category. Click an SMC file to edit it, then click Save to save your changes.

When you upload a new SMC file or edit an SMC file in Validate, the file will be evaluated. If invalid syntax is detected, or if the file fails to include one or more metrics that are specified in your compliance reports, Validate issues a warning.

You can use one SMC file per project. If you are using a report for which you can specify metrics, consider including those metrics in your SMC file.

Default SMC files:

  • all_metrics.smc includes all metrics.
  • stored_metrics.smc is used by default, and includes the metrics required for the Churn report and Complexity reports.
  • reports_metrics.smc includes the metrics required for the Churn report and Complexity reports.
  • required_metrics.smc includes the metrics required for the Compliance report.
  • performant_metrics.smc includes several key file-level and class-level metrics, and excludes functional metrics.

Changing the default SMC file

The stored_metrics.smc file is the default SMC file. To change the default SMC file, load it to your workspace. After that, all new projects will use the new SMC file.

If you rename an SMC file in the install directory to stored_metrics.smc, and then you create a new projects_root directory or migrate your existing directory, the renamed file will be used for all new projects.

To avoid manually updating the SMC file for each new project, update the stored_metrics.smc file to contain the metrics that you want before you create or migrate a projects_root directory.

Importing an SMC file

To learn how to import SMC files into new or existing projects, see Configuring a single project or an entire projects_root.

Creating a custom SMC file

You can create a custom SMC file, which must be in YAML or JSON format.

The file must contain a metrics property with a list of metrics that can be strings (metric codes) or numbers (metric IDs).

For example, to store the LOC_FILE, NOCLASSDECL, and NOCONSTDECL metrics, you can specify the metric codes:

metrics: [
    LOC_FILE,       # number of lines of code 
    NOCLASSDECL,    # number of class declarations 
    NOCONSTDECL,    # number of constant declarations
]

Alternatively, you can specify the metric ID numbers:

metrics: [
    7,              # number of lines of code 
    8,              # number of class declarations 
    9,              # number of constant declarations
]

Loading all metrics to Validate

Loading all metrics increases load time and disc space for larger projects.

To load all metrics to Validate, you have several options:

  • Use the all_metrics.smc file.
  • Delete your current SMC file.
  • Delete all metrics from your current SMC file (use an empty SMC file).