Skip to content

Commit

Permalink
Issue #130: fix ReturnCount checkstyle violations
Browse files Browse the repository at this point in the history
  • Loading branch information
romani committed Nov 7, 2017
1 parent 96fa938 commit d20b6a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ static String getRuleKey(AuditEvent event) {

@VisibleForTesting
static String getMessage(AuditEvent event) {
String result;
try {
return event.getMessage();
result = event.getMessage();

}
catch (Exception ex) {
LOG.warn("AuditEvent is created incorrectly. Exception happen during getMessage()", ex);
return null;
result = null;
}
return result;
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ public List<File> getSourceFiles() {
}

public File getTargetXmlReport() {
File result = null;
if (conf.getBoolean(PROPERTY_GENERATE_XML)) {
return new File(fileSystem.workDir(), "checkstyle-result.xml");
result = new File(fileSystem.workDir(), "checkstyle-result.xml");
}
return null;
return result;
}

public Configuration getCheckstyleConfiguration() throws CheckstyleException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ static boolean isIgnored(String configKey) {

@VisibleForTesting
static boolean isFilter(String configKey) {
boolean result = false;
for (String filter : FILTERS) {
if (StringUtils.equals(configKey, filter)) {
return true;
result = true;
break;
}
}
return false;
return result;
}

private void processRule(RulesProfile profile, String path, String moduleName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,18 @@ else if (module == RegexpSinglelineCheck.class
*/
public static String getCheckMessage(Class<?> module, String messageKey,
Object... arguments) {
String result;
final Properties pr = new Properties();
try {
pr.load(module.getResourceAsStream("messages.properties"));
final MessageFormat formatter =
new MessageFormat(pr.getProperty(messageKey), Locale.ENGLISH);
result = formatter.format(arguments);
}
catch (IOException ex) {
return null;
result = null;
}
final MessageFormat formatter =
new MessageFormat(pr.getProperty(messageKey), Locale.ENGLISH);
return formatter.format(arguments);
return result;
}

public static String getTokenText(int[] tokens, int... subtractions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@ private XmlUtil() {

public static Document getRawXml(String fileName, String code, String unserializedSource)
throws ParserConfigurationException {
Document result = null;
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);

final DocumentBuilder builder = factory.newDocumentBuilder();

return builder.parse(new InputSource(new StringReader(code)));
result = builder.parse(new InputSource(new StringReader(code)));
}
catch (IOException | SAXException ex) {
Assert.fail(fileName + " has invalid xml (" + ex.getMessage() + "): "
+ unserializedSource);
}

return null;
return result;
}

public static Set<Node> getChildrenElements(Node node) {
Expand Down

0 comments on commit d20b6a3

Please sign in to comment.