Skip to content

Commit d50d0a9

Browse files
committed
fix some pmd warnings
1 parent af325b3 commit d50d0a9

File tree

6 files changed

+9
-17
lines changed

6 files changed

+9
-17
lines changed

src/main/java/org/htmlunit/WebClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,7 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot
25532553
scriptEngine_ = new JavaScriptEngine(this);
25542554
jobManagers_ = Collections.synchronizedList(new ArrayList<>());
25552555
loadQueue_ = new ArrayList<>();
2556+
css3ParserPool_ = new CSS3ParserPool();
25562557
}
25572558

25582559
private static class LoadJob {
@@ -2948,7 +2949,7 @@ static class CSS3ParserPool {
29482949
* Our pool. We only hold data when it is available. In addition, synchronization against
29492950
* this deque is cheap.
29502951
*/
2951-
private ConcurrentLinkedDeque<PooledCSS3Parser> parsers_ = new ConcurrentLinkedDeque<>();
2952+
private final ConcurrentLinkedDeque<PooledCSS3Parser> parsers_ = new ConcurrentLinkedDeque<>();
29522953

29532954
/**
29542955
* Fetch a new or recycled CSS3parser. Make sure you use the try-with-resource concept

src/main/java/org/htmlunit/html/DomNodeIterator.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,7 @@ private DomNode traverse(final boolean next) {
143143
}
144144
else {
145145
if (beforeNode) {
146-
final DomNode left = getSibling(node, true);
147-
if (left == null) {
148-
final Node parent = node.getParentNode();
149-
if (parent == null) {
150-
node = null;
151-
}
152-
}
153-
154-
DomNode follow = left;
146+
DomNode follow = getSibling(node, true);
155147
if (follow != null) {
156148
while (follow.hasChildNodes()) {
157149
final DomNode toFollow = getChild(follow, false);

src/main/java/org/htmlunit/html/HtmlPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,7 @@ private void readObject(final ObjectInputStream in) throws IOException, ClassNot
28742874
}
28752875

28762876
private static final class MappedElementIndexEntry implements Serializable {
2877-
private ArrayList<DomElement> elements_;
2877+
private final ArrayList<DomElement> elements_;
28782878
private boolean sorted_;
28792879

28802880
MappedElementIndexEntry() {

src/main/java/org/htmlunit/javascript/host/Window.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public class Window extends EventTarget implements WindowOrWorkerGlobalScope, Au
203203
private Map<Class<? extends Scriptable>, Scriptable> prototypes_ = new HashMap<>();
204204
private Object controllers_;
205205
private Object opener_;
206-
private Object top_ = NOT_FOUND; // top can be set from JS to any value!
206+
private final Object top_ = NOT_FOUND; // top can be set from JS to any value!
207207
private Crypto crypto_;
208208
private Scriptable performance_;
209209

src/main/java/org/htmlunit/javascript/host/css/CSSStyleDeclaration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,8 +1957,6 @@ private void setStyleLengthAttribute(final String name, final Object value, fina
19571957
return;
19581958
}
19591959

1960-
final double doubleValue;
1961-
String unit = "px";
19621960
if (value instanceof Number) {
19631961
return;
19641962
}
@@ -1985,7 +1983,8 @@ private void setStyleLengthAttribute(final String name, final Object value, fina
19851983
return;
19861984
}
19871985

1988-
if (percent && valueString.endsWith("%")) {
1986+
String unit = "px";
1987+
if (percent && valueString.endsWith("%")) {
19891988
unit = valueString.substring(valueString.length() - 1);
19901989
valueString = valueString.substring(0, valueString.length() - 1);
19911990
}
@@ -2017,7 +2016,7 @@ else if (valueString.endsWith("rem")
20172016
// we have a unit but surrounding blanks
20182017
return;
20192018
}
2020-
doubleValue = JavaScriptEngine.toNumber(valueString);
2019+
final double doubleValue = JavaScriptEngine.toNumber(valueString);
20212020

20222021
try {
20232022
if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) {

src/main/java/org/htmlunit/javascript/host/intl/DateTimeFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static final class DateTimeFormatHelper {
283283

284284
private final DateTimeFormatter formatter_;
285285
private Chronology chronology_;
286-
private String locale_;
286+
private final String locale_;
287287

288288
DateTimeFormatHelper(final String locale, final BrowserVersion browserVersion, final String pattern) {
289289
locale_ = locale;

0 commit comments

Comments
 (0)