Skip to content

Commit 2c630e7

Browse files
committed
checkstyle
1 parent 3f6db6d commit 2c630e7

37 files changed

+256
-144
lines changed

checkstyle.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,9 @@
171171
<property name="format" value="^[A-Z][a-zA-Z0-9_]+_$"/>
172172
</module>
173173
<module name="TypeName"/>
174-
<!--
175174
<module name="MemberName">
176175
<property name="format" value="^[a-z][a-zA-Z0-9_]+_$"/>
177176
</module>
178-
-->
179177
<module name="ConstantName">
180178
<property name="format" value="log|^[A-Z][A-Z0-9_]*$"/>
181179
</module>
@@ -229,7 +227,7 @@
229227
<!-- See http://checkstyle.sf.net/config_coding.html -->
230228
<module name="EmptyStatement"/>
231229
<module name="EqualsHashCode"/>
232-
<!-- module name="HiddenField"/ -->
230+
<module name="HiddenField"/>
233231
<module name="IllegalInstantiation"/>
234232
<module name="InnerAssignment"/>
235233
<module name="MissingSwitchDefault"/>

checkstyle_suppressions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<suppress checks="JavadocMethod" files=".*"/>
1212
<suppress checks="JavadocType" files=".*"/>
1313
<suppress checks="JavadocVariable" files=".*"/>
14+
<suppress checks="HiddenField" files=".*"/>
15+
<suppress checks="MemberName" files=".*"/>
1416

1517
<suppress checks="MissingSwitchDefault" files="HTMLEntitiesParser.java"/>
1618

@@ -23,6 +25,7 @@
2325

2426
<suppress checks="NonEmptyAtclauseDescription" files="FastHashMap.java"/>
2527

28+
<suppress checks="LineLength" files="DOMParserTest.java"/>
2629
<suppress checks="LineLength" files="DOMMessages.properties"/>
2730
<suppress checks="LineLength" files="XMLMessages.properties"/>
2831

src/main/java/org/htmlunit/cyberneko/HTMLScanner.java

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.htmlunit.cyberneko.xerces.util.URI;
3737
import org.htmlunit.cyberneko.xerces.util.XMLAttributesImpl;
3838
import org.htmlunit.cyberneko.xerces.xni.Augmentations;
39-
import org.htmlunit.cyberneko.xerces.xni.NamespaceContext;
4039
import org.htmlunit.cyberneko.xerces.xni.QName;
4140
import org.htmlunit.cyberneko.xerces.xni.XMLAttributes;
4241
import org.htmlunit.cyberneko.xerces.xni.XMLDocumentHandler;
@@ -143,32 +142,37 @@ public class HTMLScanner implements XMLDocumentSource, XMLLocator, HTMLComponent
143142
* Strip HTML comment delimiters ("&lt;!&minus;&minus;" and
144143
* "&minus;&minus;&gt;") from SCRIPT tag contents.
145144
*/
146-
public static final String SCRIPT_STRIP_COMMENT_DELIMS = "http://cyberneko.org/html/features/scanner/script/strip-comment-delims";
145+
public static final String SCRIPT_STRIP_COMMENT_DELIMS
146+
= "http://cyberneko.org/html/features/scanner/script/strip-comment-delims";
147147

148148
/**
149149
* Strip XHTML CDATA delimiters ("&lt;![CDATA[" and "]]&gt;") from SCRIPT tag
150150
* contents.
151151
*/
152-
public static final String SCRIPT_STRIP_CDATA_DELIMS = "http://cyberneko.org/html/features/scanner/script/strip-cdata-delims";
152+
public static final String SCRIPT_STRIP_CDATA_DELIMS
153+
= "http://cyberneko.org/html/features/scanner/script/strip-cdata-delims";
153154

154155
/**
155156
* Strip HTML comment delimiters ("&lt;!&minus;&minus;" and
156157
* "&minus;&minus;&gt;") from STYLE tag contents.
157158
*/
158-
public static final String STYLE_STRIP_COMMENT_DELIMS = "http://cyberneko.org/html/features/scanner/style/strip-comment-delims";
159+
public static final String STYLE_STRIP_COMMENT_DELIMS
160+
= "http://cyberneko.org/html/features/scanner/style/strip-comment-delims";
159161

