Skip to content

Commit 76074a2

Browse files
committed
fix static analysis hint provided by IntelliJ
1 parent d9936d1 commit 76074a2

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

src/main/java/org/openstreetmap/josm/plugins/scripting/graalvm/GraalVMFacadeFactory.java

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import java.util.logging.Level;
44
import java.util.logging.Logger;
55

6-
import static org.openstreetmap.josm.tools.I18n.tr;
7-
import static java.text.MessageFormat.format;
8-
96
public class GraalVMFacadeFactory {
107
static private final Logger logger = Logger.getLogger(GraalVMFacadeFactory.class.getName());
118

src/main/java/org/openstreetmap/josm/plugins/scripting/graalvm/RequireFunction.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,13 @@ private String loadModuleSourceFromJarEntry(@NotNull URI uri)
139139
private String loadModuleSource(@NotNull URI uri) throws IOException {
140140
Objects.requireNonNull(uri);
141141
final String scheme = uri.getScheme().toLowerCase();
142-
switch(scheme) {
143-
case "file":
144-
return loadModuleSourceFromFile(uri);
145-
case "jar":
146-
return loadModuleSourceFromJarEntry(uri);
147-
default:
148-
throw new IllegalArgumentException(format(
149-
"unsupported type of module URI, file URI required. Got ''{0}''", uri
150-
));
151-
}
142+
return switch (scheme) {
143+
case "file" -> loadModuleSourceFromFile(uri);
144+
case "jar" -> loadModuleSourceFromJarEntry(uri);
145+
default -> throw new IllegalArgumentException(format(
146+
"unsupported type of module URI, file URI required. Got ''{0}''", uri
147+
));
148+
};
152149
}
153150

154151
private String wrapModuleSource(@NotNull String moduleID,

src/main/java/org/openstreetmap/josm/plugins/scripting/graalvm/TypeResolveFunction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public Value apply(String className) {
2525
if (className == null || !className.startsWith(basePackageName)) {
2626
if (logger.isLoggable(Level.FINE)) {
2727
logger.log(Level.FINE, format(
28-
"Couldn't lookup a java class in the plugin jar. Class name is null or doesn't belong " +
29-
"to the plugin package. className='{0}'", className
28+
"Couldn''t lookup a java class in the plugin jar. Class name is null or doesn''t belong " +
29+
"to the plugin package. className=''{0}''", className
3030
));
3131
}
3232
return null;
@@ -37,7 +37,7 @@ public Value apply(String className) {
3737
} catch (ClassNotFoundException e) {
3838
if (logger.isLoggable(Level.FINE)) {
3939
logger.log(Level.FINE, format(
40-
"Couldn't lookup a java class in the plugin jar. className='{0}'", className
40+
"Couldn''t lookup a java class in the plugin jar. className=''{0}''", className
4141
), e);
4242
}
4343
return null;

src/main/java/org/openstreetmap/josm/plugins/scripting/model/RelativePath.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class RelativePath {
119119
MessageFormat.format("path must not be absolute, got ''{0}''", path)
120120
);
121121
}
122-
if (path.getNameCount() == 1 && "".equals(path.getName(0).toString())) {
122+
if (path.getNameCount() == 1 && path.getName(0).toString().isEmpty()) {
123123
return EMPTY;
124124
}
125125
final List<String> segments = new ArrayList<>();

src/main/java/org/openstreetmap/josm/plugins/scripting/model/ScriptEngineDescriptor.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public enum ScriptEngineType {
3838

3939
/**
4040
* Infers the script engine type from preference value. The value is
41-
* a string <code>type/engineId</code>. This methods decodes the
41+
* a string <code>type/engineId</code>. This method decodes the
4242
* component <code>type</code>. Replies <code>null</code> if no type
4343
* can be inferred.
4444
* <p>
@@ -138,9 +138,7 @@ static public ScriptEngineDescriptor buildFromPreferences(final String preferenc
138138
// don't lowercase. Lookup in ScriptEngineManager could be
139139
// case-sensitive
140140
engineId = engineId.trim();
141-
logger.log(Level.FINE, MessageFormat.format(
142-
"buildFromPreferences: engineId={1}",
143-
engineId));
141+
logger.log(Level.FINE, MessageFormat.format("buildFromPreferences: engineId={0}", engineId));
144142
if (!JSR223ScriptEngineProvider.getInstance()
145143
.hasEngineWithName(engineId)) {
146144
logger.warning(tr("preference with key ''{0}''"

0 commit comments

Comments
 (0)