@Test public void testConvertCyclomaticComplexityToAbacusComplexity() { List<ComplexityThreshold> complexityThresholds = new ArrayList<ComplexityThreshold>(); complexityThresholds.add(new ComplexityThreshold("Simple", 10.0)); complexityThresholds.add(new ComplexityThreshold("Medium", 30.0)); complexityThresholds.add(new ComplexityThreshold("Complex", 60.0)); complexityThresholds.add(new ComplexityThreshold("Very complex", null)); Assert.assertEquals("Simple", ComplexityThresholdsUtils.convertCyclomaticComplexityToAbacusComplexity(5.0, complexityThresholds)); Assert.assertEquals("Medium", ComplexityThresholdsUtils.convertCyclomaticComplexityToAbacusComplexity(23.0, complexityThresholds)); Assert.assertEquals("Complex", ComplexityThresholdsUtils.convertCyclomaticComplexityToAbacusComplexity(36.0, complexityThresholds)); Assert.assertEquals("Very complex", ComplexityThresholdsUtils.convertCyclomaticComplexityToAbacusComplexity(77.0, complexityThresholds)); }
public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return complexity; }
ComplexityThresholdsUtils { public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return complexity; } }
ComplexityThresholdsUtils { public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return complexity; }  }
ComplexityThresholdsUtils { public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return complexity; }  static List<ComplexityThreshold> convertAbacusThresholdsToComplexityThresholds(String[] propertyThresholds); static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds); static void initCounterThreshold(List<ComplexityThreshold> complexityThresholds); static String buildComplexityDistributionMeasureValue(List<ComplexityThreshold> complexityThresholds); }
ComplexityThresholdsUtils { public static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds) { String complexity = null; for (ComplexityThreshold complexityThreshold : complexityThresholds) { if (complexityThreshold.getThreshold() == null) { complexity = complexityThreshold.getComplexityName(); break; } else { if (cyclomaticComplexity.doubleValue() <= complexityThreshold.getThreshold().doubleValue()) { complexity = complexityThreshold.getComplexityName(); break; } } } return complexity; }  static List<ComplexityThreshold> convertAbacusThresholdsToComplexityThresholds(String[] propertyThresholds); static String convertCyclomaticComplexityToAbacusComplexity(Double cyclomaticComplexity, List<ComplexityThreshold> complexityThresholds); static void initCounterThreshold(List<ComplexityThreshold> complexityThresholds); static String buildComplexityDistributionMeasureValue(List<ComplexityThreshold> complexityThresholds);  }