com.puresoltechnologies.purifinity.server.metrics.mccabe.McCabeQuality Maven / Gradle / Ivy
package com.puresoltechnologies.purifinity.server.metrics.mccabe;
import com.puresoltechnologies.purifinity.analysis.domain.CodeRangeType;
import com.puresoltechnologies.purifinity.evaluation.domain.SourceCodeQuality;
public class McCabeQuality {
public static SourceCodeQuality get(CodeRangeType codeRangeType,
int cyclomaticNumber) {
if ((codeRangeType == CodeRangeType.FILE)
|| (codeRangeType == CodeRangeType.CLASS)
|| (codeRangeType == CodeRangeType.INTERFACE)
|| (codeRangeType == CodeRangeType.ENUMERATION)
|| (codeRangeType == CodeRangeType.ANNOTATION)
|| (codeRangeType == CodeRangeType.MODULE)) {
if (cyclomaticNumber < 100) {
return SourceCodeQuality.HIGH;
}
if (cyclomaticNumber < 125) {
return SourceCodeQuality.MEDIUM;
}
return SourceCodeQuality.LOW;
} else if ((codeRangeType == CodeRangeType.CONSTRUCTOR)
|| (codeRangeType == CodeRangeType.METHOD)
|| (codeRangeType == CodeRangeType.PROGRAM)
|| (codeRangeType == CodeRangeType.SUBROUTINE)
|| (codeRangeType == CodeRangeType.FUNCTION)) {
if (cyclomaticNumber < 15) {
return SourceCodeQuality.HIGH;
}
if (cyclomaticNumber < 20) {
return SourceCodeQuality.MEDIUM;
}
return SourceCodeQuality.LOW;
} else if (codeRangeType == CodeRangeType.DIRECTORY) {
return SourceCodeQuality.HIGH;
}
return SourceCodeQuality.UNSPECIFIED;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy