Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Fix more SpotBugs issues

AuthorDaveJarvis <email>
Date2023-05-06 17:54:40 GMT-0700
Commit44ad1898bbaf829c33f225e510c2181fcb66113e
Parentbc4ac12
src/main/java/com/keenwrite/Bootstrap.java
private static final Properties sP = new Properties();
- public static String APP_TITLE;
- public static String APP_VERSION;
- public static String CONTAINER_VERSION;
+ public static final String APP_TITLE;
+ public static final String APP_VERSION;
+ public static final String CONTAINER_VERSION;
public static final String APP_TITLE_ABBR = "kwr";
static {
+ // There's no way to know what container version is compatible. This
+ // value will cause a failure when downloading the container,
+ String containerVersion = "1.0.0";
+ String appVersion = "0.0.0";
+ String appTitle = "KeenWrite";
+
try( final var in = openResource( PATH_BOOTSTRAP ) ) {
sP.load( in );
- APP_TITLE = sP.getProperty( "application.title" );
- CONTAINER_VERSION = sP.getProperty( "container.version" );
+ appTitle = sP.getProperty( "application.title" );
+ containerVersion = sP.getProperty( "container.version" );
} catch( final Exception ex ) {
- APP_TITLE = "KeenWrite";
-
- // Bootstrap properties cannot be found, use a default value.
final var fmt = "Unable to load %s resource, applying defaults.%n";
clue( ex, fmt, PATH_BOOTSTRAP );
-
- // There's no way to know what container version is compatible. This
- // value will cause a failure when downloading the container,
- CONTAINER_VERSION = "1.0.0";
}
+ CONTAINER_VERSION = containerVersion;
+ APP_TITLE = appTitle;
APP_TITLE_LOWERCASE = APP_TITLE.toLowerCase();
try {
- APP_VERSION = Launcher.getVersion();
+ appVersion = Launcher.getVersion();
} catch( final Exception ex ) {
- APP_VERSION = "0.0.0";
-
- // Application version cannot be found, use a default value.
final var fmt = "Unable to determine application version.";
clue( ex, fmt );
}
+
+ APP_VERSION = appVersion;
// The plug-in that requests the version from the repository tag will
USER_CACHE_DIR = USER_DATA_DIR.resolve( "cache" ).toFile();
- if( !USER_CACHE_DIR.exists() ) {
- final var ignored = USER_CACHE_DIR.mkdirs();
+ if( !USER_CACHE_DIR.exists() && !USER_CACHE_DIR.mkdirs() ) {
+ clue( "Main.status.error.bootstrap.cache", USER_CACHE_DIR );
}
}
src/main/java/com/keenwrite/dom/DocumentParser.java
private static final XPath sXpath = XPathFactory.newInstance().newXPath();
- public static DOMImplementation sDomImplementation;
+ public static final DOMImplementation sDomImplementation;
static {
sDocumentFactory = DocumentBuilderFactory.newInstance();
sDocumentFactory.setValidating( false );
sDocumentFactory.setAttribute( LOAD_EXTERNAL_DTD, false );
sDocumentFactory.setNamespaceAware( true );
sDocumentFactory.setIgnoringComments( true );
sDocumentFactory.setIgnoringElementContentWhitespace( true );
+
+ DOMImplementation domImplementation;
try {
sDocumentBuilder = sDocumentFactory.newDocumentBuilder();
- sDomImplementation = sDocumentBuilder.getDOMImplementation();
+ domImplementation = sDocumentBuilder.getDOMImplementation();
sTransformer = TransformerFactory.newInstance().newTransformer();
} catch( final Exception ex ) {
clue( ex );
+ domImplementation = sDocumentBuilder.getDOMImplementation();
}
+
+ sDomImplementation = domImplementation;
}
src/main/java/com/keenwrite/preview/FlyingSaucerPanel.java
case HTTP -> HyperlinkOpenEvent.fire( uri );
case FILE -> FileOpenEvent.fire( uri );
+ default -> { }
}
} catch( final Exception ex ) {
src/main/java/com/keenwrite/ui/logging/LogView.java
switch( t.getCode() ) {
case ENTER, ESCAPE -> buttonOk.fire();
+ default -> { }
}
} );
src/main/resources/com/keenwrite/messages.properties
Main.status.error.bootstrap.eval=Note: Bootstrap variable of ''{0}'' not found
+Main.status.error.bootstrap.cache=Could not create cache directory ''{0}''
Main.status.error.parse=Evaluation error: {0}
Delta28 lines added, 20 lines removed, 8-line increase