org.sonar.api.server.rule.RulesDefinition.DebtRemediationFunctions Java Examples
The following examples show how to use
org.sonar.api.server.rule.RulesDefinition.DebtRemediationFunctions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Remediation.java From enforce-sonarqube-plugin with MIT License | 5 votes |
public DebtRemediationFunction remediationFunction(DebtRemediationFunctions debt) { if (func.startsWith("Constant")) { return debt.constantPerIssue(constantCost.replace("mn", "min")); } if ("Linear".equals(func)) { return debt.linear(linearFactor.replace("mn", "min")); } return debt.linearWithOffset(linearFactor.replace("mn", "min"), linearOffset.replace("mn", "min")); }
Example #2
Source File: RemediationTest.java From enforce-sonarqube-plugin with MIT License | 5 votes |
@Test public void testRemediationFunctionConstantPerIssue() { remediation.func = "Constant issue"; remediation.constantCost = "3 mn"; DebtRemediationFunctions functions = mock(DebtRemediationFunctions.class); DebtRemediationFunction function = mock(DebtRemediationFunction.class); when(functions.constantPerIssue(eq(remediation.constantCost))).thenReturn(function); when(function.coefficient()).thenReturn("3 min"); remediation.remediationFunction(functions); verify(functions).constantPerIssue("3 min"); assertEquals("3 min",function.coefficient()); }
Example #3
Source File: RemediationTest.java From enforce-sonarqube-plugin with MIT License | 5 votes |
@Test public void testRemediationFunctionLinear() { remediation.func = "Linear"; remediation.linearFactor = "2 mn"; DebtRemediationFunctions functions = mock(DebtRemediationFunctions.class); DebtRemediationFunction function = mock(DebtRemediationFunction.class); when(functions.linear(eq(remediation.linearFactor))).thenReturn(function); when(function.coefficient()).thenReturn("2 min"); remediation.remediationFunction(functions); verify(functions).linear("2 min"); assertEquals("2 min",function.coefficient()); }
Example #4
Source File: RemediationTest.java From enforce-sonarqube-plugin with MIT License | 5 votes |
@Test public void testRemediationFunctionlinearWithOffset() { remediation.func = "somethingElse"; remediation.linearFactor = "2 mn"; remediation.linearOffset = "2 mn"; DebtRemediationFunctions functions = mock(DebtRemediationFunctions.class); DebtRemediationFunction function = mock(DebtRemediationFunction.class); when(functions.linearWithOffset(eq(remediation.linearFactor), eq(remediation.linearOffset))).thenReturn(function); when(function.coefficient()).thenReturn("2 min"); remediation.remediationFunction(functions); verify(functions).linearWithOffset("2 min", "2 min"); assertEquals("2 min",function.coefficient()); }
Example #5
Source File: RulesLoader.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
private void setTechnicalDebt(RulesDefinition.NewRule rule, Metadata metadataAnnotation) { String technicalDebt = metadataAnnotation.technicalDebt(); if (StringUtils.isNotEmpty(technicalDebt)) { DebtRemediationFunctions remediationFunction = rule.debtRemediationFunctions(); rule.setDebtRemediationFunction(remediationFunction.constantPerIssue(technicalDebt)); } }