Skip to content

Commit d913ed1

Browse files
committed
fixup! rew! Add a Gherkin formatter
1 parent faab7fd commit d913ed1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/src/main/java/com/diffplug/spotless/gherkin/GherkinSimpleStep.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ FormatterFunc toFormatter() {
5454

5555
Method format;
5656
Constructor<?> constructor;
57-
Object formatter;
5857
try {
5958
ClassLoader classLoader = jarState.getClassLoader();
6059
Class<?> prettyFormatter = classLoader.loadClass("me.jvt.cucumber.gherkinformatter.PrettyFormatter");
6160
Class<?>[] constructorArguments = new Class[]{int.class};
6261
constructor = prettyFormatter.getConstructor(constructorArguments);
6362
format = prettyFormatter.getMethod("format", String.class);
64-
formatter = constructor.newInstance(indentSpaces);
65-
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
63+
} catch (ClassNotFoundException | NoSuchMethodException e) {
6664
throw new IllegalStateException(String.format("There was a problem preparing %s dependencies", MAVEN_COORDINATE), e);
6765
}
6866

@@ -71,6 +69,8 @@ FormatterFunc toFormatter() {
7169
return s;
7270
}
7371
try {
72+
Object formatter;
73+
formatter = constructor.newInstance(indentSpaces);
7474
return (String) format.invoke(formatter, s);
7575
} catch (InvocationTargetException ex) {
7676
throw new AssertionError("Unable to format Gherkin", ex.getCause());

0 commit comments

Comments
 (0)