Skip to content

Commit

Permalink
Checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Turov committed Sep 2, 2020
1 parent ef8293e commit 426a33b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 20 deletions.
4 changes: 3 additions & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

<!-- Checks whether files end with a new line. -->
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf" />
</module>

<!-- Checks that property files contain the same keys. -->
<!-- See https://checkstyle.org/config_misc.html#Translation -->
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/hyperskill/hstest/common/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;

public class JsonUtils {
public final class JsonUtils {

private JsonUtils() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

public final class ReflectionUtils {

private ReflectionUtils() { }
private ReflectionUtils() {
}

public static Method getMainMethod(Class<?> clazz) {
Method mainMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private SystemHandler() { }
private static Locale oldLocale;
private static String oldLineSeparator;

private final static String separatorProperty = "line.separator";
private static final String separatorProperty = "line.separator";

public static void setUpSystem() {
SystemOutHandler.replaceSystemOut();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ static List<DynamicTesting> searchDynamicTestingMethods(Object obj) {
if (!Modifier.isPublic(method.getModifiers())) {
String className = method.getDeclaringClass().getSimpleName();
String methodName = method.getName();
feedback += " Try to declare method \"" +
className + "." + methodName + "\" as public";
feedback += " Try to declare method \""
+ className + "." + methodName + "\" as public";
}
throw new UnexpectedError(feedback, ex);
}
Expand Down Expand Up @@ -219,8 +219,8 @@ static List<DynamicTesting> searchDynamicTestingVariables(Object obj) {
if (!Modifier.isPublic(field.getModifiers())) {
String className = field.getDeclaringClass().getSimpleName();
String fieldName = field.getName();
feedback += " Try to declare field \"" +
className + "." + fieldName + "\" as public";
feedback += " Try to declare field \""
+ className + "." + fieldName + "\" as public";
}
throw new UnexpectedError(feedback, ex);
} catch (Exception ex) {
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/org/hyperskill/hstest/stage/SpringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import java.util.Map;

import static org.hyperskill.hstest.common.Utils.sleep;
import static org.hyperskill.hstest.mocks.web.constants.Methods.*;
import static org.hyperskill.hstest.mocks.web.constants.Methods.DELETE;
import static org.hyperskill.hstest.mocks.web.constants.Methods.GET;
import static org.hyperskill.hstest.mocks.web.constants.Methods.POST;
import static org.hyperskill.hstest.mocks.web.constants.Methods.PUT;
import static org.hyperskill.hstest.mocks.web.request.HttpRequestExecutor.packUrlParams;

public abstract class SpringTest extends StageTest<Object> {
Expand Down Expand Up @@ -86,7 +89,7 @@ private static int detectPort() {

String line;
String toSearch = "server.port";
while((line = bufReader.readLine()) != null) {
while ((line = bufReader.readLine()) != null) {
if (line.startsWith(toSearch) && line.contains("=")) {
String portNumber = line.substring(line.indexOf("=") + 1).trim();
return Integer.parseInt(portNumber);
Expand Down Expand Up @@ -123,9 +126,9 @@ public void stopSpring() {
int status = post("/actuator/shutdown", "").send().getStatusCode();

if (status != 200) {
throw new WrongAnswer("Cannot stop Spring application.\n" +
"Please make POST \"/actuator/shutdown\" endpoint accessible without authentication.\n" +
"The endpoint should return status code 200, returned " + status + ".");
throw new WrongAnswer("Cannot stop Spring application.\n"
+ "Please make POST \"/actuator/shutdown\" endpoint accessible without authentication.\n"
+ "The endpoint should return status code 200, returned " + status + ".");
}

springRunning = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/**
* Command-line options passed to the JVM listed in one place
*/
public class ExecutionOptions {
public final class ExecutionOptions {
private ExecutionOptions() { }

/**
* Unit tests contain slow tests (time limit tests)
* and to skip them an argument "-DskipSlow=true" should be passed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public TestedProgram(Class<?> testedClass) {
private String waitOutput(String input) {
if (!isWaitingInput()) {
throw new UnexpectedError(
"Tested program is not waiting for the input " +
"(state == \"" + machine.getState() + "\")");
"Tested program is not waiting for the input "
+ "(state == \"" + machine.getState() + "\")");
}

if (noMoreInput) {
Expand Down Expand Up @@ -149,7 +149,7 @@ private String waitInput() {
private void invokeMain(String[] args) {
try {
machine.waitState(ProgramState.RUNNING);
methodToInvoke.invoke(null, new Object[] { args });
methodToInvoke.invoke(null, new Object[] {args});
machine.setState(ProgramState.FINISHED);
} catch (InvocationTargetException ex) {
if (StageTest.getCurrTestRun().getErrorInTest() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public ExpectationJsonBuilder<T> atPath(String... path) {
JsonObject obj = elem.getAsJsonObject();

if (!obj.has(key)) {
feedback += "\n\nJSON should contain an object with key \""+ key + "\"";
feedback += "\n\nJSON should contain an object with key \"" + key + "\"";

if (key.matches("[0-9]+")) {
int index = Integer.parseInt(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.util.regex.Pattern;

public class JsonChecker {
public final class JsonChecker {
private JsonChecker() { }

public static JsonAnyBuilder any() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<Double> doublesOnly(String delim) {
}

public List<String> regex(String pattern) {
return regex(pattern,"words with pattern " + pattern);
return regex(pattern, "words with pattern " + pattern);
}

public List<String> regex(String pattern, String patternDescription) {
Expand Down

0 comments on commit 426a33b

Please sign in to comment.