diff options
author | rnveach <rveach02@gmail.com> | 2015-10-17 16:38:19 -0400 |
---|---|---|
committer | Roman Ivanov <ivanov-jr@mail.ru> | 2015-10-19 05:09:06 -0700 |
commit | 5aacffce41a8f8d6b79f0b4a771e3e5ce03c0d02 (patch) | |
tree | 1da4ae63eec6379d959d331d9b659ed893956d6c /src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc | |
parent | 44cc8b53c90117295151ea6723f859287f51dda5 (diff) | |
download | checkstyle-5aacffce41a8f8d6b79f0b4a771e3e5ce03c0d02.tar.gz |
Issue #2161: unify test input locations for javadoc package
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc')
16 files changed, 1087 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/AllowedAnnotations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/AllowedAnnotations.java new file mode 100644 index 000000000..39a868a0c --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/AllowedAnnotations.java @@ -0,0 +1,39 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + * Some javadoc. + */ +public class AllowedAnnotations implements SomeInterface { + + @ThisIsOk + public void allowed1() {} + + @ThisIsOkToo + public void allowed2() {} + + @com.puppycrawl.tools.checkstyle.checks.javadoc.ThisIsOk + public void allowed3() {} + + @Override + public void method() {} +} + +/** + * Documented. + */ +interface SomeInterface { + /** + * Documented. + */ + void method(); +} + +/** + * Some javadoc. + */ +@interface ThisIsOk {} + +/** + * Some javadoc. + */ +@interface ThisIsOkToo {} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/ExtendAnnotation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/ExtendAnnotation.java new file mode 100644 index 000000000..b0623ac30 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/ExtendAnnotation.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +import com.google.common.annotations.GwtCompatible; +import com.google.common.annotations.GwtIncompatible; +import com.google.common.collect.Multiset; +import com.google.common.collect.Multiset.Entry; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.ConcurrentModificationException; +import java.util.Iterator; +import java.util.List; + +/** + * Common superclass for {@link MultisetSetCountUnconditionallyTester} and + * {@link MultisetSetCountConditionallyTester}. It is used by those testers to + * test calls to the unconditional {@code setCount()} method and calls to the + * conditional {@code setCount()} method when the expected present count is + * correct. + * + * @author Chris Povirk + */ +@GwtCompatible(emulated = true) +public abstract class ExtendAnnotation<E> + { + + private static final String SUPPORTS_ADD = ""; + private static final String SUPPORTS_REMOVE = null; + +@CollectionFeature.Require + public void testSetCount_zeroToZero_unsupported() { + try { + assertZeroToZero(); + } catch (UnsupportedOperationException tolerated) { + } + } + + private void assertZeroToZero() { + + } + + @interface CollectionFeature { + @interface Require { + } + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInheritDoc.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInheritDoc.java new file mode 100644 index 000000000..762f47f66 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInheritDoc.java @@ -0,0 +1,49 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputInheritDoc +{ + /** {@inheritDoc} */ + InputInheritDoc() + { + } + + /** {@inheritDoc} */ + private void privateMethod() + { + } + + /** {@inheritDoc} */ + void packageMethod() + { + } + + /** {@inheritDoc} */ + protected void protectedMethod() + { + } + + /** {@inheritDoc} */ + public void publicMethod() + { + } + + /** {@inheritDoc} */ + private static void privateStaticMethod() + { + } + + /** {@inheritDoc} */ + static void packageStaticMethod() + { + } + + /** {@inheritDoc} */ + protected static void protectedStaticMethod() + { + } + + /** {@inheritDoc} */ + public static void publicStaticMethod() + { + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInner.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInner.java new file mode 100644 index 000000000..74f8f4526 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputInner.java @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + * Tests having inner types + * @author Oliver Burn + **/ +class InputInner +{ + // Ignore - two errors + class InnerInner2 + { + // Ignore + public int fData; + } + + // Ignore - 2 errors + interface InnerInterface2 + { + // Ignore - should be all upper case + String data = "zxzc"; + + // Ignore + class InnerInterfaceInnerClass + { + // Ignore - need Javadoc and made private + public int rData; + + /** needs to be made private unless allowProtected. */ + protected int protectedVariable; + + /** needs to be made private unless allowPackage. */ + int packageVariable; + } + } + + /** demonstrate bug in handling static final **/ + protected static Object sWeird = new Object(); + /** demonstrate bug in handling static final **/ + static Object sWeird2 = new Object(); + + /** demonstrate bug in local final variable */ + public interface Inter + { + } + + public static void main() + { + Inter m = new Inter() + { + private static final int CDS = 1; + + private int ABC; + }; + } + + /** annotation field incorrectly named. */ + @interface InnerAnnotation + { + /** Ignore - should be all upper case. */ + String data = "zxzc"; + } + + /** enum with public member variable */ + enum InnerEnum + { + /** First constant */ + A, + + /** Second constant */ + B; + + /** Should be private */ + public int someValue; + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadoc.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadoc.java new file mode 100644 index 000000000..9a315f1e6 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadoc.java @@ -0,0 +1,114 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + * Testing author and version tag patterns + **** @author Oliver Burn + * @version 1.0 + */ +class InputJavadoc +{ +} + +/** + * Testing author and version tag patterns (there are not tags :) + * SomeText @author Oliver Burn + * *@version 1.0 + */ +class InputJavadoc1 +{ +} + +/** + * Testing author and version tag patterns. + * tags are multi line ones + * @author Oliver Burn + * @version 1.0 */ +class InputJavadoc2 +{ +} + +//Testing tag on first comment line +/** +* @author ABC +* @version 1.1 +*/ +class InputJavadocType +{ +} + +/** + * Testing author and version tag patterns + **** @author Oliver Burn + * @version 1.0 + */ +enum InputJavadocEnum +{ +} + +/** + * Testing author and version tag patterns (there are not tags :) + * SomeText @author Oliver Burn + * *@version 1.0 + */ +enum InputJavadocEnum1 +{ +} + +/** + * Testing author and version tag patterns. + * tags are multi line ones + * @author Oliver Burn + * @version 1.0 */ +enum InputJavadocEnum2 +{ +} + +//Testing tag on first comment line +/** +* @author ABC +* @version 1.1 +*/ +@interface InputJavadocInterfaceType +{ +} + +/** + * Testing author and version tag patterns + **** @author Oliver Burn + * @version 1.0 + */ +@interface InputJavadocInterface +{ +} + +/** + * Testing author and version tag patterns (there are not tags :) + * SomeText @author Oliver Burn + * *@version 1.0 + */ +@interface InputJavadocInterface1 +{ +} + +/** + * Testing author and version tag patterns. + * tags are multi line ones + * @author Oliver Burn + * @version 1.0 */ +@interface InputJavadocInterface2 +{ +} + +//Testing tag on first comment line +/** +* @author ABC +* @version 1.1 +*/ +@interface InputJavadocInterfaceType1 +{ +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodCheck_SmallMethods.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodCheck_SmallMethods.java new file mode 100644 index 000000000..c319ba696 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodCheck_SmallMethods.java @@ -0,0 +1,102 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + * The following is a bad tag. + * @mytag Hello + */ +public class InputJavadocMethodCheck_SmallMethods extends Some +{ + //with comments + + /** + * Some javadoc. + * @return Some javadoc. + */ + int foo1() + { + return 1; + } + + /** + * Some javadoc. + * @return Some javadoc. + */ + String foo2() + { + return "Fooooooooooooooo" + + "ooooo" + + "ooo"; + } + + /** + * Some javadoc. + */ + void foo3() + { + foo2(); + } + + /** + * Some javadoc. + */ + void foo4() {} + + //without comments + + int foo5() + { + return 1; + } + + String foo6() + { + return "Fooooooooooooooo" + + "oooooooo"; + } + + String foo7() + { + return "Fooooooooooooooo" + + "ooooo" + + "ooo"; + } + + void foo8() + { + foo2(); + } + + void foo9() { + + + + + + } + + @MyAnnotation + String foo10() + { + return "Fooooooooooooooo" + + "ooooo" + + "ooo"; + } + + @Override + protected String foo11() + { + return "Fooooo" + + "ooo" + + "ooooooo" + + "ooooo" + + "ooo"; + } +} + +@interface MyAnnotation {} + +class Some { + protected String foo11() { + return "4"; + } +}
\ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodIgnoreNameRegex.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodIgnoreNameRegex.java new file mode 100644 index 000000000..2e448b696 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputJavadocMethodIgnoreNameRegex.java @@ -0,0 +1,19 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputJavadocMethodIgnoreNameRegex +{ + private void foo() { + + } + + private void foo88() { + + } + + private void foo2() { + int x = 0; + int k = x >> 2; + String s = String.valueOf(k); + boolean b = false; + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputMissingJavadocTags.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputMissingJavadocTags.java new file mode 100644 index 000000000..0392d02e1 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputMissingJavadocTags.java @@ -0,0 +1,64 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputMissingJavadocTags { + /** + * Missing return. + * + * @param number to return + * @throws ThreadDeath sometimes + */ + int missingReturn(int number) throws ThreadDeath { + return number; + } + + /** + * Missing param. + * + * @return number + * @throws ThreadDeath sometimes + */ + int missingParam(int number) throws ThreadDeath { + return number; + } + + /** + * Missing throws. + * + * @param number to return + * @return number + */ + int missingThrows(int number) throws ThreadDeath { + return number; + } + + /** + * Missing return, but {@inheritDoc} is present. + * + * @param number to return + * @throws java.util.NoSuchElementException sometimes + */ + int missingReturnButInheritDocPresent(int number) throws java.util.NoSuchElementException { + return number; + } + + /** + * Missing return in the middle. + * + * @param number to return + * @return + * @throws java.util.NoSuchElementException sometimes + */ + private int missingReturnInTheMiddle(int number) { + return number; + } + + /** + * Missing return at the end. + * + * @param number to return + * @return + */ + private int missingReturnAtTheEnd(int number) { + return number; + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputPublicOnly.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputPublicOnly.java new file mode 100644 index 000000000..f8196cd8c --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputPublicOnly.java @@ -0,0 +1,117 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputPublicOnly // ignore - need javadoc +{ + private interface InnerInterface // ignore - when not relaxed about Javadoc + { + String CONST = "InnerInterface"; // ignore - w.n.r.a.j + void method(); // ignore - when not relaxed about Javadoc + + class InnerInnerClass // ignore - when not relaxed about Javadoc + { + private int mData; // ignore - when not relaxed about Javadoc + + private InnerInnerClass() + { + final Runnable r = new Runnable() { + public void run() {}; + }; + } + + void method2() // ignore - when not relaxed about Javadoc + { + final Runnable r = new Runnable() { + public void run() {}; + }; + } + } + } + + private class InnerClass // ignore + { + private int mDiff; // ignore - when not relaxed about Javadoc + + void method() // ignore - when not relaxed about Javadoc + { + } + } + + private int mSize; // ignore - when not relaxed about Javadoc + int mLen; // ignore - when not relaxed about Javadoc + protected int mDeer; // ignore + public int aFreddo; // ignore + + // ignore - need Javadoc + private InputPublicOnly(int aA) + { + } + + // ignore - need Javadoc when not relaxed + InputPublicOnly(String aA) + { + } + + // ignore - always need javadoc + protected InputPublicOnly(Object aA) + { + } + + // ignore - always need javadoc + public InputPublicOnly(Class<Object> aA) + { + } + + // ignore - when not relaxed about Javadoc + private void method(int aA) + { + } + + // ignore - when not relaxed about Javadoc + void method(Long aA) + { + } + + // ignore - need javadoc + protected void method(Class<Object> aA) + { + } + + // ignore - need javadoc + public void method(StringBuffer aA) + { + } + + + /** + A param tag should not be required here when relaxed about Javadoc. + Writing a little documentation should not be worse than not + writing any documentation at all. + */ + private void method(String aA) + { + } + + /** + This inner class has no author tag, which is OK. + */ + public class InnerWithoutAuthor + { + + } + + /** {@inheritDoc} */ + public String toString() + { + return super.toString(); + } + + @Deprecated @Override + public int hashCode() + { + return super.hashCode(); + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeAnonInner.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeAnonInner.java new file mode 100644 index 000000000..913cf6a92 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeAnonInner.java @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseAdapter; +import javax.swing.JButton; + +/** + * Tests for anonymous inner types + * @author Lars Kühne + **/ +public class InputScopeAnonInner +{ + /** + button. + */ + private JButton mButton = new JButton(); + + /** + anon inner in member variable initialization. + */ + private Runnable mRunnable = new Runnable() { + public void run() // should not have to be documented, class is anon. + { + System.out.println("running"); + } + }; + + /** + anon inner in constructor. + */ + InputScopeAnonInner() + { + mButton.addMouseListener( new MouseAdapter() + { + public void mouseClicked( MouseEvent aEv ) + { + System.out.println("click"); + } + } ); + } + + /** + anon inner in method + */ + public void addInputAnonInner() + { + mButton.addMouseListener( new MouseAdapter() + { + public void mouseClicked( MouseEvent aEv ) + { + System.out.println("click"); + } + } ); + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerClasses.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerClasses.java new file mode 100644 index 000000000..693c8cbc8 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerClasses.java @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + Checks javadoc scoping for inner classes. + + Once the Javadoc Check Scope has been left, + all inner elements should not be reported as error, + even if they belong to the checkscope if isolated. + + @author lkuehne + */ +public class InputScopeInnerClasses +{ + public class InnerPublic + { + protected class InnerProtected + { + class InnerPackage + { + private class InnerPrivate + { + // no javadoc required for package scope + class PrivateHiddenPackage + { + } + + protected class PrivateHiddenProtected + { + } + + public class PrivateHiddenPublic + { + } + } + } + } + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerInterfaces.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerInterfaces.java new file mode 100644 index 000000000..5a30c43cb --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputScopeInnerInterfaces.java @@ -0,0 +1,74 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputScopeInnerInterfaces +{ + // inner interfaces with different scopes + + private interface PrivateInterface + { + public String CA = "CONST A"; + String CB = "CONST b"; + + public void ma(); + void mb(); + } + + interface PackageInnerInterface + { + public String CA = "CONST A"; + String CB = "CONST b"; + + public void ma(); + void mb(); + } + + protected interface ProtectedInnerInterface + { + public String CA = "CONST A"; + String CB = "CONST b"; + + public void ma(); + void mb(); + } + + public interface PublicInnerInterface + { + public String CA = "CONST A"; + String CB = "CONST b"; + + public void ma(); + void mb(); + } + + private + class + MyClass1 { + } + + class + MyClass2 { + } + + private + interface + MyInterface1 { + } + + interface + MyInterface2 { + } + + protected + enum + MyEnum { + } + + private + @interface + MyAnnotation { + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputSetterGetter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputSetterGetter.java new file mode 100644 index 000000000..5cbd1d4bc --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputSetterGetter.java @@ -0,0 +1,77 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class InputSetterGetter +{ + private int mNumber; + + public void setNumber(final int number) + { + mNumber = number; + } + + public int getNumber() + { + return mNumber; + } + + public void setNumber1() + { + mNumber = mNumber; + } + + public void setNumber2(int number) + { + mNumber = number; + firePropertyChanged(); + } + + public void getNumber2() + { + } + + public int getCost1(int forMe) + { + return 666; + } + + public int getCost2() + { + mNumber = 4; + return 666; + } + + public int getCost3() throws Exception + { + return 666; + } + + public boolean isSomething() + { + return false; + } + + private void firePropertyChanged(){} + + Object setObject(Object object) { + return new Object(); + } + + Object getNext() { + throw new UnsupportedOperationException(); + } + + public void setWithoutAssignment(Object object) { + object.notify(); + } + + InputSetterGetter() {} + + public InputSetterGetter(Object object) throws Exception {} + +} + +interface TestInterface { + void setObject(Object object); + + Object getObject(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputTypeParamsTags.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputTypeParamsTags.java new file mode 100644 index 000000000..9715ee939 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputTypeParamsTags.java @@ -0,0 +1,61 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +/** + * Some explanation. + * @param <A> A type param + * @param <B1> Another type param + * @param <D123> The wrong type param + * @author Nobody + * @version 1.0 + */ +public class InputTypeParamsTags<A,B1,C456 extends Comparable> +{ + /** + * Some explanation. + * @param <X> A type param + * @param <Y1> Another type param + * @return a string + */ + public <X, Y1> String doSomething() + { + return null; + } + + /** + * Some explanation. + * @param <BB> The wrong type param + */ + public <Z> void doSomethingElse() + { + } + + /** + * Some explanation. + * @param aAnEl A parameter + * @param <L> A type parameter + */ + public <L> void doSomethingElse2(L aAnEl) + { + } + + /** + * Example inner class. + * @param <A> documented parameter + * @param <C> extra parameter + */ + + public static class InnerClass<A,B> + { + } + + /** + * Some explanation. + * @param <Z The wrong type param + */ + public <Z> void unclosedGenericParam() + { + } +} + +/** @param x */ +class Test {} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputWhitespace.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputWhitespace.java new file mode 100644 index 000000000..d8a01f2cd --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/InputWhitespace.java @@ -0,0 +1,61 @@ +//////////////////////////////////////////////////////////////////////////////// +// Test case file for checkstyle. +// Created: 2001 +//////////////////////////////////////////////////////////////////////////////// +package com . puppycrawl + .tools. + checkstyle.checks.javadoc; + +/** + * Class for testing javadoc issues. + * error missing author tag + **/ +class InputWhitespace +{ + /** another check */ + void donBradman(Runnable aRun) + { + donBradman(new Runnable() { + public void run() { + } + }); + + final Runnable r = new Runnable() { + public void run() { + } + }; + } + + /** bug 806243 (NoWhitespaceBeforeCheck error for anonymous inner class) */ + void bug806243() + { + Object o = new InputWhitespace() { + private int j ; + }; + } +} + +/** + * Bug 806242 (NoWhitespaceBeforeCheck error with an interface). + * @author o_sukhodolsky + * @version 1.0 + */ +interface IFoo +{ + void foo() ; +} + +/** + * Avoid Whitespace errors in for loop. + * @author lkuehne + * @version 1.0 + */ +class SpecialCasesInForLoop +{ + public void myMethod() { + new Thread() { + public void run() { + } + }.start(); + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/TestGenerics.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/TestGenerics.java new file mode 100644 index 000000000..dd3600ac6 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/TestGenerics.java @@ -0,0 +1,68 @@ +package com.puppycrawl.tools.checkstyle.checks.javadoc; + +public class TestGenerics <E extends java.lang.Exception, + RE extends RuntimeException & java.io.Serializable> +{ + /** + * @throws E in some cases + * @throws RE in some cases + */ + public void method1() throws E + { + } + + /** + * RuntimeException is not declared. + */ + public void method2() throws RE + { + } + + /** + * @throws E in some cases + * @throws RE in other cases + */ + public void method3() throws E, RE + { + } + + /** + * @throws RE in some cases + * @throws NPE in some other cases + */ + public <NPE extends NullPointerException> void method4() throws NPE, RE + { + } + + public class InnerClass <RuntimeException extends ClassCastException> + { + /** + * @throws E in some case + * @throws RE in some other cases + */ + public void method1() throws RuntimeException, RE, + java.lang.RuntimeException + { + } + } + + /** + * @param <T> some parameter + * @param <E2> some exception parameter + */ + public interface InnerInterface<T, E2 extends Throwable> { + /** + * Some javadoc. + * @param t a parameter + * @throws E2 in some case. + * @return some string + */ + public abstract String doStuff(T t) throws E2; + } + + /** + * @param <P> some parameter + */ + public interface InvalidParameterInJavadoc<T> {} +} + |