[FOray-commit] SF.net SVN: foray:[11821] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-01-18 13:15:29
|
Revision: 11821
http://sourceforge.net/p/foray/code/11821
Author: victormote
Date: 2021-01-18 13:15:27 +0000 (Mon, 18 Jan 2021)
Log Message:
-----------
Add SuppressionWithNearbyCommentFilter to checkstyle config to allow System.exit calls to be marked as allowable more cleanly.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/resources/logback.xml
trunk/foray/foray-common/src/test/resources/logback-test.xml
trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java
trunk/foray/master/config/checkstyle/checkstyle-config.xml
Modified: trunk/foray/foray-common/src/main/resources/logback.xml
===================================================================
--- trunk/foray/foray-common/src/main/resources/logback.xml 2021-01-18 11:30:50 UTC (rev 11820)
+++ trunk/foray/foray-common/src/main/resources/logback.xml 2021-01-18 13:15:27 UTC (rev 11821)
@@ -1,5 +1,12 @@
<configuration>
+ <!--
+ See http://logback.qos.ch/manual/layouts.html for configuration documentation. Of note:
+ 1. [When configuring the handling of Throwable] "By default the full stack trace will be output."
+ This section of the documentation also indicates how this default behavior can be changed, to avoid the security
+ issues that may arise by dumping a stack trace.
+ -->
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
Modified: trunk/foray/foray-common/src/test/resources/logback-test.xml
===================================================================
--- trunk/foray/foray-common/src/test/resources/logback-test.xml 2021-01-18 11:30:50 UTC (rev 11820)
+++ trunk/foray/foray-common/src/test/resources/logback-test.xml 2021-01-18 13:15:27 UTC (rev 11821)
@@ -1,5 +1,12 @@
<configuration>
+ <!--
+ See http://logback.qos.ch/manual/layouts.html for configuration documentation. Of note:
+ 1. [When configuring the handling of Throwable] "By default the full stack trace will be output."
+ This section of the documentation also indicates how this default behavior can be changed, to avoid the security
+ issues that may arise by dumping a stack trace.
+ -->
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java 2021-01-18 11:30:50 UTC (rev 11820)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayAssignId.java 2021-01-18 13:15:27 UTC (rev 11821)
@@ -346,7 +346,7 @@
* that can be used to locate local DTDs.
*/
public static void main(final String[] args) {
- /* Checkstyle-GenericIllegalRegexp-Off. */
+ final Logger logger = LoggerFactory.getLogger(ForayAssignId.class);
final Options commandLineOptions = ForayAssignId.getCommandLineOptions();
final CommandLineParser commandLineParser = new DefaultParser();
CommandLine parsedCommandLine = null;
@@ -353,10 +353,11 @@
try {
parsedCommandLine = commandLineParser.parse(commandLineOptions, args);
} catch (final ParseException e) {
- System.out.println(e.getMessage());
+ logger.error(e.getMessage(), e);
final HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.printHelp("java -cp $FORAY_CLASSPATH " + ForayAssignId.class.getName(), commandLineOptions,
true);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_COMMAND_LINE_ERROR);
}
@@ -370,7 +371,8 @@
fis = new FileInputStream(input);
inputStream = new BufferedInputStream(fis);
} catch (final FileNotFoundException e) {
- System.err.println("File cannot be opened for input: " + input);
+ logger.error("File cannot be opened for input: " + input, e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_FILE_NOT_FOUND);
}
final InputSource inputSource = new InputSource(inputStream);
@@ -378,8 +380,9 @@
try {
final FileOutputStream fos = new FileOutputStream(output);
outputStream = new BufferedOutputStream(fos);
- } catch (final FileNotFoundException e1) {
- System.err.println("File cannot be opened for output: " + output);
+ } catch (final FileNotFoundException e) {
+ logger.error("File cannot be opened for output: " + output, e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_FILE_NOT_FOUND);
}
final ForayAssignId processor = new ForayAssignId(inputSource, outputStream,
@@ -387,23 +390,23 @@
try {
processor.start();
} catch (final IOException e) {
- System.out.println("Error parsing " + input + ": " + e.getClass().getName() + ": " + e.getMessage());
+ logger.error("Error parsing input.", e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_PARSING_ERROR);
} catch (final ParserConfigurationException e) {
- System.out.println("Error parsing input.");
- e.printStackTrace();
+ logger.error("Error parsing input.", e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_PARSING_ERROR);
} catch (final SAXException e) {
- System.out.println("Error parsing input.");
- e.printStackTrace();
+ logger.error("Error parsing input.", e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_PARSING_ERROR);
} catch (final TransformerException e) {
- System.out.println("Error writing output.");
- e.printStackTrace();
+ logger.error("Error writing output.", e);
+ /* CheckStyle: Allow System.exit() in main method. */
System.exit(ForayAssignId.STATUS_WRITING_ERROR);
}
- System.out.println("Input: " + input + " successfully modified,\n output in: " + output);
- /* Checkstyle-GenericIllegalRegexp-On. */
+ logger.info("Input: " + input + " successfully modified,\n output in: " + output);
}
}
Modified: trunk/foray/master/config/checkstyle/checkstyle-config.xml
===================================================================
--- trunk/foray/master/config/checkstyle/checkstyle-config.xml 2021-01-18 11:30:50 UTC (rev 11820)
+++ trunk/foray/master/config/checkstyle/checkstyle-config.xml 2021-01-18 13:15:27 UTC (rev 11821)
@@ -36,6 +36,12 @@
<module name="TreeWalker">
+ <module name="SuppressWithNearbyCommentFilter">
+ <property name="commentFormat" value="CheckStyle: Allow System.exit\(\) in main method."/>
+ <property name="idFormat" value="RestrictSystemExit"/>
+ <property name="influenceFormat" value="1"/>
+ </module>
+
<!-- Allow otherwise Illegal Types to be used in certain circumstances. -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle-IllegalType-Off"/>
@@ -44,8 +50,7 @@
</module>
<!-- Allow "main" methods to suppress the checks for System.exit(), etc. -->
- <!-- TODO: Write a custom checkstyle plugin that does the suppression in "main" automatically.
- -->
+ <!-- TODO: Write a custom checkstyle plugin that does the suppression in "main" automatically. -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="Checkstyle-GenericIllegalRegexp-Off"/>
<property name="onCommentFormat" value="Checkstyle-GenericIllegalRegexp-On"/>
@@ -262,6 +267,7 @@
</module>
<module name="RegexpSinglelineJava">
+ <property name="id" value="RestrictSystemExit"/>
<property name="ignoreComments" value="true"/>
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="System\.exit"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|