Main Content

Use a Justification Catalog to Autocomplete Annotations in Polyspace as You Code plugins

After you run an analysis, you can suppress known or acceptable defects or coding rule deviations by adding code annotations to indicate that the issue has been reviewed and will not be fixed.

If your organization has a predefined set of comments that you use to justify known or acceptable defects and coding standard deviations, you can store these comments in a justification catalog where you associate one or more comment with each defect or coding rule deviation. You can then pass this catalog to the Polyspace® as You Code Visual Studio Code extension or Eclipse™ plugin and use the predefined comments to autocomplete code annotations comments when you annotate the code.

Polyspace annotation autocomplete

You pass the catalog to Polyspace as You Code by specifying the path of the catalog file in these settings:

Create and Edit Justification Catalog

The justification catalog is a JSON file that uses the Polyspace code annotation syntax. For details of the syntax, see Annotation Syntax Details (Polyspace Bug Finder). To create a catalog, copy justification_catalog.json to a text editor and save it as a JSON file with UTF-8 encoding.

 justification_catalog.json

The JSON structure consists of a justifications array which contains a collection of objects with at least three key-value pairs each. An object represents a result and the comments that you want to associate with that result.

{
    "justifications":[
        {
            "family": "familyValue",
            "acronym": "acronymValue",
            "comment":[
                "autocomplete comment for family:acronym result",
                "some other autocomplete comment for the same result"
]
        }
    ]
}

  • Specify a Polyspace results family value for the family key.

  • Specify a Polyspace result name value for the acronym key.

  • Specify a comment for comment key to associate that comment with the Polyspace results with the family and result name that you specified in the other key-value pairs.

    To associate additional comments with a result, add more comment key-value pairs in the object which represents that result.

For example, in the file justification_catalog.json, the comments "This is my preset justification" and "Another justification for same defect" are available for autocomplete when you type an annotation for defect METHOD_NOT_CONST. Because the comment "Rule wildcard justification applies to all defects" applies to all defects, this comment is also available for autocomplete when you annotate METHOD_NOT_CONST.

External Websites