Skip to content

Commit 1ce8062

Browse files
authored
Merge pull request #154 from jpenilla/fix-newline
Fix newLine option with formats that have null `end`
2 parents 5083e3b + 4bd777e commit 1ce8062

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

indra-licenser-spotless/src/main/java/net/kyori/indra/licenser/spotless/internal/IndraSpotlessLicenserExtensionImpl.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of indra, licensed under the MIT License.
33
*
4-
* Copyright (c) 2020-2022 KyoriPowered
4+
* Copyright (c) 2020-2023 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -160,15 +160,14 @@ private static String formatHeader(final String header, final HeaderFormat forma
160160
final String lineSeparator = System.lineSeparator();
161161
// Apply header format to contents
162162
final String prefix = format.begin() != null ? format.begin() + lineSeparator : "";
163-
final String suffix;
163+
String suffix;
164164
if (format.end() != null) {
165-
if (newLine) {
166-
suffix = lineSeparator + format.end() + lineSeparator + lineSeparator;
167-
} else {
168-
suffix = lineSeparator + format.end() + lineSeparator;
169-
}
165+
suffix = lineSeparator + format.end() + lineSeparator;
170166
} else {
171-
suffix = "";
167+
suffix = lineSeparator;
168+
}
169+
if (newLine) {
170+
suffix = suffix + lineSeparator;
172171
}
173172
return LINE_SPLIT.splitAsStream(header)
174173
.map(line -> {

0 commit comments

Comments
 (0)