8.6. Details about Sonargraph's Resolution Matching

Resolutions contain the fully qualified name of the affected element, so that they can be applied again when the System is cleared and parsed or opened. As a consequence resolutions are vulnerable against rename operations of directories and files. With Sonargraph version 10.5 advanced resolution matching has been introduced for cycle groups and duplicate code blocks, so that the resolutions are matched, even if the fully qualified names of involved elements got changed. The "confidence" of the resolution match is shown in the "Ignores" and "Tasks" views. Matching succeeds if the confidence is greater than 0.6. The same algorithms are also used by the "System Diff" to identify matching issues from the baseline.

Also with Sonargraph version 10.5, the Script API was improved with the data type ISourceLineAccess that provides access to file content and can be used to create issues that are more resilient against code changes by applying a similarity matching algorithm taking into account the line's text, the line number, and surrounding lines as context. The following program listing shows the key part of the script "FindFixmeAndTodosInComments.xml" (available in the "Core" quality model) that has been improved with the new methods of the Script API:

    SourceFileAccess source ->
    List<ISourceLineAccess> lines = source.getSourceLines();
        for(SourceLineAccess line : lines)
            def fixmeMatcher = (line.getText() =~ fixmePattern);
            if(fixmeMatcher.count > 0)
                numberOfFixmes += fixmeMatcher.count;
                def text = extractText(fixmeMatcher);
                result.addWarningIssue(source, "FIXME", text, line);

Using this API, resolutions are now only applied for the selected issue and no longer automatically for all "FIXME"-issues in the same file. "FIXME"-issues added later to the file need to be resolved separately offering a better control over new issues.