Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c1140b
commit e41b580
Showing
46 changed files
with
3,554 additions
and
1,639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 68 additions & 71 deletions
139
src/main/java/com/thalesgroup/hudson/plugins/cppcheck/CppcheckMetricUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,68 @@ | ||
package com.thalesgroup.hudson.plugins.cppcheck; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
import com.thalesgroup.hudson.plugins.cppcheck.config.CppcheckConfig; | ||
|
||
public class CppcheckMetricUtil { | ||
|
||
public static int convert(String threshold) { | ||
if (isValid(threshold)) { | ||
if (StringUtils.isNotBlank(threshold)) { | ||
try { | ||
return Integer.valueOf(threshold); | ||
} | ||
catch (NumberFormatException exception) { | ||
// not valid | ||
} | ||
} | ||
} | ||
throw new IllegalArgumentException("Not a parsable integer value >= 0: " + threshold); | ||
} | ||
|
||
public static boolean isValid(final String threshold) { | ||
if (StringUtils.isNotBlank(threshold)) { | ||
try { | ||
return Integer.valueOf(threshold) >= 0; | ||
} | ||
catch (NumberFormatException exception) { | ||
// not valid | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static String getMessageSelectedSeverties(CppcheckConfig cppcheckConfig) { | ||
StringBuffer sb = new StringBuffer(); | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isAllSeverities()) { | ||
sb.append("with all severities"); | ||
return sb.toString(); | ||
} | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityError()) { | ||
sb.append(" and "); | ||
sb.append("severity 'error'"); | ||
} | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleError()) { | ||
sb.append(" and "); | ||
sb.append("severity 'possible error'"); | ||
} | ||
|
||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleStyle()) { | ||
sb.append(" and "); | ||
sb.append("severity 'possible style'"); | ||
} | ||
|
||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle()) { | ||
sb.append(" and "); | ||
sb.append("severity 'style'"); | ||
} | ||
|
||
if (sb.length() != 0) | ||
sb.delete(0, 5); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
} | ||
package com.thalesgroup.hudson.plugins.cppcheck; | ||
|
||
import com.thalesgroup.hudson.plugins.cppcheck.config.CppcheckConfig; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
public class CppcheckMetricUtil { | ||
|
||
public static int convert(String threshold) { | ||
if (isValid(threshold)) { | ||
if (StringUtils.isNotBlank(threshold)) { | ||
try { | ||
return Integer.valueOf(threshold); | ||
} catch (NumberFormatException exception) { | ||
// not valid | ||
} | ||
} | ||
} | ||
throw new IllegalArgumentException("Not a parsable integer value >= 0: " + threshold); | ||
} | ||
|
||
public static boolean isValid(final String threshold) { | ||
if (StringUtils.isNotBlank(threshold)) { | ||
try { | ||
return Integer.valueOf(threshold) >= 0; | ||
} catch (NumberFormatException exception) { | ||
// not valid | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static String getMessageSelectedSeverties(CppcheckConfig cppcheckConfig) { | ||
StringBuffer sb = new StringBuffer(); | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isAllSeverities()) { | ||
sb.append("with all severities"); | ||
return sb.toString(); | ||
} | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityError()) { | ||
sb.append(" and "); | ||
sb.append("severity 'error'"); | ||
} | ||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleError()) { | ||
sb.append(" and "); | ||
sb.append("severity 'possible error'"); | ||
} | ||
|
||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityPossibleStyle()) { | ||
sb.append(" and "); | ||
sb.append("severity 'possible style'"); | ||
} | ||
|
||
|
||
if (cppcheckConfig.getConfigSeverityEvaluation().isSeverityStyle()) { | ||
sb.append(" and "); | ||
sb.append("severity 'style'"); | ||
} | ||
|
||
if (sb.length() != 0) | ||
sb.delete(0, 5); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.