@Override
public void analyse(Project module, SensorContext context) {
String complexityResults = this.getExecutor().GenerateResults();
if(complexityResults != "")
{
HashMap<String, Double> complexityInfo = this.getParser().Parse(complexityResults);
if (complexityInfo != null)
{
for (InputFile file : moduleFileSystem.inputFiles(this.filePredicates.hasLanguage(TypeScriptLanguage.LANGUAGE_KEY)))
{
String fileName = file.file().getPath();
LOG.info("Complexity for: "+fileName);
Double complexityValue = 0.0;
for(Map.Entry<String, Double> entry :complexityInfo.entrySet())
{
if (fileName.contains(entry.getKey()))
{
complexityValue = entry.getValue();
break;
}
}
if( complexityValue != 0.0)
{
LOG.debug("Complexity for: "+file.file().getName() +" Value: "+complexityValue);
Measure<Double> fileComplexity = new Measure<Double>(CoreMetrics.FILE_COMPLEXITY, (double) complexityValue);
context.saveMeasure(file, fileComplexity );
}
}
}
}
}
Measure<Double> fileComplexity = new Measure<Double>(CoreMetrics.COMPLEXITY, (double) complexityValue);