sonarqube didn't show the incremental analysis results from eslint report.json

36 Views Asked by At

Our company uses the community version of sonarqube, so it does not support the branch scanning function. In order to support the branch scanning function, we use an open source plug-in: sonarqube-community-branch-plugin to enable sonarqube to support the branch scanning function. Then I used eslint to scan my front-end code and generated a report. Then during the execution of eslint, we modified the return format of the report. The js file with the modified format is as follows:

module.exports = function(results) {
    var summary = {
        issues: []
    };
    results.forEach(function(result) {
        result.messages.forEach(function(msg) {
            var logMessage = {
                engineId: "eslint",
                ruleId: msg.ruleId,
                primaryLocation: {
                    message: msg.message,
                    filePath: result.filePath,
                    textRange: {
                        startLine: msg.line,
                        endLine: msg.endLine,
                        endColumn: msg.endColumn
                    }
                }
            };
            // The log message type and severity is up to you but you need to take in consideration SonarQube properties
            if (msg.severity === 1) {
                logMessage.type = "CODE_SMELL";
                logMessage.severity = "INFO";
            }
            if (msg.severity === 2) {
                logMessage.type = "BUG";
                logMessage.severity = "MAJOR";
            }
            summary.issues.push(logMessage);
        });
    });
    return JSON.stringify(summary);
}

Then after I uploaded the report to sonarqube, sonarqube did not display the incremental report of my report relative to the master. Why?

I hope that sonarqube can correctly obtain the results of the report generated by eslint, and then correctly display the incremental report (relative to the master's incremental code)

0

There are 0 best solutions below