160162
/**
161163
* Strip XHTML CDATA delimiters ("&lt;![CDATA[" and "]]&gt;") from STYLE tag
162164
* contents.
163165
*/
164-
public static final String STYLE_STRIP_CDATA_DELIMS = "http://cyberneko.org/html/features/scanner/style/strip-cdata-delims";
166+
public static final String STYLE_STRIP_CDATA_DELIMS
167+
= "http://cyberneko.org/html/features/scanner/style/strip-cdata-delims";
165168

166169
/**
167170
* Ignore specified charset found in the &lt;meta equiv='Content-Type'
168171
* content='text/html;charset=&hellip;'&gt; tag or in the &lt;?xml &hellip;
169172
* encoding='&hellip;'&gt; processing instruction.
170173
*/
171-
public static final String IGNORE_SPECIFIED_CHARSET = "http://cyberneko.org/html/features/scanner/ignore-specified-charset";
174+
public static final String IGNORE_SPECIFIED_CHARSET
175+
= "http://cyberneko.org/html/features/scanner/ignore-specified-charset";
172176

173177
/** Scan CDATA sections. */
174178
public static final String CDATA_SECTIONS = "http://cyberneko.org/html/features/scanner/cdata-sections";
@@ -186,13 +190,16 @@ public class HTMLScanner implements XMLDocumentSource, XMLLocator, HTMLComponent
186190
public static final String PARSE_NOSCRIPT_CONTENT = "http://cyberneko.org/html/features/parse-noscript-content";
187191

188192
/** Allows self closing &lt;iframe/&gt; tag. */
189-
public static final String ALLOW_SELFCLOSING_IFRAME = "http://cyberneko.org/html/features/scanner/allow-selfclosing-iframe";
193+
public static final String ALLOW_SELFCLOSING_IFRAME
194+
= "http://cyberneko.org/html/features/scanner/allow-selfclosing-iframe";
190195

191196
/** Allows self closing &lt;script/&gt; tag. */
192-
public static final String ALLOW_SELFCLOSING_SCRIPT = "http://cyberneko.org/html/features/scanner/allow-selfclosing-script";
197+
public static final String ALLOW_SELFCLOSING_SCRIPT
198+
= "http://cyberneko.org/html/features/scanner/allow-selfclosing-script";
193199

194200
/** Allows self closing tags e.g. &lt;div/&gt; (XHTML) */
195-
public static final String ALLOW_SELFCLOSING_TAGS = "http://cyberneko.org/html/features/scanner/allow-selfclosing-tags";
201+
public static final String ALLOW_SELFCLOSING_TAGS
202+
= "http://cyberneko.org/html/features/scanner/allow-selfclosing-tags";
196203

