1
0

Use Checkstyle ParenPad

This commit is contained in:
Gary Gregory
2023-11-26 15:06:34 -05:00
parent 1290cecf73
commit 1a30b658bd
2 changed files with 18 additions and 19 deletions

View File

@@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<!DOCTYPE module PUBLIC <!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd"> "https://checkstyle.org/dtds/configuration_1_3.dtd">
@@ -23,7 +22,7 @@ limitations under the License.
<!-- commons logging customization of default Checkstyle behavior --> <!-- commons logging customization of default Checkstyle behavior -->
<module name="Checker"> <module name="Checker">
<property name="localeLanguage" value="en" /> <property name="localeLanguage" value="en" />
<property name="severity" value="warning"/> <property name="severity" value="warning" />
<!-- Checks whether files end with a new line. --> <!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
@@ -57,7 +56,7 @@ limitations under the License.
</module> </module>
<module name="LineLength"> <module name="LineLength">
<property name="max" value="160"/> <property name="max" value="160" />
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">
@@ -65,12 +64,13 @@ limitations under the License.
<property name="option" value="eol" /> <property name="option" value="eol" />
</module> </module>
<module name="ImportOrder"> <module name="ImportOrder">
<property name="option" value="top"/> <property name="option" value="top" />
<property name="groups" value="java,javax,org"/> <property name="groups" value="java,javax,org" />
<property name="ordered" value="true"/> <property name="ordered" value="true" />
<property name="separated" value="true"/> <property name="separated" value="true" />
<property name="sortStaticImportsAlphabetically" value="true"/> <property name="sortStaticImportsAlphabetically" value="true" />
</module> </module>
<module name="WhitespaceAfter" /> <module name="WhitespaceAfter" />
<module name="ParenPad" />
</module> </module>
</module> </module>

View File

@@ -159,11 +159,10 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
final Throwable throwable = new Throwable(); final Throwable throwable = new Throwable();
throwable.fillInStackTrace(); throwable.fillInStackTrace();
final StringWriter stringWriter = new StringWriter(); final StringWriter stringWriter = new StringWriter();
final PrintWriter printWriter = new PrintWriter( stringWriter ); final PrintWriter printWriter = new PrintWriter(stringWriter);
throwable.printStackTrace( printWriter ); throwable.printStackTrace(printWriter);
final String traceString = stringWriter.getBuffer().toString(); final String traceString = stringWriter.getBuffer().toString();
final StringTokenizer tokenizer = final StringTokenizer tokenizer = new StringTokenizer(traceString, "\n");
new StringTokenizer( traceString, "\n" );
tokenizer.nextToken(); tokenizer.nextToken();
String line = tokenizer.nextToken(); String line = tokenizer.nextToken();
while (!line.contains(this.getClass().getName())) { while (!line.contains(this.getClass().getName())) {
@@ -172,13 +171,13 @@ public class Jdk13LumberjackLogger implements Log, Serializable {
while (line.contains(this.getClass().getName())) { while (line.contains(this.getClass().getName())) {
line = tokenizer.nextToken(); line = tokenizer.nextToken();
} }
final int start = line.indexOf( "at " ) + 3; final int start = line.indexOf("at ") + 3;
final int end = line.indexOf( '(' ); final int end = line.indexOf('(');
final String temp = line.substring( start, end ); final String temp = line.substring(start, end);
final int lastPeriod = temp.lastIndexOf( '.' ); final int lastPeriod = temp.lastIndexOf('.');
sourceClassName = temp.substring( 0, lastPeriod ); sourceClassName = temp.substring(0, lastPeriod);
sourceMethodName = temp.substring( lastPeriod + 1 ); sourceMethodName = temp.substring(lastPeriod + 1);
} catch ( final Exception ex ) { } catch (final Exception ex) {
// ignore - leave class and methodname unknown // ignore - leave class and methodname unknown
} }
classAndMethodFound = true; classAndMethodFound = true;