Skip to content

Commit 5ee732e

Browse files
committed
checkstyle / jdoc
1 parent 676709a commit 5ee732e

File tree

10 files changed

+88
-69
lines changed

10 files changed

+88
-69
lines changed

checkstyle.xml

+21-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<module name="LineLength">
3535
<property name="max" value="120"/>
36+
<property name="ignorePattern" value="^(package|import| *\* *[^ ]+).*"/>
3637
</module>
3738

3839
<!-- Prevent two spaces after @xxxx -->
@@ -99,15 +100,11 @@
99100
<property name="message" value="Use static import for BrowserVersionFeatures"/>
100101
</module>
101102

102-
<!--
103-
at the moment there is a problem with disabling this check for some files
104-
without disabling all RegexpMultiline checks; for this reason this is not active
105103
<module name="RegexpMultiline">
106104
<property name="id" value="sysout"/>
107105
<property name="format" value="System\s*\.\s*(out)|(err)\s*\.\s*print(ln)?\("/>
108106
<property name="message" value="System.out.print/ln found"/>
109107
</module>
110-
-->
111108

112109
<module name="TreeWalker">
113110

@@ -123,12 +120,12 @@
123120
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
124121
</module>
125122

126-
<module name="ConstantName">
127-
<property name="format" value="log|^[a-zA-Z][a-zA-Z0-9_]*$"/>
128-
</module>
129-
130123
<!-- Checks for Javadoc comments. -->
131124
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
125+
<module name="MissingJavadocMethod"/>
126+
<module name="MissingJavadocPackage"/>
127+
<module name="MissingJavadocType"/>
128+
132129
<module name="JavadocMethod">
133130
<property name="accessModifiers" value="public, protected"/>
134131
</module>
@@ -145,9 +142,22 @@
145142
<property name="checkEmptyJavadoc" value="false"/>
146143
<property name="checkHtml" value="true"/>
147144
</module>
145+
<module name="InvalidJavadocPosition"/>
146+
<module name="JavadocContentLocation"/>
147+
<module name="JavadocLeadingAsteriskAlign" />
148+
<!--module name="JavadocMissingLeadingAsterisk"/-->
149+
<module name="JavadocMissingWhitespaceAfterAsterisk"/>
150+
<!--module name="JavadocParagraph"/-->
151+
<module name="JavadocTagContinuationIndentation"/>
152+
<module name="NonEmptyAtclauseDescription"/>
153+
<!--module name="RequireEmptyLineBeforeBlockTagGroup"/-->
154+
<module name="SingleLineJavadoc"/>
148155

149156
<!-- Checks for Naming Conventions. -->
150157
<!-- See http://checkstyle.sf.net/config_naming.html -->
158+
<module name="CatchParameterName">
159+
<property name="format" value="^(ex?|ignored|expected)$"/>
160+
</module>
151161
<module name="LocalFinalVariableName"/>
152162
<module name="LocalVariableName"/>
153163
<module name="MethodName">
@@ -162,6 +172,9 @@
162172
<module name="MemberName">
163173
<property name="format" value="^[a-z][a-zA-Z0-9_]+_$"/>
164174
</module>
175+
<module name="ConstantName">
176+
<property name="format" value="log|^[A-Z][A-Z0-9_]*$"/>
177+
</module>
165178

166179
<!-- Checks for imports -->
167180
<!-- See http://checkstyle.sf.net/config_imports.html -->

checkstyle_suppressions.xml

+4
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212

1313
<suppress checks="." files=".*[\\/]target[\\/]generated-sources[\\/]javacc"/>
1414
<suppress checks="." files="CssCharStream.java"/>
15+
<suppress checks="RegexpMultiline" files="HandlerBase.java"/>
16+
<suppress checks="RegexpMultiline" files="LocatorTest.java"/>
17+
<suppress checks="RegexpMultiline" files="SerializableTest.java"/>
18+
1519
</suppressions>