197204
/** Normalize attribute values. */
198205
public static final String NORMALIZE_ATTRIBUTES = "http://cyberneko.org/html/features/scanner/normalize-attrs";
@@ -1266,7 +1273,13 @@ protected String scanName(final boolean strict) throws IOException {
12661273
}
12671274
// we check for the regular space first because isWhitespace is no inlineable and hence expensive
12681275
// regular space should be the norm as well as newlines
1269-
else if (!strict && (c == ' ' || c == '\n' || c == '=' || c == '/' || c == '>' || Character.isWhitespace(c))) {
1276+
else if (!strict
1277+
&& (c == ' '
1278+
|| c == '\n'
1279+
|| c == '='
1280+
|| c == '/'
1281+
|| c == '>'
1282+
|| Character.isWhitespace(c))) {
12701283
fCurrentEntity.rewind();
12711284
break;
12721285
}
@@ -1353,7 +1366,8 @@ protected String scanTagName() throws IOException {
13531366
}
13541367

13551368
// Scans an entity reference.
1356-
protected int scanEntityRef(final XMLString str, final XMLString plainValue, final boolean content) throws IOException {
1369+
protected int scanEntityRef(final XMLString str, final XMLString plainValue, final boolean content)
1370+
throws IOException {
13571371
str.clearAndAppend('&');
13581372

13591373
// use readPreservingBufferContent inside this method to be sure we can rewind
@@ -1405,7 +1419,8 @@ protected int scanEntityRef(final XMLString str, final XMLString plainValue, fin
14051419
HTMLNamedEntitiesParser.State lastMatchingResult = null;
14061420

14071421
while (nextChar != -1) {
1408-
final HTMLNamedEntitiesParser.State intermediateResult = HTMLNamedEntitiesParser.get().lookup(nextChar, result);
1422+
final HTMLNamedEntitiesParser.State intermediateResult
1423+
= HTMLNamedEntitiesParser.get().lookup(nextChar, result);
14091424

14101425
if (intermediateResult.endNode_) {
14111426
result = intermediateResult;
@@ -2132,7 +2147,9 @@ else if (c == '/') {
21322147
return true;
21332148
}
21342149
}
2135-
else if (!fAllowSelfclosingTags_ && !fAllowSelfclosingIframe_ && "iframe".equals(enameLC)) {
2150+
else if (!fAllowSelfclosingTags_
2151+
&& !fAllowSelfclosingIframe_
2152+
&& "iframe".equals(enameLC)) {
21362153
scanUntilEndTag("iframe");
21372154
}
21382155
else if (!fParseNoScriptContent_ && "noscript".equals(enameLC)) {
@@ -2169,10 +2186,10 @@ else if (ename != null) {
21692186
if (DEBUG_CALLBACKS) {
21702187
System.out.println("startDocument()");
21712188
}
2172-
final XMLLocator locator = HTMLScanner.this;
2173-
final String encoding = fIANAEncoding;
2174-
final NamespaceContext nscontext = new NamespaceSupport();
2175-
fDocumentHandler.startDocument(locator, encoding, nscontext, locationAugs(fCurrentEntity));
2189+
fDocumentHandler.startDocument(HTMLScanner.this,
2190+
fIANAEncoding,
2191+
new NamespaceSupport(),
2192+
locationAugs(fCurrentEntity));
21762193
}
21772194
if (fInsertDoctype_ && fDocumentHandler != null) {
21782195
String root = htmlConfiguration_.getHtmlElements().getElement(HTMLElements.HTML).name;
@@ -2932,7 +2949,8 @@ protected boolean scanAttribute(final XMLAttributesImpl attributes, final boolea
29322949
}
29332950
}
29342951

2935-
// https://html.spec.whatwg.org/multipage/parsing.html#parse-error-unexpected-character-in-attribute-name
2952+
// https://html.spec.whatwg.org/multipage/parsing.html
2953+
// #parse-error-unexpected-character-in-attribute-name
29362954
if (c == '<') {
29372955
if (fReportErrors_) {
29382956
fErrorReporter.reportError("HTML1016", null);
@@ -3042,7 +3060,9 @@ protected boolean scanAttribute(final XMLAttributesImpl attributes, final boolea
30423060
scanAttributeUnquotedValue(fCurrentEntity, attribValue, nonNormalizedAttribValue);
30433061

30443062
qName_.setValues(null, aname, aname, null);
3045-
attributes.addAttribute(qName_, "CDATA", attribValue.toString(), nonNormalizedAttribValue.toString(), true);
3063+
attributes.addAttribute(qName_, "CDATA",
3064+
attribValue.toString(),
3065+
nonNormalizedAttribValue.toString(), true);
30463066
}
30473067
else {
30483068
scanAttributeUnquotedValue(fCurrentEntity, attribValue, null);

src/main/java/org/htmlunit/cyberneko/HTMLUnicodeEntitiesParser.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,30 @@ public HTMLUnicodeEntitiesParser() {
5656
}
5757

5858
public void setMatchFromCode() {
59-
// If the number is 0x00, then this is a null-character-reference parse error. Set the character reference code to 0xFFFD.
60-
// If the number is greater than 0x10FFFF, then this is a character-reference-outside-unicode-range parse error. Set the character reference code to 0xFFFD.
59+
// If the number is 0x00, then this is a null-character-reference parse error.
60+
// Set the character reference code to 0xFFFD.
61+
// If the number is greater than 0x10FFFF, then this is
62+
// a character-reference-outside-unicode-range parse error. Set the character reference code to 0xFFFD.
6163
if ((0x00 == code_) || (code_ > 0x10FFFF)) {
6264
match_ = "\uFFFD";
6365
matchLength_ = consumedCount_;
6466
return;
6567
}
6668

67-
// If the number is a surrogate, then this is a surrogate-character-reference parse error. Set the character reference code to 0xFFFD
69+
// If the number is a surrogate, then this is
70+
// a surrogate-character-reference parse error. Set the character reference code to 0xFFFD
6871
if (Character.isSurrogate((char) code_)) {
6972
match_ = "\uFFFD";
7073
return;
7174
}
7275

7376
// If the number is a noncharacter, then this is a noncharacter-character-reference parse error.
7477

75-
// If the number is 0x0D, or a control that's not ASCII whitespace, then this is a control-character-reference parse error.
78+
// If the number is 0x0D, or a control that's not ASCII whitespace,
79+
// then this is a control-character-reference parse error.
7680

77-
// If the number is one of the numbers in the first column of the following table, then find the row with that number in the first column,
81+
// If the number is one of the numbers in the first column of the following table,
82+
// then find the row with that number in the first column,
7883
// and set the character reference code to the number in the second column of that row.
7984
switch (code_) {
8085
case 0x80:

src/main/java/org/htmlunit/cyberneko/filters/DefaultFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public XMLDocumentSource getDocumentSource() {
7474

7575
/** Start document. */
7676
@Override
77-
public void startDocument(final XMLLocator locator, final String encoding, final NamespaceContext nscontext, final Augmentations augs)
77+
public void startDocument(final XMLLocator locator, final String encoding, final NamespaceContext nscontext,
78+
final Augmentations augs)
7879
throws XNIException {
7980
if (documentHandler_ != null) {
8081
documentHandler_.startDocument(locator, encoding, nscontext, augs);

src/main/java/org/htmlunit/cyberneko/filters/NamespaceBinder.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,17 @@ public void reset(final XMLComponentManager manager)
210210

211211
/** Start document. */
212212
@Override
213-
public void startDocument(final XMLLocator locator, final String encoding, final NamespaceContext nscontext, final Augmentations augs)
214-
throws XNIException {
215-
213+
public void startDocument(final XMLLocator locator, final String encoding,
214+
final NamespaceContext nscontext, final Augmentations augs) throws XNIException {
216215
// perform default handling
217216
// NOTE: using own namespace context
218217
super.startDocument(locator, encoding, namespaceContext_, augs);
219218
}
220219

221220
/** Start element. */
222221
@Override
223-
public void startElement(final QName element, final XMLAttributes attrs, final Augmentations augs) throws XNIException {
224-
222+
public void startElement(final QName element, final XMLAttributes attrs,
223+
final Augmentations augs) throws XNIException {
225224
// bind namespaces, if needed
226225
if (namespaces_) {
227226
namespaceContext_.pushContext();
@@ -234,8 +233,8 @@ public void startElement(final QName element, final XMLAttributes attrs, final A
234233

235234
/** Empty element. */
236235
@Override
237-
public void emptyElement(final QName element, final XMLAttributes attrs, final Augmentations augs) throws XNIException {
238-
236+
public void emptyElement(final QName element, final XMLAttributes attrs,
237+
final Augmentations augs) throws XNIException {
239238
// bind namespaces, if needed
240239
if (namespaces_) {
241240
namespaceContext_.pushContext();

src/main/java/org/htmlunit/cyberneko/html/dom/HTMLDocumentImpl.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ public class HTMLDocumentImpl extends DocumentImpl implements HTMLDocument {
128128
*
129129
* @see #createElement
130130
*/
131-
private static final FastHashMap<String, ElementTypesHTMLHolder> elementTypesHTMLLower_ = new FastHashMap<>(11, 0.5f);
132-
private static final FastHashMap<String, ElementTypesHTMLHolder> elementTypesHTMLUpper_ = new FastHashMap<>(11, 0.5f);
131+
private static final FastHashMap<String, ElementTypesHTMLHolder> elementTypesHTMLLower_
132+
= new FastHashMap<>(11, 0.5f);
133+
private static final FastHashMap<String, ElementTypesHTMLHolder> elementTypesHTMLUpper_
134+
= new FastHashMap<>(11, 0.5f);
133135

134136
/**
135137
* Signature used to locate constructor of HTML element classes. This
@@ -225,7 +227,9 @@ public class HTMLDocumentImpl extends DocumentImpl implements HTMLDocument {
225227
elementTypesHTMLLower_.put(lKey, holder);
226228
}
227229
catch (NoSuchMethodException | SecurityException ex) {
228-
throw new IllegalStateException("HTM15 Tag '" + key + "' associated with an Element class that failed to construct.\n" + key, ex);
230+
throw new IllegalStateException(
231+
"HTM15 Tag '" + key
232+
+ "' associated with an Element class that failed to construct.\n" + key, ex);
229233
}
230234
});
231235
}
@@ -494,7 +498,8 @@ public final NodeList getElementsByTagNameNS(final String namespaceURI, final St
494498
* name contains an invalid character.
495499
*/
496500
@Override
497-
public Element createElementNS(final String namespaceURI, final String qualifiedName, final String localpart) throws DOMException {
501+
public Element createElementNS(final String namespaceURI, final String qualifiedName,
502+
final String localpart) throws DOMException {
498503
return createElementNS(namespaceURI, qualifiedName);
499504
}
500505

@@ -537,7 +542,8 @@ public Element createElement(final String tagName) throws DOMException {
537542
return htmlHolder.ctr_.newInstance(this, tagName);
538543
}
539544
catch (final Exception e) {
540-
throw new IllegalStateException("HTM15 Tag '" + tagName + "' associated with an Element class that failed to construct.", e);
545+
throw new IllegalStateException(
546+
"HTM15 Tag '" + tagName + "' associated with an Element class that failed to construct.", e);
541547
}
542548
}
543549
return new HTMLElementImpl(this, tagName);

src/main/java/org/htmlunit/cyberneko/parsers/DOMFragmentParser.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ public void setProperty(final String propertyId, final Object value)
280280

281281
// Start document.
282282
@Override
283-
public void startDocument(final XMLLocator locator, final String encoding, final NamespaceContext nscontext, final Augmentations augs) throws XNIException {
283+
public void startDocument(final XMLLocator locator, final String encoding,
284+
final NamespaceContext nscontext, final Augmentations augs) throws XNIException {
284285
inCDATASection_ = false;
285286
}
286287

@@ -292,7 +293,8 @@ public void xmlDecl(final String version, final String encoding, final String st
292293

293294
// Document type declaration.
294295
@Override
295-
public void doctypeDecl(final String root, final String pubid, final String sysid, final Augmentations augs) throws XNIException {
296+
public void doctypeDecl(final String root, final String pubid, final String sysid,
297+
final Augmentations augs) throws XNIException {
296298
}
297299

298300
// Processing instruction.
@@ -318,7 +320,8 @@ public void comment(final XMLString text, final Augmentations augs)
318320

319321
// Start element.
320322
@Override
321-
public void startElement(final QName element, final XMLAttributes attrs, final Augmentations augs) throws XNIException {
323+
public void startElement(final QName element, final XMLAttributes attrs,
324+
final Augmentations augs) throws XNIException {
322325
final Element elementNode = document_.createElement(element.getRawname());
323326

324327
if (attrs != null) {
@@ -338,7 +341,8 @@ public void startElement(final QName element, final XMLAttributes attrs, final A
338341

339342
// Empty element.
340343
@Override
341-
public void emptyElement(final QName element, final XMLAttributes attrs, final Augmentations augs) throws XNIException {
344+
public void emptyElement(final QName element, final XMLAttributes attrs,
345+
final Augmentations augs) throws XNIException {
342346
startElement(element, attrs, augs);
343347
endElement(element, augs);
344348
}

0 commit comments

Comments
 (0)