Skip to content

Commit f30c754

Browse files
update formatters
1 parent db54228 commit f30c754

25 files changed

+982
-845
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,15 @@
215215
<plugin>
216216
<groupId>com.diffplug.spotless</groupId>
217217
<artifactId>spotless-maven-plugin</artifactId>
218-
<version>2.7.0</version>
218+
<version>2.28.0</version>
219219
<configuration>
220220
<java>
221221
<includes>
222222
<include>src/main/java/**/*.java</include>
223223
<include>src/test/java/**/*.java</include>
224224
</includes>
225225
<googleJavaFormat>
226-
<version>1.9</version>
226+
<version>1.15.0</version>
227227
<style>GOOGLE</style>
228228
</googleJavaFormat>
229229
</java>
@@ -232,8 +232,8 @@
232232
<include>src/test/kotlin/**/*.kt</include>
233233
</includes>
234234
<ktfmt>
235-
<version>0.21</version>
236-
<style>DEFAULT</style>
235+
<version>0.39</version>
236+
<style>GOOGLE</style>
237237
</ktfmt>
238238
</kotlin>
239239
</configuration>

src/main/java/com/github/vertical_blank/sqlformatter/core/AbstractFormatter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public abstract class AbstractFormatter implements DialectConfigurator {
1616
private JSLikeList<Token> tokens;
1717
private int index;
1818

19-
/** @param cfg FormatConfig */
19+
/**
20+
* @param cfg FormatConfig
21+
*/
2022
public AbstractFormatter(FormatConfig cfg) {
2123
this.cfg = cfg;
2224
this.indentation = new Indentation(cfg.indent);

src/main/java/com/github/vertical_blank/sqlformatter/core/Indentation.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ enum IndentTypes {
2222
private final String indent;
2323
private final Stack<IndentTypes> indentTypes;
2424

25-
/** @param indent Indent value, default is " " (2 spaces) */
25+
/**
26+
* @param indent Indent value, default is " " (2 spaces)
27+
*/
2628
Indentation(String indent) {
2729
this.indent = indent;
2830
this.indentTypes = new Stack<>();

src/main/java/com/github/vertical_blank/sqlformatter/core/Params.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ public interface Params {
1616

1717
Object getByName(String key);
1818

19-
/** @param params query param */
19+
/**
20+
* @param params query param
21+
*/
2022
public static Params of(Map<String, ?> params) {
2123
return new NamedParams(params);
2224
}
2325

24-
/** @param params query param */
26+
/**
27+
* @param params query param
28+
*/
2529
public static Params of(List<?> params) {
2630
return new IndexedParams(params);
2731
}

src/test/kotlin/com/github/vertical_blank/sqlformatter/BehavesLikeMariaDbFormatter.kt

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,56 @@ fun Suite.behavesLikeMariaDbFormatter(formatter: SqlFormatter.Formatter) {
1717
supportsCreateTable(formatter)
1818
supportsAlterTable(formatter)
1919
supportsStrings(
20-
formatter,
21-
listOf(StringLiteral.DOUBLE_QUOTE, StringLiteral.SINGLE_QUOTE, StringLiteral.BACK_QUOTE))
20+
formatter,
21+
listOf(StringLiteral.DOUBLE_QUOTE, StringLiteral.SINGLE_QUOTE, StringLiteral.BACK_QUOTE)
22+
)
2223
supportsBetween(formatter)
2324
supportsOperators(
24-
formatter,
25-
listOf(
26-
"%",
27-
"&",
28-
"|",
29-
"^",
30-
"~",
31-
"!=",
32-
"!",
33-
"<=>",
34-
"<<",
35-
">>",
36-
"&&",
37-
"||",
38-
":=",
39-
))
25+
formatter,
26+
listOf(
27+
"%",
28+
"&",
29+
"|",
30+
"^",
31+
"~",
32+
"!=",
33+
"!",
34+
"<=>",
35+
"<<",
36+
">>",
37+
"&&",
38+
"||",
39+
":=",
40+
)
41+
)
4042
supportsJoin(
41-
formatter,
42-
without = listOf("FULL"),
43-
additionally =
44-
listOf(
45-
"STRAIGHT_JOIN",
46-
"NATURAL LEFT JOIN",
47-
"NATURAL LEFT OUTER JOIN",
48-
"NATURAL RIGHT JOIN",
49-
"NATURAL RIGHT OUTER JOIN",
50-
))
43+
formatter,
44+
without = listOf("FULL"),
45+
additionally =
46+
listOf(
47+
"STRAIGHT_JOIN",
48+
"NATURAL LEFT JOIN",
49+
"NATURAL LEFT OUTER JOIN",
50+
"NATURAL RIGHT JOIN",
51+
"NATURAL RIGHT OUTER JOIN",
52+
)
53+
)
5154

5255
it("supports # comments") {
5356
expect(format("SELECT a # comment\nFROM b # comment"))
54-
.toBe(
55-
"""
57+
.toBe(
58+
"""
5659
SELECT
5760
a # comment
5861
FROM
5962
b # comment
60-
""".trimIndent())
63+
""".trimIndent()
64+
)
6165
}
6266

6367
it("supports @variables") {
6468
expect(format("SELECT @foo, @bar"))
65-
.toBe("""
69+
.toBe("""
6670
SELECT
6771
@foo,
6872
@bar
@@ -71,16 +75,17 @@ fun Suite.behavesLikeMariaDbFormatter(formatter: SqlFormatter.Formatter) {
7175

7276
it("supports setting variables: @var :=") {
7377
expect(format("SET @foo := (SELECT * FROM tbl);"))
74-
.toBe(
75-
"""
78+
.toBe(
79+
"""
7680
SET
7781
@foo := (
7882
SELECT
7983
*
8084
FROM
8185
tbl
8286
);
83-
""".trimIndent())
87+
""".trimIndent()
88+
)
8489
}
8590
}
8691
}

0 commit comments

Comments
 (0)