diff --git a/checkstyle_checks.xml b/checkstyle_checks.xml
index d1c75647c..87cbaec4d 100755
--- a/checkstyle_checks.xml
+++ b/checkstyle_checks.xml
@@ -123,7 +123,8 @@
-
+
+
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractOption.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractOption.java
index 395a39546..5dd7b0cfe 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractOption.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractOption.java
@@ -18,8 +18,8 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks;
-import java.io.Serializable;
import java.io.ObjectStreamException;
+import java.io.Serializable;
import java.util.Map;
/**
@@ -43,7 +43,7 @@ public abstract class AbstractOption
protected AbstractOption(String aStrRep)
{
mStrRep = aStrRep.trim().toLowerCase();
- final Map strToOpt = getStrToOpt();
+ final Map strToOpt = getStrToOpt();
strToOpt.put(mStrRep, this);
}
@@ -51,7 +51,7 @@ public abstract class AbstractOption
* Returns the map from string representations to options.
* @return Map from strings to options.
*/
- protected abstract Map getStrToOpt();
+ protected abstract Map getStrToOpt();
/**
* Returns the option specified by a string representation. If no
@@ -62,13 +62,14 @@ public abstract class AbstractOption
*/
public AbstractOption decode(String aStrRep)
{
- final Map strToOpt = getStrToOpt();
- return (AbstractOption) strToOpt.get(aStrRep.trim().toLowerCase());
+ final Map strToOpt = getStrToOpt();
+ return strToOpt.get(aStrRep.trim().toLowerCase());
}
/**
* {@inheritDoc}
**/
+ @Override
public String toString()
{
return mStrRep;
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
index 15ecd0735..4299bfc03 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/CheckUtils.java
@@ -21,9 +21,8 @@ package com.puppycrawl.tools.checkstyle.checks;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
-
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* Contains utility methods for the checks.
@@ -274,12 +273,12 @@ public final class CheckUtils
* @param aNode the parameterised AST node
* @return a list of type parameter names
*/
- public static List getTypeParameterNames(final DetailAST aNode)
+ public static List getTypeParameterNames(final DetailAST aNode)
{
final DetailAST typeParameters =
aNode.findFirstToken(TokenTypes.TYPE_PARAMETERS);
- final List typeParamNames = new ArrayList();
+ final List typeParamNames = new ArrayList();
if (typeParameters != null) {
final DetailAST typeParam =
typeParameters.findFirstToken(TokenTypes.TYPE_PARAMETER);
@@ -304,12 +303,12 @@ public final class CheckUtils
* @param aNode the parameterised AST node
* @return a list of type parameter names
*/
- public static List getTypeParameters(final DetailAST aNode)
+ public static List getTypeParameters(final DetailAST aNode)
{
final DetailAST typeParameters =
aNode.findFirstToken(TokenTypes.TYPE_PARAMETERS);
- final List typeParams = new ArrayList();
+ final List typeParams = new ArrayList();
if (typeParameters != null) {
final DetailAST typeParam =
typeParameters.findFirstToken(TokenTypes.TYPE_PARAMETER);
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/header/HeaderInfo.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/header/HeaderInfo.java
index f19aba971..53e6ca619 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/header/HeaderInfo.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/header/HeaderInfo.java
@@ -25,7 +25,6 @@ import java.io.LineNumberReader;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
-
import org.apache.commons.beanutils.ConversionException;
/**
@@ -149,7 +148,7 @@ class HeaderInfo
private void loadHeader(final Reader aHeaderReader) throws IOException
{
final LineNumberReader lnr = new LineNumberReader(aHeaderReader);
- final ArrayList lines = new ArrayList();
+ final ArrayList lines = new ArrayList();
while (true) {
final String l = lnr.readLine();
if (l == null) {
@@ -157,7 +156,7 @@ class HeaderInfo
}
lines.add(l);
}
- mHeaderLines = (String[]) lines.toArray(new String[lines.size()]);
+ mHeaderLines = lines.toArray(new String[lines.size()]);
postprocessHeaderLines();
}
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java
index 2ecbb37d2..80e94e357 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java
@@ -18,18 +18,7 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.javadoc;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import antlr.collections.AST;
-
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FileContents;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
@@ -40,6 +29,14 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.puppycrawl.tools.checkstyle.api.Utils;
import com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck;
import com.puppycrawl.tools.checkstyle.checks.CheckUtils;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Checks the Javadoc of a method or constructor.
@@ -256,6 +253,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
}
/** {@inheritDoc} */
+ @Override
public int[] getDefaultTokens()
{
return new int[] {TokenTypes.PACKAGE_DEF, TokenTypes.IMPORT,
@@ -266,6 +264,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
}
/** {@inheritDoc} */
+ @Override
public int[] getAcceptableTokens()
{
return new int[] {TokenTypes.METHOD_DEF, TokenTypes.CTOR_DEF,
@@ -278,6 +277,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
*
* @param aAST the tree node for the method or constructor.
*/
+ @Override
protected final void processAST(DetailAST aAST)
{
final Scope theScope = calculateScope(aAST);
@@ -301,6 +301,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
*
* @param aIdent class name for which we can no load class.
*/
+ @Override
protected final void logLoadError(Token aIdent)
{
logLoadErrorImpl(aIdent.getLineNo(), aIdent.getColumnNo(),
@@ -352,18 +353,18 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
*/
private void checkComment(DetailAST aAST, TextBlock aComment, Scope aScope)
{
- final List tags = getMethodTags(aComment);
+ final List tags = getMethodTags(aComment);
if (hasShortCircuitTag(aAST, tags, aScope)) {
return;
}
- Iterator it = tags.iterator();
+ Iterator it = tags.iterator();
if (aAST.getType() != TokenTypes.ANNOTATION_FIELD_DEF) {
// Check for inheritDoc
boolean hasInheritDocTag = false;
while (it.hasNext() && !hasInheritDocTag) {
- hasInheritDocTag |= ((JavadocTag) it.next()).isInheritDocTag();
+ hasInheritDocTag |= (it.next()).isInheritDocTag();
}
checkParamTags(tags, aAST, !hasInheritDocTag);
@@ -376,7 +377,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Dump out all unused tags
it = tags.iterator();
while (it.hasNext()) {
- final JavadocTag jt = (JavadocTag) it.next();
+ final JavadocTag jt = it.next();
if (!jt.isSeeOrInheritDocTag()) {
log(jt.getLineNo(), "javadoc.unusedTagGeneral");
}
@@ -392,12 +393,12 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aScope the scope of the construct
* @return true if the construct has a short circuit tag.
*/
- private boolean hasShortCircuitTag(final DetailAST aAST, final List aTags,
- final Scope aScope)
+ private boolean hasShortCircuitTag(final DetailAST aAST,
+ final List aTags, final Scope aScope)
{
// Check if it contains {@inheritDoc} tag
if ((aTags.size() != 1)
- || !((JavadocTag) aTags.get(0)).isInheritDocTag())
+ || !(aTags.get(0)).isInheritDocTag())
{
return false;
}
@@ -435,10 +436,10 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @return the tags found
* @param aComment the Javadoc comment
*/
- private List getMethodTags(TextBlock aComment)
+ private List getMethodTags(TextBlock aComment)
{
final String[] lines = aComment.getText();
- final List tags = new ArrayList();
+ final List tags = new ArrayList();
int currentLine = aComment.getStartLineNo() - 1;
for (int i = 0; i < lines.length; i++) {
@@ -541,10 +542,10 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aAST the method node.
* @return the list of parameter nodes for aAST.
*/
- private List getParameters(DetailAST aAST)
+ private List getParameters(DetailAST aAST)
{
final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
- final List retVal = new ArrayList();
+ final List retVal = new ArrayList();
DetailAST child = (DetailAST) params.getFirstChild();
while (child != null) {
@@ -563,9 +564,9 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aAST the method node.
* @return the list of exception nodes for aAST.
*/
- private List getThrows(DetailAST aAST)
+ private List getThrows(DetailAST aAST)
{
- final List retVal = new ArrayList();
+ final List retVal = new ArrayList();
final DetailAST throwsAST = aAST
.findFirstToken(TokenTypes.LITERAL_THROWS);
if (throwsAST != null) {
@@ -593,16 +594,17 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aReportExpectedTags whether we should report if do not find
* expected tag
*/
- private void checkParamTags(final List aTags, final DetailAST aParent,
- boolean aReportExpectedTags)
+ private void checkParamTags(final List aTags,
+ final DetailAST aParent, boolean aReportExpectedTags)
{
- final List params = getParameters(aParent);
- final List typeParams = CheckUtils.getTypeParameters(aParent);
+ final List params = getParameters(aParent);
+ final List typeParams = CheckUtils
+ .getTypeParameters(aParent);
// Loop over the tags, checking to see they exist in the params.
- final ListIterator tagIt = aTags.listIterator();
+ final ListIterator tagIt = aTags.listIterator();
while (tagIt.hasNext()) {
- final JavadocTag tag = (JavadocTag) tagIt.next();
+ final JavadocTag tag = tagIt.next();
if (!tag.isParamTag()) {
continue;
@@ -613,9 +615,9 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
boolean found = false;
// Loop looking for matching param
- final Iterator paramIt = params.iterator();
+ final Iterator paramIt = params.iterator();
while (paramIt.hasNext()) {
- final DetailAST param = (DetailAST) paramIt.next();
+ final DetailAST param = paramIt.next();
if (param.getText().equals(tag.getArg1())) {
found = true;
paramIt.remove();
@@ -625,9 +627,9 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
if (tag.getArg1().startsWith("<") && tag.getArg1().endsWith(">")) {
// Loop looking for matching type param
- final Iterator typeParamsIt = typeParams.iterator();
+ final Iterator typeParamsIt = typeParams.iterator();
while (typeParamsIt.hasNext()) {
- final DetailAST typeParam = (DetailAST) typeParamsIt.next();
+ final DetailAST typeParam = typeParamsIt.next();
if (typeParam.findFirstToken(TokenTypes.IDENT).getText()
.equals(
tag.getArg1().substring(1,
@@ -651,15 +653,15 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Now dump out all type parameters/parameters without tags :- unless
// the user has chosen to suppress these problems
if (!mAllowMissingParamTags && aReportExpectedTags) {
- final Iterator paramIt = params.iterator();
+ final Iterator paramIt = params.iterator();
while (paramIt.hasNext()) {
- final DetailAST param = (DetailAST) paramIt.next();
+ final DetailAST param = paramIt.next();
log(param, "javadoc.expectedTag", "@param", param.getText());
}
- final Iterator typeParamsIt = typeParams.iterator();
+ final Iterator typeParamsIt = typeParams.iterator();
while (typeParamsIt.hasNext()) {
- final DetailAST typeParam = (DetailAST) typeParamsIt.next();
+ final DetailAST typeParam = typeParamsIt.next();
log(typeParam, "javadoc.expectedTag", "@param", "<"
+ typeParam.findFirstToken(TokenTypes.IDENT).getText()
+ ">");
@@ -696,15 +698,15 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aReportExpectedTags whether we should report if do not find
* expected tag
*/
- private void checkReturnTag(List aTags, int aLineNo,
+ private void checkReturnTag(List aTags, int aLineNo,
boolean aReportExpectedTags)
{
// Loop over tags finding return tags. After the first one, report an
// error.
boolean found = false;
- final ListIterator it = aTags.listIterator();
+ final ListIterator it = aTags.listIterator();
while (it.hasNext()) {
- final JavadocTag jt = (JavadocTag) it.next();
+ final JavadocTag jt = it.next();
if (jt.isReturnTag()) {
if (found) {
log(jt.getLineNo(), jt.getColumnNo(),
@@ -730,14 +732,15 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
* @param aReportExpectedTags whether we should report if do not find
* expected tag
*/
- private void checkThrowsTags(List aTags, List aThrows,
- boolean aReportExpectedTags)
+ private void checkThrowsTags(List aTags,
+ List aThrows, boolean aReportExpectedTags)
{
// Loop over the tags, checking to see they exist in the throws.
- final Set foundThrows = new HashSet(); //used for performance only
- final ListIterator tagIt = aTags.listIterator();
+ // The foundThrows used for performance only
+ final Set foundThrows = new HashSet();
+ final ListIterator tagIt = aTags.listIterator();
while (tagIt.hasNext()) {
- final JavadocTag tag = (JavadocTag) tagIt.next();
+ final JavadocTag tag = tagIt.next();
if (!tag.isThrowsTag()) {
continue;
@@ -753,9 +756,9 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
getCurrentClassName());
boolean found = foundThrows.contains(documentedEx);
- final ListIterator throwIt = aThrows.listIterator();
+ final ListIterator throwIt = aThrows.listIterator();
while (!found && throwIt.hasNext()) {
- final ExceptionInfo ei = (ExceptionInfo) throwIt.next();
+ final ExceptionInfo ei = throwIt.next();
if (documentedCI.getClazz() == ei.getClazz()) {
found = true;
@@ -785,9 +788,9 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
// Now dump out all throws without tags :- unless
// the user has chosen to suppress these problems
if (!mAllowMissingThrowsTags && aReportExpectedTags) {
- final ListIterator throwIt = aThrows.listIterator();
+ final ListIterator throwIt = aThrows.listIterator();
while (throwIt.hasNext()) {
- final ExceptionInfo ei = (ExceptionInfo) throwIt.next();
+ final ExceptionInfo ei = throwIt.next();
if (!ei.isFound()) {
final Token fi = ei.getName();
log(fi.getLineNo(), fi.getColumnNo(),
@@ -915,7 +918,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
/** does the exception have throws tag associated with. */
private boolean mFound;
/** class information associated with this exception. */
- private ClassInfo mClassInfo;
+ private final ClassInfo mClassInfo;
/**
* Creates new instance for FullIdent.
@@ -947,7 +950,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
}
/** @return class for this exception */
- final Class getClazz()
+ final Class> getClazz()
{
return mClassInfo.getClazz();
}
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java
index 58dcae112..30079b69e 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java
@@ -18,11 +18,6 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.javadoc;
-import java.util.Stack;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FileContents;
@@ -31,6 +26,10 @@ import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
import com.puppycrawl.tools.checkstyle.api.TextBlock;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.puppycrawl.tools.checkstyle.checks.CheckUtils;
+import java.util.List;
+import java.util.Stack;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
/**
* Custom Checkstyle Check to validate Javadoc.
@@ -78,6 +77,7 @@ public class JavadocStyleCheck
private boolean mCheckEmptyJavadoc;
/** {@inheritDoc} */
+ @Override
public int[] getDefaultTokens()
{
return new int[] {
@@ -94,6 +94,7 @@ public class JavadocStyleCheck
}
/** {@inheritDoc} */
+ @Override
public void visitToken(DetailAST aAST)
{
if (shouldCheck(aAST)) {
@@ -295,9 +296,9 @@ public class JavadocStyleCheck
private void checkHtml(final DetailAST aAST, final TextBlock aComment)
{
final int lineno = aComment.getStartLineNo();
- final Stack htmlStack = new Stack();
+ final Stack htmlStack = new Stack();
final String[] text = aComment.getText();
- final List typeParameters =
+ final List typeParameters =
CheckUtils.getTypeParameterNames(aAST);
TagParser parser = null;
@@ -338,7 +339,7 @@ public class JavadocStyleCheck
// Identify any tags left on the stack.
String lastFound = ""; // Skip multiples, like ...
for (int i = 0; i < htmlStack.size(); i++) {
- final HtmlTag htag = (HtmlTag) htmlStack.elementAt(i);
+ final HtmlTag htag = htmlStack.elementAt(i);
if (!isSingleTag(htag)
&& !htag.getId().equals(lastFound)
&& !typeParameters.contains(htag.getId()))
@@ -358,26 +359,26 @@ public class JavadocStyleCheck
* @param aHtmlStack the stack of opened HTML tags.
* @param aToken the current HTML tag name that has been closed.
*/
- private void checkUnclosedTags(Stack aHtmlStack, String aToken)
+ private void checkUnclosedTags(Stack aHtmlStack, String aToken)
{
- final Stack unclosedTags = new Stack();
- HtmlTag lastOpenTag = (HtmlTag) aHtmlStack.pop();
+ final Stack unclosedTags = new Stack();
+ HtmlTag lastOpenTag = aHtmlStack.pop();
while (!aToken.equalsIgnoreCase(lastOpenTag.getId())) {
// Find unclosed elements. Put them on a stack so the
// output order won't be back-to-front.
if (isSingleTag(lastOpenTag)) {
- lastOpenTag = (HtmlTag) aHtmlStack.pop();
+ lastOpenTag = aHtmlStack.pop();
}
else {
unclosedTags.push(lastOpenTag);
- lastOpenTag = (HtmlTag) aHtmlStack.pop();
+ lastOpenTag = aHtmlStack.pop();
}
}
// Output the unterminated tags, if any
String lastFound = ""; // Skip multiples, like ..
for (int i = 0; i < unclosedTags.size(); i++) {
- lastOpenTag = (HtmlTag) unclosedTags.get(i);
+ lastOpenTag = unclosedTags.get(i);
if (lastOpenTag.getId().equals(lastFound)) {
continue;
}
@@ -419,7 +420,7 @@ public class JavadocStyleCheck
* @return false if a previous open tag was found
* for the token.
*/
- private boolean isExtraHtml(String aToken, Stack aHtmlStack)
+ private boolean isExtraHtml(String aToken, Stack aHtmlStack)
{
boolean isExtra = true;
for (int i = 0; i < aHtmlStack.size(); i++) {
@@ -427,7 +428,7 @@ public class JavadocStyleCheck
// The loop is needed in case there are unclosed
// tags on the stack. In that case, the stack would
// not be empty, but this tag would still be extra.
- final HtmlTag td = (HtmlTag) aHtmlStack.elementAt(i);
+ final HtmlTag td = aHtmlStack.elementAt(i);
if (aToken.equalsIgnoreCase(td.getId())) {
isExtra = false;
break;
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
index 20dcbe212..cf359086a 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java
@@ -128,6 +128,7 @@ public class JavadocTypeCheck
}
/** {@inheritDoc} */
+ @Override
public int[] getDefaultTokens()
{
return new int[] {
@@ -139,6 +140,7 @@ public class JavadocTypeCheck
}
/** {@inheritDoc} */
+ @Override
public void visitToken(DetailAST aAST)
{
if (shouldCheck(aAST)) {
@@ -150,23 +152,23 @@ public class JavadocTypeCheck
}
else if (ScopeUtils.isOuterMostType(aAST)) {
// don't check author/version for inner classes
- final List tags = getJavadocTags(cmt);
+ final List tags = getJavadocTags(cmt);
checkTag(lineNo, tags, "author",
mAuthorFormatPattern, mAuthorFormat);
checkTag(lineNo, tags, "version",
mVersionFormatPattern, mVersionFormat);
- final List typeParamNames =
+ final List typeParamNames =
CheckUtils.getTypeParameterNames(aAST);
if (!mAllowMissingParamTags) {
//Check type parameters that should exist, do
- for (final Iterator typeParamNameIt =
+ for (final Iterator typeParamNameIt =
typeParamNames.iterator();
typeParamNameIt.hasNext();)
{
checkTypeParamTag(
- lineNo, tags, (String) typeParamNameIt.next());
+ lineNo, tags, typeParamNameIt.next());
}
}
@@ -202,10 +204,10 @@ public class JavadocTypeCheck
* @param aCmt teh Javadoc comment to process.
* @return all standalone tags from the given javadoc.
*/
- private List getJavadocTags(TextBlock aCmt)
+ private List getJavadocTags(TextBlock aCmt)
{
final String[] text = aCmt.getText();
- final List tags = new ArrayList();
+ final List tags = new ArrayList();
Pattern tagPattern = Utils.getPattern("/\\*{2,}\\s*@(\\p{Alpha}+)\\s");
for (int i = 0; i < text.length; i++) {
final String s = text[i];
@@ -236,7 +238,7 @@ public class JavadocTypeCheck
* @param aFormatPattern regexp for the tag value.
* @param aFormat pattern for the tag value.
*/
- private void checkTag(int aLineNo, List aTags, String aTag,
+ private void checkTag(int aLineNo, List aTags, String aTag,
Pattern aFormatPattern, String aFormat)
{
if (aFormatPattern == null) {
@@ -245,7 +247,7 @@ public class JavadocTypeCheck
int tagCount = 0;
for (int i = aTags.size() - 1; i >= 0; i--) {
- final JavadocTag tag = (JavadocTag) aTags.get(i);
+ final JavadocTag tag = aTags.get(i);
if (tag.getTag().equals(aTag)) {
tagCount++;
if (!aFormatPattern.matcher(tag.getArg1()).find()) {
@@ -265,12 +267,12 @@ public class JavadocTypeCheck
* @param aTags tags from the Javadoc comment for the type definition.
* @param aTypeParamName the name of the type parameter
*/
- private void checkTypeParamTag(
- final int aLineNo, final List aTags, final String aTypeParamName)
+ private void checkTypeParamTag(final int aLineNo,
+ final List aTags, final String aTypeParamName)
{
boolean found = false;
for (int i = aTags.size() - 1; i >= 0; i--) {
- final JavadocTag tag = (JavadocTag) aTags.get(i);
+ final JavadocTag tag = aTags.get(i);
if (tag.getTag().equals("param")
&& (tag.getArg1() != null)
&& (tag.getArg1().indexOf("<" + aTypeParamName + ">") == 0))
@@ -289,12 +291,12 @@ public class JavadocTypeCheck
* @param aTypeParamNames names of type parameters
*/
private void checkUnusedTypeParamTags(
- final List aTags,
- final List aTypeParamNames)
+ final List aTags,
+ final List aTypeParamNames)
{
final Pattern pattern = Utils.getPattern("\\s*<([^>]+)>.*");
for (int i = aTags.size() - 1; i >= 0; i--) {
- final JavadocTag tag = (JavadocTag) aTags.get(i);
+ final JavadocTag tag = aTags.get(i);
if (tag.getTag().equals("param")) {
if (tag.getArg1() != null) {
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/PackageHtmlCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/PackageHtmlCheck.java
index f60129b7b..3f634deeb 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/PackageHtmlCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/PackageHtmlCheck.java
@@ -18,13 +18,12 @@
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.javadoc;
+import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
+import com.puppycrawl.tools.checkstyle.api.MessageDispatcher;
import java.io.File;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import java.util.HashSet;
-
-import com.puppycrawl.tools.checkstyle.api.MessageDispatcher;
-import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
/**
* Checks that all packages have a package documentation.
@@ -51,9 +50,9 @@ public class PackageHtmlCheck extends AbstractFileSetCheck
public void process(File[] aFiles)
{
final File[] javaFiles = filter(aFiles);
- final Set directories = getParentDirs(javaFiles);
- for (final Iterator it = directories.iterator(); it.hasNext();) {
- final File dir = (File) it.next();
+ final Set directories = getParentDirs(javaFiles);
+ for (final Iterator it = directories.iterator(); it.hasNext();) {
+ final File dir = it.next();
final File packageHtml = new File(dir, "package.html");
final MessageDispatcher dispatcher = getMessageDispatcher();
final String path = packageHtml.getPath();
@@ -71,9 +70,9 @@ public class PackageHtmlCheck extends AbstractFileSetCheck
* @param aFiles s set of files
* @return the set of parent directories of the given files
*/
- protected final Set getParentDirs(File[] aFiles)
+ protected final Set getParentDirs(File[] aFiles)
{
- final Set directories = new HashSet();
+ final Set directories = new HashSet();
for (int i = 0; i < aFiles.length; i++) {
final File f = aFiles[i].getAbsoluteFile();
if (f.getName().endsWith(".java")) {
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser.java
index ebe6eb1cd..8d14e46fd 100755
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser.java
@@ -34,7 +34,7 @@ import java.util.List;
class TagParser
{
/** List of HtmlTags found on the input line of text. */
- private final List mTags = new LinkedList();
+ private final List mTags = new LinkedList();
/**
* Constructs a TagParser and finds the first tag if any.
@@ -54,7 +54,7 @@ class TagParser
*/
public HtmlTag nextTag()
{
- return (HtmlTag) mTags.remove(0);
+ return mTags.remove(0);
}
/**
diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java
index e27c7b737..4d126ebe0 100644
--- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java
+++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheck.java
@@ -39,7 +39,7 @@ public final class ExecutableStatementCountCheck
private int mMax;
/** Stack of method contexts. */
- private final Stack mContextStack = new Stack();
+ private final Stack mContextStack = new Stack();
/** Current method context. */
private Context mContext;
@@ -51,6 +51,7 @@ public final class ExecutableStatementCountCheck
}
/** {@inheritDoc} */
+ @Override
public int[] getDefaultTokens()
{
return new int[] {
@@ -63,6 +64,7 @@ public final class ExecutableStatementCountCheck
}
/** {@inheritDoc} */
+ @Override
public int[] getRequiredTokens()
{
return new int[] {TokenTypes.SLIST};
@@ -87,6 +89,7 @@ public final class ExecutableStatementCountCheck
}
/** {@inheritDoc} */
+ @Override
public void beginTree(DetailAST aRootAST)
{
mContext = null;
@@ -94,6 +97,7 @@ public final class ExecutableStatementCountCheck
}
/** {@inheritDoc} */
+ @Override
public void visitToken(DetailAST aAST)
{
switch (aAST.getType()) {
@@ -112,6 +116,7 @@ public final class ExecutableStatementCountCheck
}
/** {@inheritDoc} */
+ @Override
public void leaveToken(DetailAST aAST)
{
switch (aAST.getType()) {
@@ -155,7 +160,7 @@ public final class ExecutableStatementCountCheck
new Integer(count),
new Integer(getMax()));
}
- mContext = (Context) mContextStack.pop();
+ mContext = mContextStack.pop();
}
/**
@@ -193,7 +198,7 @@ public final class ExecutableStatementCountCheck
private class Context
{
/** Member AST node. */
- private DetailAST mAST;
+ private final DetailAST mAST;
/** Counter for context elements. */
private int mCount;