This tutorial describes how the Static Analysis vs Coverage example flow gathers newly-introduced violations and correlates them with the coverage data in the same resource. Violations are prioritized to reflect their potential risk based on the coverage data and a configurable coverage threshold. The Risk/Impact for the violations will be set to one of the following values:
Extreme | File has no coverage |
---|---|
High | File has low coverage (coverage under the specified threshold) |
Low | File has acceptable coverage (coverage at or below the specified threshold) |
In this tutorial:
This example uses the Violations Event, which is a common utility flow shipped with Extension Designer. This flow is used to subscribe to events related to new or fixed static analysis violations sent into DTP. Choose Import > Library > Common > Violation Events to deploy the flow to the service.
Double-click the Set the file coverage threshold node. The coverage threshold is defined the the Rules section of the node. By default it is set to 30.0, which represents a file coverage threshold of 30.0%.
Double-click the Filter and group violations node and review the JavaScript. By default, violations related to code formatting are removed from the calculation. This is to avoid raising the Risk/Impact on violations that may not necessarily pose a significant risk compared to resource leaks, null pointer exceptions, and similar types of violations.
You can apply additional filtering strategies to further refine the violations you want to apply coverage risk analysis to. Filtering can also be removed so that all the new violations are subject to coverage risk calculation.
After the module coverage data has been obtained and the violations are filtered, the violations are grouped by projectResourcePath
. This parameter represents the file containing the violation. For each set of violations, file coverage for the projectResourcePath
is obtained and the set of violations is passed to a DTP REST API node so that the Risk/Impact can be set for the entire set of violations.