All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.puresoltechnologies.purifinity.server.metrics.halstead.HalsteadQuality Maven / Gradle / Ivy

package com.puresoltechnologies.purifinity.server.metrics.halstead;

import com.puresoltechnologies.purifinity.analysis.domain.CodeRangeType;
import com.puresoltechnologies.purifinity.evaluation.domain.SourceCodeQuality;

public class HalsteadQuality {

	public static SourceCodeQuality get(CodeRangeType codeRangeType,
			HalsteadResult result) {
		if ((codeRangeType == CodeRangeType.FILE)
				|| (codeRangeType == CodeRangeType.CLASS)
				|| (codeRangeType == CodeRangeType.INTERFACE)
				|| (codeRangeType == CodeRangeType.ENUMERATION)
				|| (codeRangeType == CodeRangeType.ANNOTATION)
				|| (codeRangeType == CodeRangeType.MODULE)) {
			if (result.getHalsteadVolume() < 80) {
				return SourceCodeQuality.MEDIUM;
			}
			if (result.getHalsteadVolume() > 10000) {
				return SourceCodeQuality.LOW;
			}
			if (result.getHalsteadVolume() > 8000) {
				return SourceCodeQuality.MEDIUM;
			}
			return SourceCodeQuality.HIGH;
		} else if ((codeRangeType == CodeRangeType.CONSTRUCTOR)
				|| (codeRangeType == CodeRangeType.METHOD)
				|| (codeRangeType == CodeRangeType.PROGRAM)
				|| (codeRangeType == CodeRangeType.SUBROUTINE)
				|| (codeRangeType == CodeRangeType.FUNCTION)) {
			if (result.getHalsteadVolume() < 10) {
				return SourceCodeQuality.MEDIUM;
			}
			if (result.getHalsteadVolume() > 1250) {
				return SourceCodeQuality.LOW;
			}
			if (result.getHalsteadVolume() > 1000) {
				return SourceCodeQuality.MEDIUM;
			}
			return SourceCodeQuality.HIGH;
		} else if (codeRangeType == CodeRangeType.DIRECTORY) {
			return SourceCodeQuality.HIGH;
		}
		return SourceCodeQuality.UNSPECIFIED;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy