Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: fix ReturnCount checkstyle violations #132

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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