src/main/java/org/htmlunit/cssparser/dom/DOMExceptionImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class DOMExceptionImpl extends DOMException {
5858
/** INSERT_BEFORE_IMPORT = 16. */
5959
public static final int INSERT_BEFORE_IMPORT = 16;
6060

61-
static final String[] messages = {
61+
static final String[] MESSAGES_ = {
6262
"Syntax error",
6363
"Index out of bounds error",
6464
"This style sheet is read only",
@@ -103,6 +103,6 @@ public DOMExceptionImpl(final int code, final int messageKey) {
103103
* @param info additional info
104104
*/
105105
public DOMExceptionImpl(final int code, final int messageKey, final String info) {
106-
super((short) code, messages[messageKey] + " (" + info + ")");
106+
super((short) code, MESSAGES_[messageKey] + " (" + info + ")");
107107
}
108108
}

src/main/java/org/htmlunit/cssparser/parser/AbstractCSSParser.java

+45-45
Original file line numberDiff line numberDiff line change
@@ -39,55 +39,55 @@ public abstract class AbstractCSSParser {
3939
private CSSErrorHandler errorHandler_;
4040
private InputSource source_;
4141

42-
private static final HashMap<String, String> parserMessages_ = new HashMap<>();
42+
private static final HashMap<String, String> PARSER_MESSAGES_ = new HashMap<>();
4343

4444
static {
45-
parserMessages_.put("invalidExpectingOne", "Invalid token \"{0}\". Was expecting: {1}.");
46-
parserMessages_.put("invalidExpectingMore", "Invalid token \"{0}\". Was expecting one of: {1}.");
47-
parserMessages_.put("invalidColor", "Invalid color \"{0}\".");
48-
parserMessages_.put("invalidStyleSheet", "Error in style sheet.");
49-
parserMessages_.put("invalidRule", "Error in rule.");
50-
parserMessages_.put("invalidUnknownRule", "Error in unknown at-rule.");
51-
parserMessages_.put("invalidCharsetRule", "Error in @charset rule.");
52-
parserMessages_.put("misplacedCharsetRule", "The @charset must be the first element in the style sheet.");
53-
parserMessages_.put("invalidImportRule", "Error in @import rule.");
54-
parserMessages_.put("invalidImportRuleIgnored", "@import rule must occur before all other rules.");
55-
parserMessages_.put("invalidImportRuleIgnored2",
45+
PARSER_MESSAGES_.put("invalidExpectingOne", "Invalid token \"{0}\". Was expecting: {1}.");
46+
PARSER_MESSAGES_.put("invalidExpectingMore", "Invalid token \"{0}\". Was expecting one of: {1}.");
47+
PARSER_MESSAGES_.put("invalidColor", "Invalid color \"{0}\".");
48+
PARSER_MESSAGES_.put("invalidStyleSheet", "Error in style sheet.");
49+
PARSER_MESSAGES_.put("invalidRule", "Error in rule.");
50+
PARSER_MESSAGES_.put("invalidUnknownRule", "Error in unknown at-rule.");
51+
PARSER_MESSAGES_.put("invalidCharsetRule", "Error in @charset rule.");
52+
PARSER_MESSAGES_.put("misplacedCharsetRule", "The @charset must be the first element in the style sheet.");
53+
PARSER_MESSAGES_.put("invalidImportRule", "Error in @import rule.");
54+
PARSER_MESSAGES_.put("invalidImportRuleIgnored", "@import rule must occur before all other rules.");
55+
PARSER_MESSAGES_.put("invalidImportRuleIgnored2",
5656
"@import rule must occur before all other rules, except the @charset rule.");
57-
parserMessages_.put("invalidPageRule", "Error in @page rule.");
58-
parserMessages_.put("invalidFontFaceRule", "Error in @font-face rule.");
59-
parserMessages_.put("invalidMediaList", "Error in media list.");
60-
parserMessages_.put("invalidMediaRule", "Error in @media rule.");
61-
parserMessages_.put("invalidStyleRule", "Error in style rule.");
62-
parserMessages_.put("invalidStyleDeclaration", "Error in style declaration.");
63-
parserMessages_.put("invalidDeclaration", "Error in declaration.");
64-
parserMessages_.put("invalidDeclarationInvalidChar", "Error in declaration; invalid character \"{0}\" found.");
65-
parserMessages_.put("invalidDeclarationStarHack",
57+
PARSER_MESSAGES_.put("invalidPageRule", "Error in @page rule.");
58+
PARSER_MESSAGES_.put("invalidFontFaceRule", "Error in @font-face rule.");
59+
PARSER_MESSAGES_.put("invalidMediaList", "Error in media list.");
60+
PARSER_MESSAGES_.put("invalidMediaRule", "Error in @media rule.");
61+
PARSER_MESSAGES_.put("invalidStyleRule", "Error in style rule.");
62+
PARSER_MESSAGES_.put("invalidStyleDeclaration", "Error in style declaration.");
63+
PARSER_MESSAGES_.put("invalidDeclaration", "Error in declaration.");
64+
PARSER_MESSAGES_.put("invalidDeclarationInvalidChar", "Error in declaration; invalid character \"{0}\" found.");
65+
PARSER_MESSAGES_.put("invalidDeclarationStarHack",
6666
"Error in declaration. ''*'' is not allowed as first char of a property.");
67-
parserMessages_.put("invalidSelectorList", "Error in selector list.");
68-
parserMessages_.put("invalidSelector", "Error in selector.");
69-
parserMessages_.put("invalidSimpleSelector", "Error in simple selector.");
70-
parserMessages_.put("invalidClassSelector", "Error in class selector.");
71-
parserMessages_.put("invalidElementName", "Error in element name.");
72-
parserMessages_.put("invalidAttrib", "Error in attribute selector.");
73-
parserMessages_.put("invalidPseudo", "Error in pseudo class or element.");
74-
parserMessages_.put("duplicatePseudo", "Duplicate pseudo class \":{0}\" or pseudo class \":{0}\" not at end.");
75-
parserMessages_.put("invalidHash", "Error in hash.");
76-
parserMessages_.put("invalidExpr", "Error in expression.");
77-
parserMessages_.put("invalidExprColon", "Error in expression; '':'' found after identifier \"{0}\".");
78-
parserMessages_.put("invalidPrio", "Error in priority.");
79-
80-
parserMessages_.put("invalidPagePseudoClass",
67+
PARSER_MESSAGES_.put("invalidSelectorList", "Error in selector list.");
68+
PARSER_MESSAGES_.put("invalidSelector", "Error in selector.");
69+
PARSER_MESSAGES_.put("invalidSimpleSelector", "Error in simple selector.");
70+
PARSER_MESSAGES_.put("invalidClassSelector", "Error in class selector.");
71+
PARSER_MESSAGES_.put("invalidElementName", "Error in element name.");
72+
PARSER_MESSAGES_.put("invalidAttrib", "Error in attribute selector.");
73+
PARSER_MESSAGES_.put("invalidPseudo", "Error in pseudo class or element.");
74+
PARSER_MESSAGES_.put("duplicatePseudo", "Duplicate pseudo class \":{0}\" or pseudo class \":{0}\" not at end.");
75+
PARSER_MESSAGES_.put("invalidHash", "Error in hash.");
76+
PARSER_MESSAGES_.put("invalidExpr", "Error in expression.");
77+
PARSER_MESSAGES_.put("invalidExprColon", "Error in expression; '':'' found after identifier \"{0}\".");
78+
PARSER_MESSAGES_.put("invalidPrio", "Error in priority.");
79+
80+
PARSER_MESSAGES_.put("invalidPagePseudoClass",
8181
"Invalid page pseudo class \"{0}\"; valid values are \"blank\", \"first\", \"left\", and \"right\".");
8282

83-
parserMessages_.put("invalidCaseInSensitivelyIdentifier",
83+
PARSER_MESSAGES_.put("invalidCaseInSensitivelyIdentifier",
8484
"Invalid case-insensitively identifier \"{0}\" found; valid values are \"i\", and \"s\".");
8585

86-
parserMessages_.put("ignoringRule", "Ignoring the whole rule.");
87-
parserMessages_.put("ignoringFollowingDeclarations", "Ignoring the following declarations in this rule.");
86+
PARSER_MESSAGES_.put("ignoringRule", "Ignoring the whole rule.");
87+
PARSER_MESSAGES_.put("ignoringFollowingDeclarations", "Ignoring the following declarations in this rule.");
8888

89-
parserMessages_.put("tokenMgrError", "Lexical error.");
90-
parserMessages_.put("domException", "DOM exception: ''{0}''");
89+
PARSER_MESSAGES_.put("tokenMgrError", "Lexical error.");
90+
PARSER_MESSAGES_.put("domException", "DOM exception: ''{0}''");
9191
}
9292

9393
private static final String NUM_CHARS = "0123456789.";
@@ -169,7 +169,7 @@ protected InputSource getInputSource() {
169169
* @return the parser message
170170
*/
171171
protected String getParserMessage(final String key) {
172-
final String msg = parserMessages_.get(key);
172+
final String msg = PARSER_MESSAGES_.get(key);
173173
if (msg == null) {
174174
return "[[" + key + "]]";
175175
}
@@ -555,10 +555,10 @@ private static CharStream getCharStream(final InputSource source) throws IOExcep
555555

556556
/**
557557
* @return a string about which CSS language is supported by this
558-
* parser. For CSS Level 1, it returns "http://www.w3.org/TR/REC-CSS1", for
559-
* CSS Level 2, it returns "http://www.w3.org/TR/REC-CSS2". Note that a
560-
* "CSSx" parser can return lexical unit other than those allowed by CSS
561-
* Level x but this usage is not recommended.
558+
* parser. For CSS Level 1, it returns "http://www.w3.org/TR/REC-CSS1", for
559+
* CSS Level 2, it returns "http://www.w3.org/TR/REC-CSS2". Note that a
560+
* "CSSx" parser can return lexical unit other than those allowed by CSS
561+
* Level x but this usage is not recommended.
562562
*/
563563
public abstract String getParserVersion();
564564

src/main/java/org/htmlunit/cssparser/parser/CSSErrorHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
package org.htmlunit.cssparser.parser;
1616

1717
/**
18-
* Interface for CSS parser error handlers.
19-
* @author Ronald Brill
20-
*/
18+
* Interface for CSS parser error handlers.
19+
* @author Ronald Brill
20+
*/
2121
public interface CSSErrorHandler {
2222

2323
/**

src/main/java/org/htmlunit/cssparser/parser/CSSParseException.java

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public CSSParseException(final String message, final Locator locator) {
4141
}
4242

4343
/**
44-
4544
* Wrap an existing exception in a CSSParseException.
4645
*
4746
* <p>This constructor is especially useful when an application is

src/main/java/org/htmlunit/cssparser/parser/DocumentHandler.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public interface DocumentHandler {
9595
* @param characterEncoding the character encoding
9696
* @param locator the locator
9797
* @throws CSSException Any CSS exception, possibly wrapping another
98-
* exception.
98+
* exception.
9999
*/
100100
void charset(String characterEncoding, Locator locator) throws CSSException;
101101

@@ -105,10 +105,10 @@ public interface DocumentHandler {
105105
* @param uri The URI of the imported style sheet.
106106
* @param media The intended destination media for style information.
107107
* @param defaultNamespaceURI The default namespace URI for the imported
108-
* style sheet.
108+
* style sheet.
109109
* @param locator the locator
110110
* @exception CSSException Any CSS exception, possibly wrapping another
111-
* exception.
111+
* exception.
112112
*/
113113
void importStyle(String uri, MediaQueryList media,
114114
String defaultNamespaceURI, Locator locator) throws CSSException;
@@ -120,7 +120,7 @@ void importStyle(String uri, MediaQueryList media,
120120
* @param atRule The complete ignored at-rule.
121121
* @param locator the locator
122122
* @exception CSSException Any CSS exception, possibly wrapping another
123-
* exception.
123+
* exception.
124124
*/
125125
void ignorableAtRule(String atRule, Locator locator) throws CSSException;
126126

@@ -133,7 +133,7 @@ void importStyle(String uri, MediaQueryList media,
133133
*
134134
* @param locator the locator
135135
* @exception CSSException Any CSS exception, possibly wrapping another
136-
* exception.
136+
* exception.
137137
*/
138138
void startFontFace(Locator locator) throws CSSException;
139139

@@ -148,7 +148,7 @@ void importStyle(String uri, MediaQueryList media,
148148
* @param pseudoPage the pseudo page (if any, null otherwise)
149149
* @param locator the locator
150150
* @exception CSSException Any CSS exception, possibly wrapping another
151-
* exception.
151+
* exception.
152152
*/
153153
void startPage(String name, String pseudoPage, Locator locator) throws CSSException;
154154

@@ -162,7 +162,7 @@ void importStyle(String uri, MediaQueryList media,
162162
* @param media The intended destination media for style information.
163163
* @param locator the locator
164164
* @exception CSSException Any CSS exception, possibly wrapping another
165-
* exception.
165+
* exception.
166166
*/
167167
void startMedia(MediaQueryList media, Locator locator) throws CSSException;
168168

@@ -172,7 +172,7 @@ void importStyle(String uri, MediaQueryList media,
172172
* @param selectors All intended selectors for all declarations.
173173
* @param locator the locator
174174
* @exception CSSException Any CSS exception, possibly wrapping another
175-
* exception.
175+
* exception.
176176
*/
177177
void startSelector(SelectorList selectors, Locator locator) throws CSSException;
178178

src/main/java/org/htmlunit/cssparser/parser/condition/AttributeCondition.java

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public boolean isCaseInSensitive() {
6767
return caseInSensitive_ != null && caseInSensitive_.booleanValue();
6868
}
6969

70+
/**
71+
* @return the operator '='
72+
*/
7073
public String getOperator() {
7174
return "=";
7275
}

src/main/java/org/htmlunit/cssparser/parser/condition/LangCondition.java

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.htmlunit.cssparser.parser.Locator;
2121

2222
/**
23-
*
2423
* @author Ronald Brill
2524
*/
2625
public class LangCondition extends AbstractLocatable implements Condition, Serializable {

src/test/java/org/htmlunit/cssparser/parser/CSS3ParserTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,8 @@ public void skipInvalidColor() throws Exception {
22752275
assertEquals("*.test { display: block; }", rules.getRules().get(0).getCssText());
22762276
assertEquals("*.another { display: none; }", rules.getRules().get(1).getCssText());
22772277
}
2278-
/**
2278+
2279+
/**
22792280
* @throws Exception if any error occurs
22802281
*/
22812282
@Test

0 commit comments

Comments
 (0)