Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #1004: Enforce since tag in inner classes #1013

Merged
merged 1 commit into from Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -63,10 +63,6 @@
*
* @see <a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html">Keywords substitution in Subversion</a>
* @since 0.3
* @todo #743:30min Nested classes should have since tag. Implement check to
* validate if nested classes javadoc have a valid since tag. After the
* implementation add JavadocTagsCheck to checks.xml and ChecksTest (removed
* because now the test fails).
*/
public final class JavadocTagsCheck extends AbstractCheck {

Expand Down Expand Up @@ -111,21 +107,19 @@ public void init() {

@Override
public void visitToken(final DetailAST ast) {
if (ast.getParent() == null) {
final String[] lines = this.getLines();
final int start = ast.getLineNo();
final int cstart = JavadocTagsCheck.findCommentStart(lines, start);
final int cend = JavadocTagsCheck.findCommentEnd(lines, start);
if (cend > cstart && cstart >= 0) {
for (final String tag : this.prohibited) {
this.findProhibited(lines, start, cstart, cend, tag);
}
for (final String tag : this.tags.keySet()) {
this.matchTagFormat(lines, cstart, cend, tag);
}
} else {
this.log(0, "Problem finding class/interface comment");
final String[] lines = this.getLines();
final int start = ast.getLineNo();
final int cstart = JavadocTagsCheck.findCommentStart(lines, start);
final int cend = JavadocTagsCheck.findCommentEnd(lines, start);
if (cend > cstart && cstart >= 0) {
for (final String tag : this.prohibited) {
this.findProhibited(lines, start, cstart, cend, tag);
}
for (final String tag : this.tags.keySet()) {
this.matchTagFormat(lines, cstart, cend, tag);
}
} else {
this.log(0, "Problem finding class/interface comment");
}
}

Expand Down Expand Up @@ -252,7 +246,7 @@ private List<Integer> findTagLineNum(final String[] lines, final int start,
for (int pos = start; pos <= end; pos += 1) {
final String line = lines[pos];
if (line.contains(String.format("@%s ", tag))) {
if (!line.startsWith(prefix)) {
if (!line.trim().startsWith(prefix.trim())) {
this.log(
start + pos + 1,
"Line with ''@{0}'' does not start with a ''{1}''",
Expand Down
Expand Up @@ -418,6 +418,7 @@
<module name="com.qulice.checkstyle.FinalSemicolonInTryWithResourcesCheck"/>
<module name="com.qulice.checkstyle.JavadocEmptyLineCheck"/>
<module name="com.qulice.checkstyle.DiamondOperatorCheck"/>
<module name="com.qulice.checkstyle.JavadocTagsCheck"/>
</module>

<!--
Expand Down
Expand Up @@ -79,6 +79,7 @@ public final class ChecksTest {
"NonStaticMethodCheck",
"ConstantUsageCheck",
"JavadocEmptyLineCheck",
"JavadocTagsCheck",
};

/**
Expand Down
Expand Up @@ -24,6 +24,7 @@ public final String UPPERCASE() {

/**
* ValidInnerHtml example class having the abbreviation in camelcase.
* @since 1.0
*/
public class ValidInnerHtml {
}
Expand Down
Expand Up @@ -10,6 +10,7 @@
public class ValidAbbreviationAsWordInNameIT {
/**
* Valid name on inner class, because the IT abbreviation is allowed.
* @since 1.0
*/
class ValidInnerIT {
}
Expand Down
Expand Up @@ -35,12 +35,14 @@ public static void innerClassUsage() {

/**
* Simple interface, used as wrapper.
* @since 1.0
*/
interface SimpleInterface {

/**
* Inner class with generic parameter.
* @param <E> generic parameter
* @since 1.0
*/
final class InnerClass<E> implements SimpleInterface {

Expand Down