Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added OpenJavaDocCheck library (new BSD licensed) and written a custo…
…m JavaDoc checks. * test if the cdk.module tag has been given in the class JavaDoc. * test if @cdk.bug is followed by an integer * test if the @cdk.githash tag is given Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
- Loading branch information
Showing
6 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/net/sf/cdk/tools/checkdoctest/IncorrectBugNumberTagletTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
package net.sf.cdk.tools.checkdoctest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.sf.cdk.tools.doclets.CDKBugTaglet; | ||
|
||
import com.github.ojdcheck.test.IClassDocTester; | ||
import com.github.ojdcheck.test.ITestReport; | ||
import com.github.ojdcheck.test.TestReport; | ||
import com.sun.javadoc.ClassDoc; | ||
import com.sun.javadoc.MethodDoc; | ||
import com.sun.javadoc.Tag; | ||
|
||
/** | ||
* OpenJavaDocCheck test that tests if the content of the cdk.bug | ||
* tag is a valid integer. | ||
* | ||
* @see CDKBugTaglet | ||
*/ | ||
public class IncorrectBugNumberTagletTest implements IClassDocTester { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getDescription() { | ||
return "Tests if the @cdk.bug content is a valid number."; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getName() { | ||
return "CDK Bug Taglet Number Test"; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public List<ITestReport> test(ClassDoc classDoc) { | ||
List<ITestReport> reports = new ArrayList<ITestReport>(); | ||
Tag[] tags = classDoc.tags("cdk.bug"); | ||
for (Tag tag : tags) { | ||
try { | ||
Integer.valueOf(tag.text()); | ||
} catch (NumberFormatException exception) { | ||
reports.add( | ||
new TestReport( | ||
this, classDoc, | ||
"Invalid integer given as bug number in @cdk.bug tag.", | ||
tag.position().line(), null | ||
) | ||
); | ||
} | ||
} | ||
MethodDoc[] methodDocs = classDoc.methods(); | ||
for (MethodDoc methodDoc : methodDocs) { | ||
tags = methodDoc.tags("cdk.bug"); | ||
for (Tag tag : tags) { | ||
try { | ||
Integer.valueOf(tag.text()); | ||
} catch (NumberFormatException exception) { | ||
reports.add( | ||
new TestReport( | ||
this, classDoc, | ||
"Invalid integer given as bug number in @cdk.bug tag.", | ||
tag.position().line(), null | ||
) | ||
); | ||
} | ||
} | ||
} | ||
return reports; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Priority getPriority() { | ||
return Priority.ERROR; | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
src/main/net/sf/cdk/tools/checkdoctest/MissingGithashTagletTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
package net.sf.cdk.tools.checkdoctest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.sf.cdk.tools.doclets.CDKGitTaglet; | ||
|
||
import com.github.ojdcheck.test.IClassDocTester; | ||
import com.github.ojdcheck.test.ITestReport; | ||
import com.github.ojdcheck.test.TestReport; | ||
import com.sun.javadoc.ClassDoc; | ||
import com.sun.javadoc.Tag; | ||
|
||
/** | ||
* OpenJavaDocCheck test that warns about missing cdk.githash tags. | ||
* | ||
* @see CDKGitTaglet | ||
*/ | ||
public class MissingGithashTagletTest implements IClassDocTester { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public String getDescription() { | ||
return "Tests if the @cdk.githash tag is given."; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public String getName() { | ||
return "CDK Githash Taglet Test"; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public List<ITestReport> test(ClassDoc classDoc) { | ||
List<ITestReport> reports = new ArrayList<ITestReport>(); | ||
Tag[] tags = classDoc.tags("cdk.githash"); | ||
if (tags.length == 0) { | ||
reports.add( | ||
new TestReport( | ||
this, classDoc, | ||
"Missing @cdk.githash tag.", | ||
classDoc.position().line(), null | ||
) | ||
); | ||
} | ||
return reports; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public Priority getPriority() { | ||
return Priority.MINOR_ERROR; | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
src/main/net/sf/cdk/tools/checkdoctest/MissingModuleTagletTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
package net.sf.cdk.tools.checkdoctest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.sf.cdk.tools.doclets.CDKModuleTaglet; | ||
|
||
import com.github.ojdcheck.test.IClassDocTester; | ||
import com.github.ojdcheck.test.ITestReport; | ||
import com.github.ojdcheck.test.TestReport; | ||
import com.sun.javadoc.ClassDoc; | ||
import com.sun.javadoc.Tag; | ||
|
||
/** | ||
* OpenJavaDocCheck test that warns of a class JavaDoc does not contain | ||
* the cdk.module tag needed by the build system. | ||
* | ||
* @see CDKModuleTaglet | ||
*/ | ||
public class MissingModuleTagletTest implements IClassDocTester { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getDescription() { | ||
return "Tests the content of the module taglet content."; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getName() { | ||
return "CDK Module Taglet Test"; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public List<ITestReport> test(ClassDoc classDoc) { | ||
List<ITestReport> reports = new ArrayList<ITestReport>(); | ||
Tag[] tags = classDoc.tags("cdk.module"); | ||
if (tags.length == 0) { | ||
reports.add( | ||
new TestReport( | ||
this, classDoc, | ||
"Missing @cdk.module tag.", | ||
classDoc.position().line(), null | ||
) | ||
); | ||
} | ||
return reports; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Priority getPriority() { | ||
return Priority.WARNING; | ||
} | ||
|
||
} |