fix for 1379666
This commit is contained in:
parent
fa7617c222
commit
dfbaeedf8b
|
|
@ -23,7 +23,6 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
|||
import com.puppycrawl.tools.checkstyle.api.FullIdent;
|
||||
import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
|
||||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
import com.puppycrawl.tools.checkstyle.api.Utils;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -148,42 +147,6 @@ public abstract class AbstractTypeAwareCheck extends Check
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate if one type name is a shortname for another type name.
|
||||
* @param aShortName a shorthand, such as <code>IOException</code>
|
||||
* @param aFullName a full name, such as <code>java.io.IOException</code>
|
||||
* @return true iff aShortName represents the same type as aFullName
|
||||
*/
|
||||
protected boolean isShortName(String aShortName, String aFullName)
|
||||
{
|
||||
if (aShortName.length() >= aFullName.length()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final String base = Utils.baseClassname(aFullName);
|
||||
if (aShortName.length() >= aFullName.length()
|
||||
|| !base.equals(aShortName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check fully qualified import
|
||||
if (mImports.contains(aFullName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check .* import
|
||||
final int endIndex = aFullName.length() - base.length() - 1;
|
||||
final String packageName = aFullName.substring(0, endIndex);
|
||||
final String starImport = packageName + ".*";
|
||||
if (mImports.contains(starImport)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check fully qualified class from same package
|
||||
return packageName.equals(mPackageFullIdent.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is exception is unchecked (subclass of <code>RuntimeException</code>
|
||||
* or <code>Error</code>
|
||||
|
|
@ -214,21 +177,6 @@ public abstract class AbstractTypeAwareCheck extends Check
|
|||
&& aParent.isAssignableFrom(aChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if two Strings represent the same type, inspecting the
|
||||
* import statements if necessary
|
||||
*
|
||||
* @param aFirst first type declared in throws clause
|
||||
* @param aSecond second type declared in thros tag
|
||||
* @return true iff type names represent the same type
|
||||
*/
|
||||
protected boolean isSameType(String aFirst, String aSecond)
|
||||
{
|
||||
return aFirst.equals(aSecond)
|
||||
|| isShortName(aFirst, aSecond)
|
||||
|| isShortName(aSecond, aFirst);
|
||||
}
|
||||
|
||||
/** @return <code>ClassResolver</code> for current tree. */
|
||||
private ClassResolver getClassResolver()
|
||||
{
|
||||
|
|
@ -248,8 +196,7 @@ public abstract class AbstractTypeAwareCheck extends Check
|
|||
* @return the resolved class or <code>null</code>
|
||||
* if unable to resolve the class.
|
||||
*/
|
||||
protected final Class resolveClass(String aClassName,
|
||||
String aCurrentClass)
|
||||
protected final Class resolveClass(String aClassName, String aCurrentClass)
|
||||
{
|
||||
try {
|
||||
return getClassResolver().resolve(aClassName, aCurrentClass);
|
||||
|
|
@ -528,6 +475,13 @@ public abstract class AbstractTypeAwareCheck extends Check
|
|||
{
|
||||
return mClassInfo.getClazz();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String toString()
|
||||
{
|
||||
return "ClassAlias[alias " + getName()
|
||||
+ " for " + mClassInfo + "]";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -583,5 +537,12 @@ public abstract class AbstractTypeAwareCheck extends Check
|
|||
{
|
||||
return mText;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public String toString()
|
||||
{
|
||||
return "Token[" + getText() + "(" + getLineNo()
|
||||
+ "x" + getColumnNo() + ")]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public class ClassResolver
|
|||
mLoader = aLoader;
|
||||
mPkg = aPkg;
|
||||
mImports = aImports;
|
||||
mImports.add("java.lang.*");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,17 +69,9 @@ public class ClassResolver
|
|||
throws ClassNotFoundException
|
||||
{
|
||||
// See if the class is full qualified
|
||||
if (isLoadable(aName)) {
|
||||
return safeLoad(aName);
|
||||
}
|
||||
//Perhaps it's fully-qualified inner class
|
||||
int dotIdx = aName.lastIndexOf(".");
|
||||
if (dotIdx != -1) {
|
||||
final String cn = aName.substring(0, dotIdx) + "$"
|
||||
+ aName.substring(dotIdx + 1);
|
||||
if (isLoadable(cn)) {
|
||||
return safeLoad(cn);
|
||||
}
|
||||
Class clazz = resolveQualifiedName(aName);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
// try matching explicit imports
|
||||
|
|
@ -90,27 +83,19 @@ public class ClassResolver
|
|||
// "SecurityDataException". This has been the cause of a very
|
||||
// difficult bug to resolve!
|
||||
if (imp.endsWith("." + aName)) {
|
||||
if (isLoadable(imp)) {
|
||||
return safeLoad(imp);
|
||||
}
|
||||
// perhaps this is a import for inner class
|
||||
// let's try load it.
|
||||
final int dot = imp.lastIndexOf(".");
|
||||
if (dot != -1) {
|
||||
final String innerName = imp.substring(0, dot) + "$"
|
||||
+ imp.substring(dot + 1);
|
||||
if (isLoadable(innerName)) {
|
||||
return safeLoad(innerName);
|
||||
}
|
||||
clazz = resolveQualifiedName(imp);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// See if in the package
|
||||
if (!"".equals(mPkg)) {
|
||||
final String fqn = mPkg + "." + aName;
|
||||
if (isLoadable(fqn)) {
|
||||
return safeLoad(fqn);
|
||||
clazz = resolveQualifiedName(mPkg + "." + aName);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,12 +108,6 @@ public class ClassResolver
|
|||
}
|
||||
}
|
||||
|
||||
// try "java.lang."
|
||||
final String langClass = "java.lang." + aName;
|
||||
if (isLoadable(langClass)) {
|
||||
return safeLoad(langClass);
|
||||
}
|
||||
|
||||
// try star imports
|
||||
it = mImports.iterator();
|
||||
while (it.hasNext()) {
|
||||
|
|
@ -136,8 +115,9 @@ public class ClassResolver
|
|||
if (imp.endsWith(".*")) {
|
||||
final String fqn = imp.substring(0, imp.lastIndexOf('.') + 1)
|
||||
+ aName;
|
||||
if (isLoadable(fqn)) {
|
||||
return safeLoad(fqn);
|
||||
clazz = resolveQualifiedName(fqn);
|
||||
if (clazz != null) {
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,4 +157,34 @@ public class ClassResolver
|
|||
// class will not be initialised. Very, very important.
|
||||
return Class.forName(aName, false, mLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to resolve a class for fully-specified name.
|
||||
* @param aName a given name of class.
|
||||
* @return Class object for the given name or null.
|
||||
*/
|
||||
private Class resolveQualifiedName(final String aName)
|
||||
{
|
||||
try {
|
||||
if (isLoadable(aName)) {
|
||||
return safeLoad(aName);
|
||||
}
|
||||
//Perhaps it's fully-qualified inner class
|
||||
final int dot = aName.lastIndexOf(".");
|
||||
if (dot != -1) {
|
||||
final String innerName =
|
||||
aName.substring(0, dot) + "$" + aName.substring(dot + 1);
|
||||
if (isLoadable(innerName)) {
|
||||
return safeLoad(innerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// we shouldn't get this exception here,
|
||||
// so this is unexpected runtime exception
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class RedundantThrowsCheck extends AbstractTypeAwareCheck
|
|||
final ClassInfo ci = (ClassInfo) known.next();
|
||||
final Token fi = ci.getName();
|
||||
|
||||
if (isSameType(fi.getText(), aExc.getText())) {
|
||||
if (ci.getClazz() == newClassInfo.getClazz()) {
|
||||
shouldAdd = false;
|
||||
log(aExc.getLineNo(), aExc.getColumnNo(),
|
||||
"redundant.throws.duplicate", aExc.getText());
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ public class JavadocMethodCheck extends AbstractTypeAwareCheck
|
|||
final Token fi = ei.getName();
|
||||
final String declaredEx = fi.getText();
|
||||
|
||||
if (isSameType(declaredEx, documentedEx)) {
|
||||
if (documentedCI.getClazz() == ei.getClazz()) {
|
||||
found = true;
|
||||
ei.setFound();
|
||||
foundThrows.add(documentedEx);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package test.javadoc.method;
|
||||
|
||||
/**
|
||||
* comment.
|
||||
*/
|
||||
public class Test_1379666 {
|
||||
/**
|
||||
* @throws BadStringFormat some text
|
||||
*/
|
||||
public void ok() throws BadStringFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Test_1379666.BadStringFormat some text
|
||||
*/
|
||||
public void error1()
|
||||
throws test.javadoc.method.Test_1379666.BadStringFormat
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Some comment.
|
||||
* @throws test.javadoc.method.Test_1379666.BadStringFormat some text
|
||||
*/
|
||||
public void error2() throws Test_1379666.BadStringFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Some exception class.
|
||||
*/
|
||||
public static class BadStringFormat extends Exception {
|
||||
/**
|
||||
* Some comment.
|
||||
* @param s string.
|
||||
*/
|
||||
BadStringFormat(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,13 +3,17 @@ package com.puppycrawl.tools.checkstyle.checks.coding;
|
|||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
|
||||
public class RedundantThrowsCheckTest
|
||||
extends BaseCheckTestCase
|
||||
public class RedundantThrowsCheckTest extends BaseCheckTestCase
|
||||
{
|
||||
private DefaultConfiguration mCheckConfig;
|
||||
|
||||
public void setUp()
|
||||
{
|
||||
mCheckConfig = createCheckConfig(RedundantThrowsCheck.class);
|
||||
}
|
||||
|
||||
public void testDefaults() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {
|
||||
"7:37: Redundant throws: 'java.io.FileNotFoundException' is subclass of 'java.io.IOException'.",
|
||||
"13:16: Redundant throws: 'RuntimeException' is unchecked exception.",
|
||||
|
|
@ -18,85 +22,69 @@ public class RedundantThrowsCheckTest
|
|||
"39:27: Redundant throws: 'NullPointerException' is unchecked exception.",
|
||||
"39:49: Redundant throws: 'RuntimeException' is unchecked exception.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
}
|
||||
|
||||
public void testAllowUnchecked() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
checkConfig.addAttribute("allowUnchecked", "true");
|
||||
mCheckConfig.addAttribute("allowUnchecked", "true");
|
||||
final String[] expected = {
|
||||
"7:37: Redundant throws: 'java.io.FileNotFoundException' is subclass of 'java.io.IOException'.",
|
||||
"19:29: Redundant throws: 'java.io.IOException' listed more then one time.",
|
||||
// "35:27: Unable to get class information for WrongException.",
|
||||
"39:27: Redundant throws: 'NullPointerException' is subclass of 'RuntimeException'.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
}
|
||||
|
||||
public void testAllowSubclasses() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
checkConfig.addAttribute("allowSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowSubclasses", "true");
|
||||
final String[] expected = {
|
||||
"13:16: Redundant throws: 'RuntimeException' is unchecked exception.",
|
||||
"19:29: Redundant throws: 'java.io.IOException' listed more then one time.",
|
||||
"39:27: Redundant throws: 'NullPointerException' is unchecked exception.",
|
||||
"39:49: Redundant throws: 'RuntimeException' is unchecked exception.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
}
|
||||
|
||||
public void testRejectDuplicatesOnly() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
checkConfig.addAttribute("allowSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUnchecked", "true");
|
||||
mCheckConfig.addAttribute("allowSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowUnchecked", "true");
|
||||
final String[] expected = {
|
||||
"19:29: Redundant throws: 'java.io.IOException' listed more then one time.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputRedundantThrows.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_1() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test1.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test1.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_2() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test2.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test2.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_3() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test3.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test3.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1220726() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/BadCls.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/BadCls.java"), expected);
|
||||
}
|
||||
|
||||
public void test_generics_params() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(RedundantThrowsCheck.class);
|
||||
final String[] expected = {
|
||||
"15:34: Redundant throws: 'RE' is unchecked exception.",
|
||||
"23:37: Redundant throws: 'RE' is subclass of 'E'.",
|
||||
|
|
@ -106,10 +94,16 @@ public class RedundantThrowsCheckTest
|
|||
"31:74: Redundant throws: 'RE' is unchecked exception.",
|
||||
"41:38: Redundant throws: 'RuntimeException' is subclass of 'RE'.",
|
||||
"41:38: Redundant throws: 'RuntimeException' is unchecked exception.",
|
||||
"41:56: Redundant throws: 'RE' is subclass of 'java.lang.RuntimeException'.",
|
||||
"41:56: Redundant throws: 'RE' is unchecked exception.",
|
||||
"42:13: Redundant throws: 'java.lang.RuntimeException' is unchecked exception.",
|
||||
"42:13: Redundant throws: 'java.lang.RuntimeException' listed more then one time.",
|
||||
};
|
||||
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1379666() throws Exception
|
||||
{
|
||||
final String[] expected = {};
|
||||
verify(mCheckConfig, getPath("javadoc/Test_1379666.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ import java.io.File;
|
|||
|
||||
public class JavadocMethodCheckTest extends BaseCheckTestCase
|
||||
{
|
||||
private DefaultConfiguration mCheckConfig;
|
||||
|
||||
public void setUp()
|
||||
{
|
||||
mCheckConfig = createCheckConfig(JavadocMethodCheck.class);
|
||||
}
|
||||
|
||||
public void testTags() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"14:5: Missing a Javadoc comment.",
|
||||
"18:9: Unused @param tag for 'unused'.",
|
||||
|
|
@ -44,14 +49,12 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"333: Unused Javadoc tag.",
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("InputTags.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputTags.java"), expected);
|
||||
}
|
||||
|
||||
public void testTagsWithResolver() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
mCheckConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = {
|
||||
"14:5: Missing a Javadoc comment.",
|
||||
"18:9: Unused @param tag for 'unused'.",
|
||||
|
|
@ -79,13 +82,11 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"320:9: Missing a Javadoc comment.",
|
||||
"329:5: Missing a Javadoc comment.",
|
||||
"333: Unused Javadoc tag.", };
|
||||
verify(checkConfig, getPath("InputTags.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputTags.java"), expected);
|
||||
}
|
||||
|
||||
public void testStrictJavadoc() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"12:9: Missing a Javadoc comment.",
|
||||
"18:13: Missing a Javadoc comment.",
|
||||
|
|
@ -100,79 +101,64 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"79:5: Missing a Javadoc comment.",
|
||||
"84:5: Missing a Javadoc comment.",
|
||||
"94:32: Expected @param tag for 'aA'." };
|
||||
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputPublicOnly.java"), expected);
|
||||
}
|
||||
|
||||
public void testNoJavadoc() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.NOTHING.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.NOTHING.getName());
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputPublicOnly.java"), expected);
|
||||
}
|
||||
|
||||
// pre 1.4 relaxed mode is roughly equivalent with check=protected
|
||||
public void testRelaxedJavadoc() throws Exception
|
||||
{
|
||||
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.PROTECTED.getName());
|
||||
final String[] expected = {
|
||||
"59:5: Missing a Javadoc comment.",
|
||||
"64:5: Missing a Javadoc comment.",
|
||||
"79:5: Missing a Javadoc comment.",
|
||||
"84:5: Missing a Javadoc comment." };
|
||||
verify(checkConfig, getPath("InputPublicOnly.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputPublicOnly.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopeInnerInterfacesPublic() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.PUBLIC.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.PUBLIC.getName());
|
||||
final String[] expected = {
|
||||
"43:9: Missing a Javadoc comment.",
|
||||
"44:9: Missing a Javadoc comment." };
|
||||
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopeAnonInnerPrivate() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.PRIVATE.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.PRIVATE.getName());
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopeAnonInnerAnonInner() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.ANONINNER.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.ANONINNER.getName());
|
||||
final String[] expected = {
|
||||
"26:9: Missing a Javadoc comment.",
|
||||
"39:17: Missing a Javadoc comment.",
|
||||
"53:17: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopeAnonInnerWithResolver() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
mCheckConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputScopeAnonInner.java"), expected);
|
||||
}
|
||||
|
||||
public void testTagsWithSubclassesAllowed() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
final String[] expected = {
|
||||
"14:5: Missing a Javadoc comment.",
|
||||
"18:9: Unused @param tag for 'unused'.",
|
||||
|
|
@ -200,13 +186,11 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"320:9: Missing a Javadoc comment.",
|
||||
"329:5: Missing a Javadoc comment.",
|
||||
"333: Unused Javadoc tag.", };
|
||||
verify(checkConfig, getPath("InputTags.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputTags.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopes() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"8:5: Missing a Javadoc comment.",
|
||||
"9:5: Missing a Javadoc comment.",
|
||||
|
|
@ -244,30 +228,26 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"104:9: Missing a Javadoc comment.",
|
||||
"105:9: Missing a Javadoc comment.",
|
||||
"106:9: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputNoJavadoc.java"), expected);
|
||||
}
|
||||
|
||||
public void testScopes2() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.PROTECTED.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.PROTECTED.getName());
|
||||
final String[] expected = {
|
||||
"8:5: Missing a Javadoc comment.",
|
||||
"9:5: Missing a Javadoc comment.",
|
||||
"19:9: Missing a Javadoc comment.",
|
||||
"20:9: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputNoJavadoc.java"), expected);
|
||||
}
|
||||
|
||||
public void testExcludeScope() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("scope", Scope.PRIVATE.getName());
|
||||
checkConfig.addAttribute("excludeScope", Scope.PROTECTED.getName());
|
||||
mCheckConfig.addAttribute("scope", Scope.PRIVATE.getName());
|
||||
mCheckConfig.addAttribute("excludeScope", Scope.PROTECTED.getName());
|
||||
final String[] expected = {
|
||||
"10:5: Missing a Javadoc comment.",
|
||||
"11:5: Missing a Javadoc comment.",
|
||||
|
|
@ -301,24 +281,20 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"104:9: Missing a Javadoc comment.",
|
||||
"105:9: Missing a Javadoc comment.",
|
||||
"106:9: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputNoJavadoc.java"), expected);
|
||||
}
|
||||
|
||||
public void testAllowMissingJavadoc() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowMissingJavadoc", "true");
|
||||
mCheckConfig.addAttribute("allowMissingJavadoc", "true");
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputNoJavadoc.java"), expected);
|
||||
}
|
||||
|
||||
public void testSetterGetterOff() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"5:5: Missing a Javadoc comment.",
|
||||
"10:5: Missing a Javadoc comment.",
|
||||
|
|
@ -329,15 +305,13 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"35:5: Missing a Javadoc comment.",
|
||||
"41:5: Missing a Javadoc comment.",
|
||||
"46:5: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputSetterGetter.java"), expected);
|
||||
}
|
||||
|
||||
public void testSetterGetterOn() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowMissingPropertyJavadoc", "true");
|
||||
mCheckConfig.addAttribute("allowMissingPropertyJavadoc", "true");
|
||||
final String[] expected = {
|
||||
"15:5: Missing a Javadoc comment.",
|
||||
"20:5: Missing a Javadoc comment.",
|
||||
|
|
@ -345,52 +319,42 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"30:5: Missing a Javadoc comment.",
|
||||
"35:5: Missing a Javadoc comment.",
|
||||
"41:5: Missing a Javadoc comment.", };
|
||||
verify(checkConfig, getPath("javadoc" + File.separator
|
||||
verify(mCheckConfig, getPath("javadoc" + File.separator
|
||||
+ "InputSetterGetter.java"), expected);
|
||||
}
|
||||
|
||||
public void testTypeParamsTags() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"26:8: Unused @param tag for '<BB>'.",
|
||||
"28:13: Expected @param tag for '<Z>'.", };
|
||||
verify(checkConfig, getPath("InputTypeParamsTags.java"), expected);
|
||||
verify(mCheckConfig, getPath("InputTypeParamsTags.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_1() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test1.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test1.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_2() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test2.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test2.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1168408_3() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
mCheckConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = {};
|
||||
verify(checkConfig, getPath("javadoc/Test3.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/Test3.java"), expected);
|
||||
}
|
||||
|
||||
public void test_generics_1() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
checkConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
mCheckConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = {
|
||||
"15:34: Expected @throws tag for 'RE'.",
|
||||
"23:37: Expected @throws tag for 'RE'.",
|
||||
|
|
@ -399,14 +363,12 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"41:38: Expected @throws tag for 'RuntimeException'.",
|
||||
"42:13: Expected @throws tag for 'java.lang.RuntimeException'.",
|
||||
};
|
||||
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
}
|
||||
|
||||
public void test_generics_2() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
checkConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
final String[] expected = {
|
||||
"15:34: Expected @throws tag for 'RE'.",
|
||||
"23:37: Expected @throws tag for 'RE'.",
|
||||
|
|
@ -415,13 +377,11 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"41:38: Expected @throws tag for 'RuntimeException'.",
|
||||
"42:13: Expected @throws tag for 'java.lang.RuntimeException'.",
|
||||
};
|
||||
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
}
|
||||
|
||||
public void test_generics_3() throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(JavadocMethodCheck.class);
|
||||
final String[] expected = {
|
||||
"6:8: Unused @throws tag for 'RE'.",
|
||||
"15:34: Expected @throws tag for 'RE'.",
|
||||
|
|
@ -430,6 +390,14 @@ public class JavadocMethodCheckTest extends BaseCheckTestCase
|
|||
"41:38: Expected @throws tag for 'RuntimeException'.",
|
||||
"42:13: Expected @throws tag for 'java.lang.RuntimeException'.",
|
||||
};
|
||||
verify(checkConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
verify(mCheckConfig, getPath("javadoc/TestGenerics.java"), expected);
|
||||
}
|
||||
|
||||
public void test_1379666() throws Exception
|
||||
{
|
||||
mCheckConfig.addAttribute("allowThrowsTagsForSubclasses", "true");
|
||||
mCheckConfig.addAttribute("allowUndeclaredRTE", "true");
|
||||
final String[] expected = {};
|
||||
verify(mCheckConfig, getPath("javadoc/Test_1379666.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,27 +9,39 @@
|
|||
</properties>
|
||||
|
||||
<body>
|
||||
<section name="Release 4.2">
|
||||
<p>Fixed Bugs:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Fixed problem in type aware checks with loading
|
||||
inner-classes which were referenced as
|
||||
<outer_class_name>.<inner_class_name> (bug
|
||||
1379666, modules JavadocMethod and RedundantThrows).
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section name="Release 4.1">
|
||||
<p>Fixed Bugs:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Documentation for JavadocMethod check corrected to indicate
|
||||
Documentation for JavadocMethod check corrected to indicate
|
||||
that after fix for 1290379 javadoc which contains only @see
|
||||
tag is not valid any more (bug 1369615)
|
||||
</li>
|
||||
<li>
|
||||
Fixed StackOverflowError in GenericIllegalRegexp check
|
||||
Fixed StackOverflowError in GenericIllegalRegexp check
|
||||
which may occur if ignoreComments is true and there is an
|
||||
illegal match in comment at the end of line. (bug 1371588)
|
||||
</li>
|
||||
<li>
|
||||
InnerAssignment now ignores assignments in annotations. (bug
|
||||
InnerAssignment now ignores assignments in annotations. (bug
|
||||
1369425)
|
||||
</li>
|
||||
<li>
|
||||
Applied patch from Ralf (rakus) to remove javadoc's
|
||||
Applied patch from Ralf (rakus) to remove javadoc's
|
||||
complainings. (patch 1352862)
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -37,9 +49,9 @@
|
|||
throws if someone tries to create object of generic class
|
||||
(with any params) (bug 1374792).
|
||||
</li>
|
||||
<li>
|
||||
Added information to the manifest file. (bug 1380322).
|
||||
</li>
|
||||
<li>
|
||||
Added information to the manifest file. (bug 1380322).
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue