From 8e913308176b8ec6f141c587797be1f1507d8a3b Mon Sep 17 00:00:00 2001 From: wltan <53135010+wltan@users.noreply.github.com> Date: Sat, 9 May 2020 14:39:21 +0800 Subject: [PATCH] Add pitest report --- .../BlockTagUtil.java.html | 1684 ++ .../InlineTagUtil.java.html | 2538 ++ .../TagInfo.java.html | 1389 + .../index.html | 69 + .../AbstractJavadocCheck.java.html | 7038 +++++ .../AtclauseOrderCheck.java.html | 3468 +++ .../HtmlTag.java.html | 2393 ++ .../InvalidJavadocPositionCheck.java.html | 1672 ++ .../InvalidJavadocTag.java.html | 1209 + .../JavadocBlockTagLocationCheck.java.html | 3681 +++ .../JavadocContentLocationCheck.java.html | 3985 +++ .../JavadocMethodCheck.java.html | 23496 ++++++++++++++++ ...singWhitespaceAfterAsteriskCheck.java.html | 2487 ++ .../JavadocNodeImpl.java.html | 3020 ++ .../JavadocPackageCheck.java.html | 2267 ++ .../JavadocParagraphCheck.java.html | 5005 ++++ .../JavadocStyleCheck.java.html | 12788 +++++++++ .../JavadocTag.java.html | 2741 ++ ...cTagContinuationIndentationCheck.java.html | 3350 +++ .../JavadocTagInfo.java.html | 9160 ++++++ .../JavadocTags.java.html | 1133 + .../JavadocTypeCheck.java.html | 8079 ++++++ .../JavadocVariableCheck.java.html | 3463 +++ .../MissingJavadocMethodCheck.java.html | 7368 +++++ .../MissingJavadocPackageCheck.java.html | 2478 ++ .../MissingJavadocTypeCheck.java.html | 3985 +++ ...NonEmptyAtclauseDescriptionCheck.java.html | 1767 ++ .../SingleLineJavadocCheck.java.html | 3112 ++ .../SummaryJavadocCheck.java.html | 5954 ++++ .../TagParser.java.html | 5709 ++++ .../WriteTagCheck.java.html | 3923 +++ .../index.html | 213 + .../pitest-abstractjavadoccheck/index.html | 66 + .../pitest-abstractjavadoccheck/style.css | 563 + 34 files changed, 141253 insertions(+) create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/BlockTagUtil.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/InlineTagUtil.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/TagInfo.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/index.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/AbstractJavadocCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/AtclauseOrderCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/HtmlTag.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/InvalidJavadocPositionCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/InvalidJavadocTag.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocBlockTagLocationCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocContentLocationCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocMethodCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocMissingWhitespaceAfterAsteriskCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocNodeImpl.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocPackageCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocParagraphCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocStyleCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocTag.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocTagContinuationIndentationCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocTagInfo.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocTags.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocTypeCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/JavadocVariableCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/MissingJavadocMethodCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/MissingJavadocPackageCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/MissingJavadocTypeCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/NonEmptyAtclauseDescriptionCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/SingleLineJavadocCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/SummaryJavadocCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/TagParser.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/WriteTagCheck.java.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc/index.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/index.html create mode 100644 2020-05-09/pitest-abstractjavadoccheck/style.css diff --git a/2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/BlockTagUtil.java.html b/2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/BlockTagUtil.java.html new file mode 100644 index 00000000..3ecf3b1d --- /dev/null +++ b/2020-05-09/pitest-abstractjavadoccheck/com.puppycrawl.tools.checkstyle.checks.javadoc.utils/BlockTagUtil.java.html @@ -0,0 +1,1684 @@ + + +
+ + + + + ++ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc.utils; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.List; |
+ +24 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +25 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.LineColumn; |
+ +28 + | ++ + + + + + | +|
+ +29 + | ++ + + + + + | +/** |
+ +30 + | ++ + + + + + | + * Tools for parsing block tags from a Javadoc comment. |
+ +31 + | ++ + + + + + | + * |
+ +32 + | ++ + + + + + | + */ |
+ +33 + | ++ + + + + + | +public final class BlockTagUtil { |
+ +34 + | ++ + + + + + | +|
+ +35 + | ++ + + + + + | + /** Block tag pattern for a first line. */ |
+ +36 + | ++ + + + + + | + private static final Pattern BLOCK_TAG_PATTERN_FIRST_LINE = Pattern.compile( |
+ +37 + | ++ + + + + + | + "/\\*{2,}\\s*@(\\p{Alpha}+)\\s"); |
+ +38 + | ++ + + + + + | +|
+ +39 + | ++ + + + + + | + /** Block tag pattern. */ |
+ +40 + | ++ + + + + + | + private static final Pattern BLOCK_TAG_PATTERN = Pattern.compile( |
+ +41 + | ++ + + + + + | + "^\\s*\\**\\s*@(\\p{Alpha}+)\\s"); |
+ +42 + | ++ + + + + + | +|
+ +43 + | ++ + + + + + | + /** Closing tag. */ |
+ +44 + | ++ + + + + + | + private static final String JAVADOC_CLOSING_TAG = "*/"; |
+ +45 + | ++ + + + + + | +|
+ +46 + | ++ + + + + + | + /** Prevent instantiation. */ |
+ +47 + | ++ + + + + + | + private BlockTagUtil() { |
+ +48 + | ++ + + + + + | + } |
+ +49 + | ++ + + + + + | +|
+ +50 + | ++ + + + + + | + /** |
+ +51 + | ++ + + + + + | + * Extract the block tags from a Javadoc comment. |
+ +52 + | ++ + + + + + | + * |
+ +53 + | ++ + + + + + | + * @param lines The text of the comment, as separate lines. |
+ +54 + | ++ + + + + + | + * @return The tags extracted from the block. |
+ +55 + | ++ + + + + + | + */ |
+ +56 + | ++ + + + + + | + public static List<TagInfo> extractBlockTags(String... lines) { |
+ +57 + | +
+
+1
+
+
+1. extractBlockTags : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<TagInfo> tags = new ArrayList<>(); |
+ +58 + | ++ + + + + + | +|
+ +59 + | +
+
+3
+
+
+1. extractBlockTags : changed conditional boundary → KILLED + +2. extractBlockTags : Changed increment from 1 to -1 → KILLED + +3. extractBlockTags : negated conditional → KILLED + + + + |
+ for (int i = 0; i < lines.length; i++) { |
+ +60 + | ++ + + + + + | + // Starting lines of a comment have a different first line pattern. |
+ +61 + | +
+
+1
+
+
+1. extractBlockTags : negated conditional → KILLED + + + + |
+ final boolean isFirstLine = i == 0; |
+ +62 + | ++ + + + + + | + final Pattern pattern; |
+ +63 + | +
+
+1
+
+
+1. extractBlockTags : negated conditional → KILLED + + + + |
+ if (isFirstLine) { |
+ +64 + | ++ + + + + + | + pattern = BLOCK_TAG_PATTERN_FIRST_LINE; |
+ +65 + | ++ + + + + + | + } |
+ +66 + | ++ + + + + + | + else { |
+ +67 + | ++ + + + + + | + pattern = BLOCK_TAG_PATTERN; |
+ +68 + | ++ + + + + + | + } |
+ +69 + | ++ + + + + + | +|
+ +70 + | ++ + + + + + | + final String line = lines[i]; |
+ +71 + | ++ + + + + + | + final Matcher tagMatcher = pattern.matcher(line); |
+ +72 + | ++ + + + + + | +|
+ +73 + | +
+
+1
+
+
+1. extractBlockTags : negated conditional → KILLED + + + + |
+ if (tagMatcher.find()) { |
+ +74 + | ++ + + + + + | + final String tagName = tagMatcher.group(1); |
+ +75 + | ++ + + + + + | +|
+ +76 + | ++ + + + + + | + // offset of one for the @ character |
+ +77 + | +
+
+1
+
+
+1. extractBlockTags : Replaced integer subtraction with addition → KILLED + + + + |
+ final int colNum = tagMatcher.start(1) - 1; |
+ +78 + | +
+
+1
+
+
+1. extractBlockTags : Replaced integer addition with subtraction → KILLED + + + + |
+ final int lineNum = i + 1; |
+ +79 + | ++ + + + + + | +|
+ +80 + | ++ + + + + + | + final String remainder = line.substring(tagMatcher.end(1)); |
+ +81 + | ++ + + + + + | + String tagValue = remainder.trim(); |
+ +82 + | ++ + + + + + | +|
+ +83 + | ++ + + + + + | + // Handle the case where we're on the last line of a Javadoc comment. |
+ +84 + | +
+
+1
+
+
+1. extractBlockTags : negated conditional → KILLED + + + + |
+ if (tagValue.endsWith(JAVADOC_CLOSING_TAG)) { |
+ +85 + | +
+
+1
+
+
+1. extractBlockTags : Replaced integer subtraction with addition → KILLED + + + + |
+ final int endIndex = tagValue.length() - JAVADOC_CLOSING_TAG.length(); |
+ +86 + | ++ + + + + + | + tagValue = tagValue.substring(0, endIndex).trim(); |
+ +87 + | ++ + + + + + | + } |
+ +88 + | ++ + + + + + | +|
+ +89 + | +
+
+1
+
+
+1. extractBlockTags : removed call to com/puppycrawl/tools/checkstyle/api/LineColumn::<init> → KILLED + + + + |
+ final LineColumn position = new LineColumn(lineNum, colNum); |
+ +90 + | +
+
+1
+
+
+1. extractBlockTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/utils/TagInfo::<init> → KILLED + + + + |
+ tags.add(new TagInfo(tagName, tagValue, position)); |
+ +91 + | ++ + + + + + | + } |
+ +92 + | ++ + + + + + | + } |
+ +93 + | ++ + + + + + | +|
+ +94 + | +
+
+1
+
+
+1. extractBlockTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/BlockTagUtil::extractBlockTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags; |
+ +95 + | ++ + + + + + | + } |
+ +96 + | ++ + + + + + | +|
+ +97 + | ++ + + + + + | +} |
Mutations | ||
57 | ++ |
+
+
+
+ 1.1 |
+
59 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
61 | ++ |
+
+
+
+ 1.1 |
+
63 | ++ |
+
+
+
+ 1.1 |
+
73 | ++ |
+
+
+
+ 1.1 |
+
77 | ++ |
+
+
+
+ 1.1 |
+
78 | ++ |
+
+
+
+ 1.1 |
+
84 | ++ |
+
+
+
+ 1.1 |
+
85 | ++ |
+
+
+
+ 1.1 |
+
89 | ++ |
+
+
+
+ 1.1 |
+
90 | ++ |
+
+
+
+ 1.1 |
+
94 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc.utils; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.List; |
+ +24 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +25 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.LineColumn; |
+ +28 + | ++ + + + + + | +|
+ +29 + | ++ + + + + + | +/** |
+ +30 + | ++ + + + + + | + * Tools for extracting inline tags from Javadoc comments. |
+ +31 + | ++ + + + + + | + * |
+ +32 + | ++ + + + + + | + */ |
+ +33 + | ++ + + + + + | +public final class InlineTagUtil { |
+ +34 + | ++ + + + + + | +|
+ +35 + | ++ + + + + + | + /** |
+ +36 + | ++ + + + + + | + * Inline tag pattern. |
+ +37 + | ++ + + + + + | + */ |
+ +38 + | ++ + + + + + | + private static final Pattern INLINE_TAG_PATTERN = Pattern.compile( |
+ +39 + | ++ + + + + + | + "\\{@(\\p{Alpha}+)\\b(.*?)}", Pattern.DOTALL); |
+ +40 + | ++ + + + + + | +|
+ +41 + | ++ + + + + + | + /** Pattern to recognize leading "*" characters in Javadoc. */ |
+ +42 + | ++ + + + + + | + private static final Pattern JAVADOC_PREFIX_PATTERN = Pattern.compile( |
+ +43 + | ++ + + + + + | + "^\\s*\\*", Pattern.MULTILINE); |
+ +44 + | ++ + + + + + | +|
+ +45 + | ++ + + + + + | + /** Pattern matching whitespace, used by {@link InlineTagUtil#collapseWhitespace(String)}. */ |
+ +46 + | ++ + + + + + | + private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\s+"); |
+ +47 + | ++ + + + + + | +|
+ +48 + | ++ + + + + + | + /** Pattern matching a newline. */ |
+ +49 + | ++ + + + + + | + private static final Pattern NEWLINE_PATTERN = Pattern.compile("\\n"); |
+ +50 + | ++ + + + + + | +|
+ +51 + | ++ + + + + + | + /** Line feed character. */ |
+ +52 + | ++ + + + + + | + private static final String LINE_FEED = "\n"; |
+ +53 + | ++ + + + + + | +|
+ +54 + | ++ + + + + + | + /** Carriage return character. */ |
+ +55 + | ++ + + + + + | + private static final String CARRIAGE_RETURN = "\r"; |
+ +56 + | ++ + + + + + | +|
+ +57 + | ++ + + + + + | + /** Prevent instantiation. */ |
+ +58 + | ++ + + + + + | + private InlineTagUtil() { |
+ +59 + | ++ + + + + + | + } |
+ +60 + | ++ + + + + + | +|
+ +61 + | ++ + + + + + | + /** |
+ +62 + | ++ + + + + + | + * Extract inline Javadoc tags from the given comment. |
+ +63 + | ++ + + + + + | + * |
+ +64 + | ++ + + + + + | + * @param lines The Javadoc comment (as lines). |
+ +65 + | ++ + + + + + | + * @return The extracted inline Javadoc tags. |
+ +66 + | ++ + + + + + | + * @throws IllegalArgumentException when comment lines contain newlines |
+ +67 + | ++ + + + + + | + */ |
+ +68 + | ++ + + + + + | + public static List<TagInfo> extractInlineTags(String... lines) { |
+ +69 + | ++ + + + + + | + for (String line : lines) { |
+ +70 + | +
+
+2
+
+
+1. extractInlineTags : negated conditional → KILLED + +2. extractInlineTags : negated conditional → KILLED + + + + |
+ if (line.contains(LINE_FEED) || line.contains(CARRIAGE_RETURN)) { |
+ +71 + | +
+
+1
+
+
+1. extractInlineTags : removed call to java/lang/IllegalArgumentException::<init> → KILLED + + + + |
+ throw new IllegalArgumentException("comment lines cannot contain newlines"); |
+ +72 + | ++ + + + + + | + } |
+ +73 + | ++ + + + + + | + } |
+ +74 + | ++ + + + + + | +|
+ +75 + | ++ + + + + + | + final String commentText = convertLinesToString(lines); |
+ +76 + | ++ + + + + + | + final Matcher inlineTagMatcher = INLINE_TAG_PATTERN.matcher(commentText); |
+ +77 + | ++ + + + + + | +|
+ +78 + | +
+
+1
+
+
+1. extractInlineTags : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<TagInfo> tags = new ArrayList<>(); |
+ +79 + | ++ + + + + + | +|
+ +80 + | +
+
+1
+
+
+1. extractInlineTags : negated conditional → KILLED + + + + |
+ while (inlineTagMatcher.find()) { |
+ +81 + | ++ + + + + + | + final String tagName = inlineTagMatcher.group(1); |
+ +82 + | ++ + + + + + | +|
+ +83 + | ++ + + + + + | + // Remove the leading asterisks (in case the tag spans a line) and collapse |
+ +84 + | ++ + + + + + | + // the whitespace. |
+ +85 + | ++ + + + + + | + String matchedTagValue = inlineTagMatcher.group(2); |
+ +86 + | ++ + + + + + | + matchedTagValue = removeLeadingJavaDoc(matchedTagValue); |
+ +87 + | ++ + + + + + | + matchedTagValue = collapseWhitespace(matchedTagValue); |
+ +88 + | ++ + + + + + | +|
+ +89 + | ++ + + + + + | + final String tagValue = matchedTagValue; |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + final int startIndex = inlineTagMatcher.start(1); |
+ +92 + | +
+
+1
+
+
+1. extractInlineTags : Replaced integer subtraction with addition → KILLED + + + + |
+ final LineColumn position = getLineColumnOfIndex(commentText, |
+ +93 + | ++ + + + + + | + // correct start index offset |
+ +94 + | ++ + + + + + | + startIndex - 1); |
+ +95 + | ++ + + + + + | +|
+ +96 + | +
+
+1
+
+
+1. extractInlineTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/utils/TagInfo::<init> → KILLED + + + + |
+ tags.add(new TagInfo(tagName, tagValue, position)); |
+ +97 + | ++ + + + + + | + } |
+ +98 + | ++ + + + + + | +|
+ +99 + | +
+
+1
+
+
+1. extractInlineTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtil::extractInlineTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags; |
+ +100 + | ++ + + + + + | + } |
+ +101 + | ++ + + + + + | +|
+ +102 + | ++ + + + + + | + /** |
+ +103 + | ++ + + + + + | + * Convert array of string to single String. |
+ +104 + | ++ + + + + + | + * |
+ +105 + | ++ + + + + + | + * @param lines A number of lines, in order. |
+ +106 + | ++ + + + + + | + * @return The lines, joined together with newlines, as a single string. |
+ +107 + | ++ + + + + + | + */ |
+ +108 + | ++ + + + + + | + private static String convertLinesToString(String... lines) { |
+ +109 + | +
+
+1
+
+
+1. convertLinesToString : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder builder = new StringBuilder(1024); |
+ +110 + | ++ + + + + + | + for (String line : lines) { |
+ +111 + | ++ + + + + + | + builder.append(line); |
+ +112 + | ++ + + + + + | + builder.append(LINE_FEED); |
+ +113 + | ++ + + + + + | + } |
+ +114 + | +
+
+1
+
+
+1. convertLinesToString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtil::convertLinesToString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return builder.toString(); |
+ +115 + | ++ + + + + + | + } |
+ +116 + | ++ + + + + + | +|
+ +117 + | ++ + + + + + | + /** |
+ +118 + | ++ + + + + + | + * Get LineColumn from string till index. |
+ +119 + | ++ + + + + + | + * |
+ +120 + | ++ + + + + + | + * @param source Source string. |
+ +121 + | ++ + + + + + | + * @param index An index into the string. |
+ +122 + | ++ + + + + + | + * @return A position in the source representing what line and column that index appears on. |
+ +123 + | ++ + + + + + | + */ |
+ +124 + | ++ + + + + + | + private static LineColumn getLineColumnOfIndex(String source, int index) { |
+ +125 + | ++ + + + + + | + final String precedingText = source.subSequence(0, index).toString(); |
+ +126 + | ++ + + + + + | + final String[] precedingLines = NEWLINE_PATTERN.split(precedingText); |
+ +127 + | +
+
+1
+
+
+1. getLineColumnOfIndex : Replaced integer subtraction with addition → KILLED + + + + |
+ final String lastLine = precedingLines[precedingLines.length - 1]; |
+ +128 + | +
+
+2
+
+
+1. getLineColumnOfIndex : removed call to com/puppycrawl/tools/checkstyle/api/LineColumn::<init> → KILLED + +2. getLineColumnOfIndex : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtil::getLineColumnOfIndex to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new LineColumn(precedingLines.length, lastLine.length()); |
+ +129 + | ++ + + + + + | + } |
+ +130 + | ++ + + + + + | +|
+ +131 + | ++ + + + + + | + /** |
+ +132 + | ++ + + + + + | + * Collapse whitespaces. |
+ +133 + | ++ + + + + + | + * |
+ +134 + | ++ + + + + + | + * @param str Source string. |
+ +135 + | ++ + + + + + | + * @return The given string with all whitespace collapsed. |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + private static String collapseWhitespace(String str) { |
+ +138 + | ++ + + + + + | + final Matcher matcher = WHITESPACE_PATTERN.matcher(str); |
+ +139 + | +
+
+1
+
+
+1. collapseWhitespace : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtil::collapseWhitespace to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return matcher.replaceAll(" ").trim(); |
+ +140 + | ++ + + + + + | + } |
+ +141 + | ++ + + + + + | +|
+ +142 + | ++ + + + + + | + /** |
+ +143 + | ++ + + + + + | + * Remove leading JavaDoc. |
+ +144 + | ++ + + + + + | + * |
+ +145 + | ++ + + + + + | + * @param source A string to remove leading Javadoc from. |
+ +146 + | ++ + + + + + | + * @return The given string with leading Javadoc "*" characters from each line removed. |
+ +147 + | ++ + + + + + | + */ |
+ +148 + | ++ + + + + + | + private static String removeLeadingJavaDoc(String source) { |
+ +149 + | ++ + + + + + | + final Matcher matcher = JAVADOC_PREFIX_PATTERN.matcher(source); |
+ +150 + | +
+
+1
+
+
+1. removeLeadingJavaDoc : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtil::removeLeadingJavaDoc to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return matcher.replaceAll(""); |
+ +151 + | ++ + + + + + | + } |
+ +152 + | ++ + + + + + | +|
+ +153 + | ++ + + + + + | +} |
Mutations | ||
70 | ++ |
+
+
+
+ 1.1 2.2 |
+
71 | ++ |
+
+
+
+ 1.1 |
+
78 | ++ |
+
+
+
+ 1.1 |
+
80 | ++ |
+
+
+
+ 1.1 |
+
92 | ++ |
+
+
+
+ 1.1 |
+
96 | ++ |
+
+
+
+ 1.1 |
+
99 | ++ |
+
+
+
+ 1.1 |
+
109 | ++ |
+
+
+
+ 1.1 |
+
114 | ++ |
+
+
+
+ 1.1 |
+
127 | ++ |
+
+
+
+ 1.1 |
+
128 | ++ |
+
+
+
+ 1.1 2.2 |
+
139 | ++ |
+
+
+
+ 1.1 |
+
150 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc.utils; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.LineColumn; |
+ +23 + | ++ + + + + + | +|
+ +24 + | ++ + + + + + | +/** |
+ +25 + | ++ + + + + + | + * Value object for storing data about a parsed tag. |
+ +26 + | ++ + + + + + | + * |
+ +27 + | ++ + + + + + | + */ |
+ +28 + | ++ + + + + + | +public final class TagInfo { |
+ +29 + | ++ + + + + + | +|
+ +30 + | ++ + + + + + | + /** |
+ +31 + | ++ + + + + + | + * Name of the tag ("link", "see", etc). |
+ +32 + | ++ + + + + + | + */ |
+ +33 + | ++ + + + + + | + private final String name; |
+ +34 + | ++ + + + + + | +|
+ +35 + | ++ + + + + + | + /** |
+ +36 + | ++ + + + + + | + * Value of the tag. |
+ +37 + | ++ + + + + + | + */ |
+ +38 + | ++ + + + + + | + private final String value; |
+ +39 + | ++ + + + + + | +|
+ +40 + | ++ + + + + + | + /** |
+ +41 + | ++ + + + + + | + * Position of the tag in the given comment. |
+ +42 + | ++ + + + + + | + */ |
+ +43 + | ++ + + + + + | + private final LineColumn position; |
+ +44 + | ++ + + + + + | +|
+ +45 + | ++ + + + + + | + /** |
+ +46 + | ++ + + + + + | + * Constructor. |
+ +47 + | ++ + + + + + | + * |
+ +48 + | ++ + + + + + | + * @param name The name of the tag. |
+ +49 + | ++ + + + + + | + * @param value The value of the tag. |
+ +50 + | ++ + + + + + | + * @param position The position of the tag in the comment. |
+ +51 + | ++ + + + + + | + */ |
+ +52 + | ++ + + + + + | + public TagInfo(String name, String value, LineColumn position) { |
+ +53 + | ++ + + + + + | + this.name = name; |
+ +54 + | ++ + + + + + | + this.value = value; |
+ +55 + | ++ + + + + + | + this.position = position; |
+ +56 + | ++ + + + + + | + } |
+ +57 + | ++ + + + + + | +|
+ +58 + | ++ + + + + + | + /** |
+ +59 + | ++ + + + + + | + * Return name of tag. |
+ +60 + | ++ + + + + + | + * |
+ +61 + | ++ + + + + + | + * @return Name of the tag. |
+ +62 + | ++ + + + + + | + */ |
+ +63 + | ++ + + + + + | + public String getName() { |
+ +64 + | +
+
+1
+
+
+1. getName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/TagInfo::getName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return name; |
+ +65 + | ++ + + + + + | + } |
+ +66 + | ++ + + + + + | +|
+ +67 + | ++ + + + + + | + /** |
+ +68 + | ++ + + + + + | + * Return value of tag. |
+ +69 + | ++ + + + + + | + * |
+ +70 + | ++ + + + + + | + * @return Value of the tag. |
+ +71 + | ++ + + + + + | + */ |
+ +72 + | ++ + + + + + | + public String getValue() { |
+ +73 + | +
+
+1
+
+
+1. getValue : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/TagInfo::getValue to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return value; |
+ +74 + | ++ + + + + + | + } |
+ +75 + | ++ + + + + + | +|
+ +76 + | ++ + + + + + | + /** |
+ +77 + | ++ + + + + + | + * Return position of tag. |
+ +78 + | ++ + + + + + | + * |
+ +79 + | ++ + + + + + | + * @return Value of the tag. |
+ +80 + | ++ + + + + + | + */ |
+ +81 + | ++ + + + + + | + public LineColumn getPosition() { |
+ +82 + | +
+
+1
+
+
+1. getPosition : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/utils/TagInfo::getPosition to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return position; |
+ +83 + | ++ + + + + + | + } |
+ +84 + | ++ + + + + + | +|
+ +85 + | ++ + + + + + | +} |
+ +86 + | ++ + + + + + | +|
Mutations | ||
64 | ++ |
+
+
+
+ 1.1 |
+
73 | ++ |
+
+
+
+ 1.1 |
+
82 | ++ |
+
+
+
+ 1.1 |
+
Number of Classes | +Line Coverage | +Mutation Coverage | +
---|---|---|
3 | +100% | +100% | +
Name | +Line Coverage | +Mutation Coverage | +
---|---|---|
BlockTagUtil.java | +100% |
+ 100% |
+
InlineTagUtil.java | +100% |
+ 100% |
+
TagInfo.java | +100% |
+ 100% |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.HashMap; |
+ +24 + | ++ + + + + + | +import java.util.HashSet; |
+ +25 + | ++ + + + + + | +import java.util.Locale; |
+ +26 + | ++ + + + + + | +import java.util.Map; |
+ +27 + | ++ + + + + + | +import java.util.Set; |
+ +28 + | ++ + + + + + | +import java.util.stream.Collectors; |
+ +29 + | ++ + + + + + | +|
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus; |
+ +33 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +34 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +35 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +36 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +37 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +38 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +39 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +40 + | ++ + + + + + | +|
+ +41 + | ++ + + + + + | +/** |
+ +42 + | ++ + + + + + | + * Base class for Checks that process Javadoc comments. |
+ +43 + | ++ + + + + + | + * |
+ +44 + | ++ + + + + + | + * @noinspection NoopMethodInAbstractClass |
+ +45 + | ++ + + + + + | + */ |
+ +46 + | ++ + + + + + | +public abstract class AbstractJavadocCheck extends AbstractCheck { |
+ +47 + | ++ + + + + + | +|
+ +48 + | ++ + + + + + | + /** |
+ +49 + | ++ + + + + + | + * Message key of error message. Missed close HTML tag breaks structure |
+ +50 + | ++ + + + + + | + * of parse tree, so parser stops parsing and generates such error |
+ +51 + | ++ + + + + + | + * message. This case is special because parser prints error like |
+ +52 + | ++ + + + + + | + * {@code "no viable alternative at input 'b \n *\n'"} and it is not |
+ +53 + | ++ + + + + + | + * clear that error is about missed close HTML tag. |
+ +54 + | ++ + + + + + | + */ |
+ +55 + | ++ + + + + + | + public static final String MSG_JAVADOC_MISSED_HTML_CLOSE = |
+ +56 + | ++ + + + + + | + JavadocDetailNodeParser.MSG_JAVADOC_MISSED_HTML_CLOSE; |
+ +57 + | ++ + + + + + | +|
+ +58 + | ++ + + + + + | + /** |
+ +59 + | ++ + + + + + | + * Message key of error message. |
+ +60 + | ++ + + + + + | + */ |
+ +61 + | ++ + + + + + | + public static final String MSG_JAVADOC_WRONG_SINGLETON_TAG = |
+ +62 + | ++ + + + + + | + JavadocDetailNodeParser.MSG_JAVADOC_WRONG_SINGLETON_TAG; |
+ +63 + | ++ + + + + + | +|
+ +64 + | ++ + + + + + | + /** |
+ +65 + | ++ + + + + + | + * Parse error while rule recognition. |
+ +66 + | ++ + + + + + | + */ |
+ +67 + | ++ + + + + + | + public static final String MSG_JAVADOC_PARSE_RULE_ERROR = |
+ +68 + | ++ + + + + + | + JavadocDetailNodeParser.MSG_JAVADOC_PARSE_RULE_ERROR; |
+ +69 + | ++ + + + + + | +|
+ +70 + | ++ + + + + + | + /** |
+ +71 + | ++ + + + + + | + * Key is "line:column". Value is {@link DetailNode} tree. Map is stored in {@link ThreadLocal} |
+ +72 + | ++ + + + + + | + * to guarantee basic thread safety and avoid shared, mutable state when not necessary. |
+ +73 + | ++ + + + + + | + */ |
+ +74 + | ++ + + + + + | + private static final ThreadLocal<Map<String, ParseStatus>> TREE_CACHE = |
+ +75 + | ++ + + + + + | + ThreadLocal.withInitial(HashMap::new); |
+ +76 + | ++ + + + + + | +|
+ +77 + | ++ + + + + + | + /** |
+ +78 + | ++ + + + + + | + * The file context. |
+ +79 + | ++ + + + + + | + * |
+ +80 + | ++ + + + + + | + * @noinspection ThreadLocalNotStaticFinal |
+ +81 + | ++ + + + + + | + */ |
+ +82 + | +
+
+2
+
+
+1. lambda$new$0 : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck$FileContext::<init> → KILLED + +2. lambda$new$0 : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::lambda$new$0 to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ private final ThreadLocal<FileContext> context = ThreadLocal.withInitial(FileContext::new); |
+ +83 + | ++ + + + + + | +|
+ +84 + | ++ + + + + + | + /** The javadoc tokens the check is interested in. */ |
+ +85 + | +
+
+1
+
+
+1. + + |
+ private final Set<Integer> javadocTokens = new HashSet<>(); |
+ +86 + | ++ + + + + + | +|
+ +87 + | ++ + + + + + | + /** |
+ +88 + | ++ + + + + + | + * This property determines if a check should log a violation upon encountering javadoc with |
+ +89 + | ++ + + + + + | + * non-tight html. The default return value for this method is set to false since checks |
+ +90 + | ++ + + + + + | + * generally tend to be fine with non tight html. It can be set through config file if a check |
+ +91 + | ++ + + + + + | + * is to log violation upon encountering non-tight HTML in javadoc. |
+ +92 + | ++ + + + + + | + * |
+ +93 + | ++ + + + + + | + * @see ParseStatus#isNonTight() |
+ +94 + | ++ + + + + + | + * @see <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules"> |
+ +95 + | ++ + + + + + | + * Tight HTML rules</a> |
+ +96 + | ++ + + + + + | + */ |
+ +97 + | ++ + + + + + | + private boolean violateExecutionOnNonTightHtml; |
+ +98 + | ++ + + + + + | +|
+ +99 + | ++ + + + + + | + /** |
+ +100 + | ++ + + + + + | + * Returns the default javadoc token types a check is interested in. |
+ +101 + | ++ + + + + + | + * |
+ +102 + | ++ + + + + + | + * @return the default javadoc token types |
+ +103 + | ++ + + + + + | + * @see JavadocTokenTypes |
+ +104 + | ++ + + + + + | + */ |
+ +105 + | ++ + + + + + | + public abstract int[] getDefaultJavadocTokens(); |
+ +106 + | ++ + + + + + | +|
+ +107 + | ++ + + + + + | + /** |
+ +108 + | ++ + + + + + | + * Called to process a Javadoc token. |
+ +109 + | ++ + + + + + | + * |
+ +110 + | ++ + + + + + | + * @param ast |
+ +111 + | ++ + + + + + | + * the token to process |
+ +112 + | ++ + + + + + | + */ |
+ +113 + | ++ + + + + + | + public abstract void visitJavadocToken(DetailNode ast); |
+ +114 + | ++ + + + + + | +|
+ +115 + | ++ + + + + + | + /** |
+ +116 + | ++ + + + + + | + * The configurable javadoc token set. |
+ +117 + | ++ + + + + + | + * Used to protect Checks against malicious users who specify an |
+ +118 + | ++ + + + + + | + * unacceptable javadoc token set in the configuration file. |
+ +119 + | ++ + + + + + | + * The default implementation returns the check's default javadoc tokens. |
+ +120 + | ++ + + + + + | + * |
+ +121 + | ++ + + + + + | + * @return the javadoc token set this check is designed for. |
+ +122 + | ++ + + + + + | + * @see JavadocTokenTypes |
+ +123 + | ++ + + + + + | + */ |
+ +124 + | ++ + + + + + | + public int[] getAcceptableJavadocTokens() { |
+ +125 + | ++ + + + + + | + final int[] defaultJavadocTokens = getDefaultJavadocTokens(); |
+ +126 + | ++ + + + + + | + final int[] copy = new int[defaultJavadocTokens.length]; |
+ +127 + | +
+
+1
+
+
+1. getAcceptableJavadocTokens : removed call to java/lang/System::arraycopy → KILLED + + + + |
+ System.arraycopy(defaultJavadocTokens, 0, copy, 0, defaultJavadocTokens.length); |
+ +128 + | +
+
+1
+
+
+1. getAcceptableJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getAcceptableJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return copy; |
+ +129 + | ++ + + + + + | + } |
+ +130 + | ++ + + + + + | +|
+ +131 + | ++ + + + + + | + /** |
+ +132 + | ++ + + + + + | + * The javadoc tokens that this check must be registered for. |
+ +133 + | ++ + + + + + | + * |
+ +134 + | ++ + + + + + | + * @return the javadoc token set this must be registered for. |
+ +135 + | ++ + + + + + | + * @see JavadocTokenTypes |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +138 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +139 + | ++ + + + + + | + } |
+ +140 + | ++ + + + + + | +|
+ +141 + | ++ + + + + + | + /** |
+ +142 + | ++ + + + + + | + * This method determines if a check should process javadoc containing non-tight html tags. |
+ +143 + | ++ + + + + + | + * This method must be overridden in checks extending {@code AbstractJavadocCheck} which |
+ +144 + | ++ + + + + + | + * are not supposed to process javadoc containing non-tight html tags. |
+ +145 + | ++ + + + + + | + * |
+ +146 + | ++ + + + + + | + * @return true if the check should or can process javadoc containing non-tight html tags; |
+ +147 + | ++ + + + + + | + * false otherwise |
+ +148 + | ++ + + + + + | + * @see ParseStatus#isNonTight() |
+ +149 + | ++ + + + + + | + * @see <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules"> |
+ +150 + | ++ + + + + + | + * Tight HTML rules</a> |
+ +151 + | ++ + + + + + | + */ |
+ +152 + | ++ + + + + + | + public boolean acceptJavadocWithNonTightHtml() { |
+ +153 + | +
+
+2
+
+
+1. acceptJavadocWithNonTightHtml : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::acceptJavadocWithNonTightHtml → KILLED + +2. acceptJavadocWithNonTightHtml : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return true; |
+ +154 + | ++ + + + + + | + } |
+ +155 + | ++ + + + + + | +|
+ +156 + | ++ + + + + + | + /** |
+ +157 + | ++ + + + + + | + * Setter to control when to print violations if the Javadoc being examined by this check |
+ +158 + | ++ + + + + + | + * violates the tight html rules defined at |
+ +159 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules"> |
+ +160 + | ++ + + + + + | + * Tight-HTML Rules</a>. |
+ +161 + | ++ + + + + + | + * |
+ +162 + | ++ + + + + + | + * @param shouldReportViolation value to which the field shall be set to |
+ +163 + | ++ + + + + + | + */ |
+ +164 + | ++ + + + + + | + public final void setViolateExecutionOnNonTightHtml(boolean shouldReportViolation) { |
+ +165 + | ++ + + + + + | + violateExecutionOnNonTightHtml = shouldReportViolation; |
+ +166 + | ++ + + + + + | + } |
+ +167 + | ++ + + + + + | +|
+ +168 + | ++ + + + + + | + /** |
+ +169 + | ++ + + + + + | + * Adds a set of tokens the check is interested in. |
+ +170 + | ++ + + + + + | + * |
+ +171 + | ++ + + + + + | + * @param strRep the string representation of the tokens interested in |
+ +172 + | ++ + + + + + | + */ |
+ +173 + | ++ + + + + + | + public final void setJavadocTokens(String... strRep) { |
+ +174 + | +
+
+1
+
+
+1. setJavadocTokens : removed call to java/util/Set::clear → SURVIVED + + + + |
+ javadocTokens.clear(); |
+ +175 + | ++ + + + + + | + for (String str : strRep) { |
+ +176 + | ++ + + + + + | + javadocTokens.add(JavadocUtil.getTokenId(str)); |
+ +177 + | ++ + + + + + | + } |
+ +178 + | ++ + + + + + | + } |
+ +179 + | ++ + + + + + | +|
+ +180 + | ++ + + + + + | + @Override |
+ +181 + | ++ + + + + + | + public void init() { |
+ +182 + | +
+
+1
+
+
+1. init : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::validateDefaultJavadocTokens → KILLED + + + + |
+ validateDefaultJavadocTokens(); |
+ +183 + | +
+
+1
+
+
+1. init : negated conditional → KILLED + + + + |
+ if (javadocTokens.isEmpty()) { |
+ +184 + | ++ + + + + + | + javadocTokens.addAll( |
+ +185 + | ++ + + + + + | + Arrays.stream(getDefaultJavadocTokens()).boxed().collect(Collectors.toList())); |
+ +186 + | ++ + + + + + | + } |
+ +187 + | ++ + + + + + | + else { |
+ +188 + | ++ + + + + + | + final int[] acceptableJavadocTokens = getAcceptableJavadocTokens(); |
+ +189 + | +
+
+1
+
+
+1. init : removed call to java/util/Arrays::sort → SURVIVED + + + + |
+ Arrays.sort(acceptableJavadocTokens); |
+ +190 + | ++ + + + + + | + for (Integer javadocTokenId : javadocTokens) { |
+ +191 + | +
+
+2
+
+
+1. init : changed conditional boundary → KILLED + +2. init : negated conditional → KILLED + + + + |
+ if (Arrays.binarySearch(acceptableJavadocTokens, javadocTokenId) < 0) { |
+ +192 + | ++ + + + + + | + final String message = String.format(Locale.ROOT, "Javadoc Token \"%s\" was " |
+ +193 + | ++ + + + + + | + + "not found in Acceptable javadoc tokens list in check %s", |
+ +194 + | ++ + + + + + | + JavadocUtil.getTokenName(javadocTokenId), getClass().getName()); |
+ +195 + | +
+
+1
+
+
+1. init : removed call to java/lang/IllegalStateException::<init> → KILLED + + + + |
+ throw new IllegalStateException(message); |
+ +196 + | ++ + + + + + | + } |
+ +197 + | ++ + + + + + | + } |
+ +198 + | ++ + + + + + | + } |
+ +199 + | ++ + + + + + | + } |
+ +200 + | ++ + + + + + | +|
+ +201 + | ++ + + + + + | + /** |
+ +202 + | ++ + + + + + | + * Validates that check's required javadoc tokens are subset of default javadoc tokens. |
+ +203 + | ++ + + + + + | + * |
+ +204 + | ++ + + + + + | + * @throws IllegalStateException when validation of default javadoc tokens fails |
+ +205 + | ++ + + + + + | + */ |
+ +206 + | ++ + + + + + | + private void validateDefaultJavadocTokens() { |
+ +207 + | +
+
+1
+
+
+1. validateDefaultJavadocTokens : negated conditional → KILLED + + + + |
+ if (getRequiredJavadocTokens().length != 0) { |
+ +208 + | ++ + + + + + | + final int[] defaultJavadocTokens = getDefaultJavadocTokens(); |
+ +209 + | +
+
+1
+
+
+1. validateDefaultJavadocTokens : removed call to java/util/Arrays::sort → KILLED + + + + |
+ Arrays.sort(defaultJavadocTokens); |
+ +210 + | ++ + + + + + | + for (final int javadocToken : getRequiredJavadocTokens()) { |
+ +211 + | +
+
+2
+
+
+1. validateDefaultJavadocTokens : changed conditional boundary → KILLED + +2. validateDefaultJavadocTokens : negated conditional → KILLED + + + + |
+ if (Arrays.binarySearch(defaultJavadocTokens, javadocToken) < 0) { |
+ +212 + | ++ + + + + + | + final String message = String.format(Locale.ROOT, |
+ +213 + | ++ + + + + + | + "Javadoc Token \"%s\" from required javadoc " |
+ +214 + | ++ + + + + + | + + "tokens was not found in default " |
+ +215 + | ++ + + + + + | + + "javadoc tokens list in check %s", |
+ +216 + | ++ + + + + + | + javadocToken, getClass().getName()); |
+ +217 + | +
+
+1
+
+
+1. validateDefaultJavadocTokens : removed call to java/lang/IllegalStateException::<init> → KILLED + + + + |
+ throw new IllegalStateException(message); |
+ +218 + | ++ + + + + + | + } |
+ +219 + | ++ + + + + + | + } |
+ +220 + | ++ + + + + + | + } |
+ +221 + | ++ + + + + + | + } |
+ +222 + | ++ + + + + + | +|
+ +223 + | ++ + + + + + | + /** |
+ +224 + | ++ + + + + + | + * Called before the starting to process a tree. |
+ +225 + | ++ + + + + + | + * |
+ +226 + | ++ + + + + + | + * @param rootAst |
+ +227 + | ++ + + + + + | + * the root of the tree |
+ +228 + | ++ + + + + + | + * @noinspection WeakerAccess |
+ +229 + | ++ + + + + + | + */ |
+ +230 + | ++ + + + + + | + public void beginJavadocTree(DetailNode rootAst) { |
+ +231 + | ++ + + + + + | + // No code by default, should be overridden only by demand at subclasses |
+ +232 + | ++ + + + + + | + } |
+ +233 + | ++ + + + + + | +|
+ +234 + | ++ + + + + + | + /** |
+ +235 + | ++ + + + + + | + * Called after finished processing a tree. |
+ +236 + | ++ + + + + + | + * |
+ +237 + | ++ + + + + + | + * @param rootAst |
+ +238 + | ++ + + + + + | + * the root of the tree |
+ +239 + | ++ + + + + + | + * @noinspection WeakerAccess |
+ +240 + | ++ + + + + + | + */ |
+ +241 + | ++ + + + + + | + public void finishJavadocTree(DetailNode rootAst) { |
+ +242 + | ++ + + + + + | + // No code by default, should be overridden only by demand at subclasses |
+ +243 + | ++ + + + + + | + } |
+ +244 + | ++ + + + + + | +|
+ +245 + | ++ + + + + + | + /** |
+ +246 + | ++ + + + + + | + * Called after all the child nodes have been process. |
+ +247 + | ++ + + + + + | + * |
+ +248 + | ++ + + + + + | + * @param ast |
+ +249 + | ++ + + + + + | + * the token leaving |
+ +250 + | ++ + + + + + | + */ |
+ +251 + | ++ + + + + + | + public void leaveJavadocToken(DetailNode ast) { |
+ +252 + | ++ + + + + + | + // No code by default, should be overridden only by demand at subclasses |
+ +253 + | ++ + + + + + | + } |
+ +254 + | ++ + + + + + | +|
+ +255 + | ++ + + + + + | + /** |
+ +256 + | ++ + + + + + | + * Defined final to not allow JavadocChecks to change default tokens. |
+ +257 + | ++ + + + + + | + * |
+ +258 + | ++ + + + + + | + * @return default tokens |
+ +259 + | ++ + + + + + | + */ |
+ +260 + | ++ + + + + + | + @Override |
+ +261 + | ++ + + + + + | + public final int[] getDefaultTokens() { |
+ +262 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +263 + | ++ + + + + + | + } |
+ +264 + | ++ + + + + + | +|
+ +265 + | ++ + + + + + | + @Override |
+ +266 + | ++ + + + + + | + public final int[] getAcceptableTokens() { |
+ +267 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +268 + | ++ + + + + + | + } |
+ +269 + | ++ + + + + + | +|
+ +270 + | ++ + + + + + | + @Override |
+ +271 + | ++ + + + + + | + public final int[] getRequiredTokens() { |
+ +272 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] {TokenTypes.BLOCK_COMMENT_BEGIN }; |
+ +273 + | ++ + + + + + | + } |
+ +274 + | ++ + + + + + | +|
+ +275 + | ++ + + + + + | + /** |
+ +276 + | ++ + + + + + | + * Defined final because all JavadocChecks require comment nodes. |
+ +277 + | ++ + + + + + | + * |
+ +278 + | ++ + + + + + | + * @return true |
+ +279 + | ++ + + + + + | + */ |
+ +280 + | ++ + + + + + | + @Override |
+ +281 + | ++ + + + + + | + public final boolean isCommentNodesRequired() { |
+ +282 + | +
+
+2
+
+
+1. isCommentNodesRequired : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::isCommentNodesRequired → KILLED + +2. isCommentNodesRequired : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return true; |
+ +283 + | ++ + + + + + | + } |
+ +284 + | ++ + + + + + | +|
+ +285 + | ++ + + + + + | + @Override |
+ +286 + | ++ + + + + + | + public final void beginTree(DetailAST rootAST) { |
+ +287 + | +
+
+1
+
+
+1. beginTree : removed call to java/util/Map::clear → KILLED + + + + |
+ TREE_CACHE.get().clear(); |
+ +288 + | ++ + + + + + | + } |
+ +289 + | ++ + + + + + | +|
+ +290 + | ++ + + + + + | + @Override |
+ +291 + | ++ + + + + + | + public final void finishTree(DetailAST rootAST) { |
+ +292 + | ++ + + + + + | + // No code, prevent override in subclasses |
+ +293 + | ++ + + + + + | + } |
+ +294 + | ++ + + + + + | +|
+ +295 + | ++ + + + + + | + @Override |
+ +296 + | ++ + + + + + | + public final void visitToken(DetailAST blockCommentNode) { |
+ +297 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (JavadocUtil.isJavadocComment(blockCommentNode)) { |
+ +298 + | ++ + + + + + | + // store as field, to share with child Checks |
+ +299 + | ++ + + + + + | + context.get().blockCommentAst = blockCommentNode; |
+ +300 + | ++ + + + + + | +|
+ +301 + | +
+
+1
+
+
+1. visitToken : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final String treeCacheKey = blockCommentNode.getLineNo() + ":" |
+ +302 + | ++ + + + + + | + + blockCommentNode.getColumnNo(); |
+ +303 + | ++ + + + + + | +|
+ +304 + | ++ + + + + + | + final ParseStatus result; |
+ +305 + | ++ + + + + + | +|
+ +306 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (TREE_CACHE.get().containsKey(treeCacheKey)) { |
+ +307 + | ++ + + + + + | + result = TREE_CACHE.get().get(treeCacheKey); |
+ +308 + | ++ + + + + + | + } |
+ +309 + | ++ + + + + + | + else { |
+ +310 + | ++ + + + + + | + result = context.get().parser |
+ +311 + | ++ + + + + + | + .parseJavadocAsDetailNode(blockCommentNode); |
+ +312 + | ++ + + + + + | + TREE_CACHE.get().put(treeCacheKey, result); |
+ +313 + | ++ + + + + + | + } |
+ +314 + | ++ + + + + + | +|
+ +315 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (result.getParseErrorMessage() == null) { |
+ +316 + | +
+
+2
+
+
+1. visitToken : negated conditional → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (acceptJavadocWithNonTightHtml() || !result.isNonTight()) { |
+ +317 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::processTree → KILLED + + + + |
+ processTree(result.getTree()); |
+ +318 + | ++ + + + + + | + } |
+ +319 + | ++ + + + + + | +|
+ +320 + | +
+
+2
+
+
+1. visitToken : negated conditional → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (violateExecutionOnNonTightHtml && result.isNonTight()) { |
+ +321 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::log → KILLED + + + + |
+ log(result.getFirstNonTightHtmlTag().getLine(), |
+ +322 + | ++ + + + + + | + JavadocDetailNodeParser.MSG_UNCLOSED_HTML_TAG, |
+ +323 + | ++ + + + + + | + result.getFirstNonTightHtmlTag().getText()); |
+ +324 + | ++ + + + + + | + } |
+ +325 + | ++ + + + + + | + } |
+ +326 + | ++ + + + + + | + else { |
+ +327 + | ++ + + + + + | + final ParseErrorMessage parseErrorMessage = result.getParseErrorMessage(); |
+ +328 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::log → KILLED + + + + |
+ log(parseErrorMessage.getLineNumber(), |
+ +329 + | ++ + + + + + | + parseErrorMessage.getMessageKey(), |
+ +330 + | ++ + + + + + | + parseErrorMessage.getMessageArguments()); |
+ +331 + | ++ + + + + + | + } |
+ +332 + | ++ + + + + + | + } |
+ +333 + | ++ + + + + + | + } |
+ +334 + | ++ + + + + + | +|
+ +335 + | ++ + + + + + | + /** |
+ +336 + | ++ + + + + + | + * Getter for block comment in Java language syntax tree. |
+ +337 + | ++ + + + + + | + * |
+ +338 + | ++ + + + + + | + * @return A block comment in the syntax tree. |
+ +339 + | ++ + + + + + | + */ |
+ +340 + | ++ + + + + + | + protected DetailAST getBlockCommentAst() { |
+ +341 + | +
+
+1
+
+
+1. getBlockCommentAst : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::getBlockCommentAst to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return context.get().blockCommentAst; |
+ +342 + | ++ + + + + + | + } |
+ +343 + | ++ + + + + + | +|
+ +344 + | ++ + + + + + | + /** |
+ +345 + | ++ + + + + + | + * Processes JavadocAST tree notifying Check. |
+ +346 + | ++ + + + + + | + * |
+ +347 + | ++ + + + + + | + * @param root |
+ +348 + | ++ + + + + + | + * root of JavadocAST tree. |
+ +349 + | ++ + + + + + | + */ |
+ +350 + | ++ + + + + + | + private void processTree(DetailNode root) { |
+ +351 + | +
+
+1
+
+
+1. processTree : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::beginJavadocTree → SURVIVED + + + + |
+ beginJavadocTree(root); |
+ +352 + | +
+
+1
+
+
+1. processTree : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::walk → KILLED + + + + |
+ walk(root); |
+ +353 + | +
+
+1
+
+
+1. processTree : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::finishJavadocTree → SURVIVED + + + + |
+ finishJavadocTree(root); |
+ +354 + | ++ + + + + + | + } |
+ +355 + | ++ + + + + + | +|
+ +356 + | ++ + + + + + | + /** |
+ +357 + | ++ + + + + + | + * Processes a node calling Check at interested nodes. |
+ +358 + | ++ + + + + + | + * |
+ +359 + | ++ + + + + + | + * @param root |
+ +360 + | ++ + + + + + | + * the root of tree for process |
+ +361 + | ++ + + + + + | + */ |
+ +362 + | ++ + + + + + | + private void walk(DetailNode root) { |
+ +363 + | ++ + + + + + | + DetailNode curNode = root; |
+ +364 + | +
+
+1
+
+
+1. walk : negated conditional → KILLED + + + + |
+ while (curNode != null) { |
+ +365 + | ++ + + + + + | + boolean waitsForProcessing = shouldBeProcessed(curNode); |
+ +366 + | ++ + + + + + | +|
+ +367 + | +
+
+1
+
+
+1. walk : negated conditional → KILLED + + + + |
+ if (waitsForProcessing) { |
+ +368 + | +
+
+1
+
+
+1. walk : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::visitJavadocToken → KILLED + + + + |
+ visitJavadocToken(curNode); |
+ +369 + | ++ + + + + + | + } |
+ +370 + | ++ + + + + + | + DetailNode toVisit = JavadocUtil.getFirstChild(curNode); |
+ +371 + | +
+
+2
+
+
+1. walk : negated conditional → KILLED + +2. walk : negated conditional → KILLED + + + + |
+ while (curNode != null && toVisit == null) { |
+ +372 + | +
+
+1
+
+
+1. walk : negated conditional → KILLED + + + + |
+ if (waitsForProcessing) { |
+ +373 + | +
+
+1
+
+
+1. walk : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::leaveJavadocToken → KILLED + + + + |
+ leaveJavadocToken(curNode); |
+ +374 + | ++ + + + + + | + } |
+ +375 + | ++ + + + + + | +|
+ +376 + | ++ + + + + + | + toVisit = JavadocUtil.getNextSibling(curNode); |
+ +377 + | +
+
+1
+
+
+1. walk : negated conditional → TIMED_OUT + + + + |
+ if (toVisit == null) { |
+ +378 + | ++ + + + + + | + curNode = curNode.getParent(); |
+ +379 + | +
+
+1
+
+
+1. walk : negated conditional → KILLED + + + + |
+ if (curNode != null) { |
+ +380 + | ++ + + + + + | + waitsForProcessing = shouldBeProcessed(curNode); |
+ +381 + | ++ + + + + + | + } |
+ +382 + | ++ + + + + + | + } |
+ +383 + | ++ + + + + + | + } |
+ +384 + | ++ + + + + + | + curNode = toVisit; |
+ +385 + | ++ + + + + + | + } |
+ +386 + | ++ + + + + + | + } |
+ +387 + | ++ + + + + + | +|
+ +388 + | ++ + + + + + | + /** |
+ +389 + | ++ + + + + + | + * Checks whether the current node should be processed by the check. |
+ +390 + | ++ + + + + + | + * |
+ +391 + | ++ + + + + + | + * @param curNode current node. |
+ +392 + | ++ + + + + + | + * @return true if the current node should be processed by the check. |
+ +393 + | ++ + + + + + | + */ |
+ +394 + | ++ + + + + + | + private boolean shouldBeProcessed(DetailNode curNode) { |
+ +395 + | +
+
+3
+
+
+1. shouldBeProcessed : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::shouldBeProcessed → KILLED + +2. shouldBeProcessed : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck::shouldBeProcessed → KILLED + +3. shouldBeProcessed : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return javadocTokens.contains(curNode.getType()); |
+ +396 + | ++ + + + + + | + } |
+ +397 + | ++ + + + + + | +|
+ +398 + | ++ + + + + + | + @Override |
+ +399 + | ++ + + + + + | + public void destroy() { |
+ +400 + | ++ + + + + + | + super.destroy(); |
+ +401 + | ++ + + + + + | + context.remove(); |
+ +402 + | ++ + + + + + | + TREE_CACHE.remove(); |
+ +403 + | ++ + + + + + | + } |
+ +404 + | ++ + + + + + | +|
+ +405 + | ++ + + + + + | + /** |
+ +406 + | ++ + + + + + | + * The file context holder. |
+ +407 + | ++ + + + + + | + */ |
+ +408 + | ++ + + + + + | + private static class FileContext { |
+ +409 + | ++ + + + + + | +|
+ +410 + | ++ + + + + + | + /** |
+ +411 + | ++ + + + + + | + * Parses content of Javadoc comment as DetailNode tree. |
+ +412 + | ++ + + + + + | + */ |
+ +413 + | +
+
+1
+
+
+1. + + |
+ private final JavadocDetailNodeParser parser = new JavadocDetailNodeParser(); |
+ +414 + | ++ + + + + + | +|
+ +415 + | ++ + + + + + | + /** |
+ +416 + | ++ + + + + + | + * DetailAST node of considered Javadoc comment that is just a block comment |
+ +417 + | ++ + + + + + | + * in Java language syntax tree. |
+ +418 + | ++ + + + + + | + */ |
+ +419 + | ++ + + + + + | + private DetailAST blockCommentAst; |
+ +420 + | ++ + + + + + | +|
+ +421 + | ++ + + + + + | + } |
+ +422 + | ++ + + + + + | +|
+ +423 + | ++ + + + + + | +} |
Mutations | ||
82 | ++ |
+
+
+
+ 1.1 2.2 |
+
85 | ++ |
+
+
+
+ 1.1 |
+
127 | ++ |
+
+
+
+ 1.1 |
+
128 | ++ |
+
+
+
+ 1.1 |
+
138 | ++ |
+
+
+
+ 1.1 |
+
153 | ++ |
+
+
+
+ 1.1 2.2 |
+
174 | ++ |
+
+
+
+ 1.1 |
+
182 | ++ |
+
+
+
+ 1.1 |
+
183 | ++ |
+
+
+
+ 1.1 |
+
189 | ++ |
+
+
+
+ 1.1 |
+
191 | ++ |
+
+
+
+ 1.1 2.2 |
+
195 | ++ |
+
+
+
+ 1.1 |
+
207 | ++ |
+
+
+
+ 1.1 |
+
209 | ++ |
+
+
+
+ 1.1 |
+
211 | ++ |
+
+
+
+ 1.1 2.2 |
+
217 | ++ |
+
+
+
+ 1.1 |
+
262 | ++ |
+
+
+
+ 1.1 |
+
267 | ++ |
+
+
+
+ 1.1 |
+
272 | ++ |
+
+
+
+ 1.1 |
+
282 | ++ |
+
+
+
+ 1.1 2.2 |
+
287 | ++ |
+
+
+
+ 1.1 |
+
297 | ++ |
+
+
+
+ 1.1 |
+
301 | ++ |
+
+
+
+ 1.1 |
+
306 | ++ |
+
+
+
+ 1.1 |
+
315 | ++ |
+
+
+
+ 1.1 |
+
316 | ++ |
+
+
+
+ 1.1 2.2 |
+
317 | ++ |
+
+
+
+ 1.1 |
+
320 | ++ |
+
+
+
+ 1.1 2.2 |
+
321 | ++ |
+
+
+
+ 1.1 |
+
328 | ++ |
+
+
+
+ 1.1 |
+
341 | ++ |
+
+
+
+ 1.1 |
+
351 | ++ |
+
+
+
+ 1.1 |
+
352 | ++ |
+
+
+
+ 1.1 |
+
353 | ++ |
+
+
+
+ 1.1 |
+
364 | ++ |
+
+
+
+ 1.1 |
+
367 | ++ |
+
+
+
+ 1.1 |
+
368 | ++ |
+
+
+
+ 1.1 |
+
371 | ++ |
+
+
+
+ 1.1 2.2 |
+
372 | ++ |
+
+
+
+ 1.1 |
+
373 | ++ |
+
+
+
+ 1.1 |
+
377 | ++ |
+
+
+
+ 1.1 |
+
379 | ++ |
+
+
+
+ 1.1 |
+
395 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
413 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.Arrays; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +|
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.TokenUtil; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | +/** |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * Checks the order of |
+ +37 + | ++ + + + + + | + * <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF"> |
+ +38 + | ++ + + + + + | + * javadoc block-tags or javadoc tags</a>. |
+ +39 + | ++ + + + + + | + * </p> |
+ +40 + | ++ + + + + + | + * <p> |
+ +41 + | ++ + + + + + | + * Note: Google used the term "at-clauses" for block tags in their guide till 2017-02-28. |
+ +42 + | ++ + + + + + | + * </p> |
+ +43 + | ++ + + + + + | + * |
+ +44 + | ++ + + + + + | + * <ul> |
+ +45 + | ++ + + + + + | + * <li> |
+ +46 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations if the |
+ +47 + | ++ + + + + + | + * Javadoc being examined by this check violates the tight html rules defined at |
+ +48 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +49 + | ++ + + + + + | + * Default value is {@code false}. |
+ +50 + | ++ + + + + + | + * </li> |
+ +51 + | ++ + + + + + | + * <li> |
+ +52 + | ++ + + + + + | + * Property {@code target} - Specify the list of targets to check at-clauses. Default value is |
+ +53 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF"> |
+ +54 + | ++ + + + + + | + * CLASS_DEF</a>, |
+ +55 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF"> |
+ +56 + | ++ + + + + + | + * INTERFACE_DEF</a>, |
+ +57 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF"> |
+ +58 + | ++ + + + + + | + * ENUM_DEF</a>, |
+ +59 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF"> |
+ +60 + | ++ + + + + + | + * METHOD_DEF</a>, |
+ +61 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF"> |
+ +62 + | ++ + + + + + | + * CTOR_DEF</a>, |
+ +63 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF"> |
+ +64 + | ++ + + + + + | + * VARIABLE_DEF</a>. |
+ +65 + | ++ + + + + + | + * </li> |
+ +66 + | ++ + + + + + | + * <li> |
+ +67 + | ++ + + + + + | + * Property {@code tagOrder} - Specify the order by tags. |
+ +68 + | ++ + + + + + | + * Default value is |
+ +69 + | ++ + + + + + | + * {@code @author, @deprecated, @exception, @param, @return, @see, @serial, @serialData, @serialField, @since, @throws, @version}. |
+ +70 + | ++ + + + + + | + * </li> |
+ +71 + | ++ + + + + + | + * </ul> |
+ +72 + | ++ + + + + + | + * <p> |
+ +73 + | ++ + + + + + | + * Default configuration |
+ +74 + | ++ + + + + + | + * </p> |
+ +75 + | ++ + + + + + | + * <pre> |
+ +76 + | ++ + + + + + | + * <module name="AtclauseOrder"> |
+ +77 + | ++ + + + + + | + * <property name="tagOrder" value="@author, @version, @param, |
+ +78 + | ++ + + + + + | + * @return, @throws, @exception, @see, @since, @serial, |
+ +79 + | ++ + + + + + | + * @serialField, @serialData, @deprecated"/> |
+ +80 + | ++ + + + + + | + * <property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, |
+ +81 + | ++ + + + + + | + * METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> |
+ +82 + | ++ + + + + + | + * </module> |
+ +83 + | ++ + + + + + | + * </pre> |
+ +84 + | ++ + + + + + | + * |
+ +85 + | ++ + + + + + | + * @since 6.0 |
+ +86 + | ++ + + + + + | + */ |
+ +87 + | ++ + + + + + | +@StatelessCheck |
+ +88 + | ++ + + + + + | +public class AtclauseOrderCheck extends AbstractJavadocCheck { |
+ +89 + | ++ + + + + + | +|
+ +90 + | ++ + + + + + | + /** |
+ +91 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +92 + | ++ + + + + + | + * file. |
+ +93 + | ++ + + + + + | + */ |
+ +94 + | ++ + + + + + | + public static final String MSG_KEY = "at.clause.order"; |
+ +95 + | ++ + + + + + | +|
+ +96 + | ++ + + + + + | + /** |
+ +97 + | ++ + + + + + | + * Default order of atclauses. |
+ +98 + | ++ + + + + + | + */ |
+ +99 + | ++ + + + + + | + private static final String[] DEFAULT_ORDER = { |
+ +100 + | ++ + + + + + | + "@author", "@version", |
+ +101 + | ++ + + + + + | + "@param", "@return", |
+ +102 + | ++ + + + + + | + "@throws", "@exception", |
+ +103 + | ++ + + + + + | + "@see", "@since", |
+ +104 + | ++ + + + + + | + "@serial", "@serialField", |
+ +105 + | ++ + + + + + | + "@serialData", "@deprecated", |
+ +106 + | ++ + + + + + | + }; |
+ +107 + | ++ + + + + + | +|
+ +108 + | ++ + + + + + | + /** |
+ +109 + | ++ + + + + + | + * Specify the list of targets to check at-clauses. |
+ +110 + | ++ + + + + + | + */ |
+ +111 + | ++ + + + + + | + private List<Integer> target = Arrays.asList( |
+ +112 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +113 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +114 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +115 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +116 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +117 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF |
+ +118 + | ++ + + + + + | + ); |
+ +119 + | ++ + + + + + | +|
+ +120 + | ++ + + + + + | + /** |
+ +121 + | ++ + + + + + | + * Specify the order by tags. |
+ +122 + | ++ + + + + + | + */ |
+ +123 + | ++ + + + + + | + private List<String> tagOrder = Arrays.asList(DEFAULT_ORDER); |
+ +124 + | ++ + + + + + | +|
+ +125 + | ++ + + + + + | + /** |
+ +126 + | ++ + + + + + | + * Setter to specify the list of targets to check at-clauses. |
+ +127 + | ++ + + + + + | + * |
+ +128 + | ++ + + + + + | + * @param targets user's targets. |
+ +129 + | ++ + + + + + | + */ |
+ +130 + | ++ + + + + + | + public void setTarget(String... targets) { |
+ +131 + | +
+
+1
+
+
+1. setTarget : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<Integer> customTarget = new ArrayList<>(); |
+ +132 + | ++ + + + + + | + for (String temp : targets) { |
+ +133 + | ++ + + + + + | + customTarget.add(TokenUtil.getTokenId(temp.trim())); |
+ +134 + | ++ + + + + + | + } |
+ +135 + | ++ + + + + + | + target = customTarget; |
+ +136 + | ++ + + + + + | + } |
+ +137 + | ++ + + + + + | +|
+ +138 + | ++ + + + + + | + /** |
+ +139 + | ++ + + + + + | + * Setter to specify the order by tags. |
+ +140 + | ++ + + + + + | + * |
+ +141 + | ++ + + + + + | + * @param orders user's orders. |
+ +142 + | ++ + + + + + | + */ |
+ +143 + | ++ + + + + + | + public void setTagOrder(String... orders) { |
+ +144 + | +
+
+1
+
+
+1. setTagOrder : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<String> customOrder = new ArrayList<>(); |
+ +145 + | ++ + + + + + | + for (String order : orders) { |
+ +146 + | ++ + + + + + | + customOrder.add(order.trim()); |
+ +147 + | ++ + + + + + | + } |
+ +148 + | ++ + + + + + | + tagOrder = customOrder; |
+ +149 + | ++ + + + + + | + } |
+ +150 + | ++ + + + + + | +|
+ +151 + | ++ + + + + + | + @Override |
+ +152 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +153 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +154 + | ++ + + + + + | + JavadocTokenTypes.JAVADOC, |
+ +155 + | ++ + + + + + | + }; |
+ +156 + | ++ + + + + + | + } |
+ +157 + | ++ + + + + + | +|
+ +158 + | ++ + + + + + | + @Override |
+ +159 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +160 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +161 + | ++ + + + + + | + } |
+ +162 + | ++ + + + + + | +|
+ +163 + | ++ + + + + + | + @Override |
+ +164 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +165 + | ++ + + + + + | + final int parentType = getParentType(getBlockCommentAst()); |
+ +166 + | ++ + + + + + | +|
+ +167 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (target.contains(parentType)) { |
+ +168 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheck::checkOrderInTagSection → KILLED + + + + |
+ checkOrderInTagSection(ast); |
+ +169 + | ++ + + + + + | + } |
+ +170 + | ++ + + + + + | + } |
+ +171 + | ++ + + + + + | +|
+ +172 + | ++ + + + + + | + /** |
+ +173 + | ++ + + + + + | + * Checks order of atclauses in tag section node. |
+ +174 + | ++ + + + + + | + * |
+ +175 + | ++ + + + + + | + * @param javadoc Javadoc root node. |
+ +176 + | ++ + + + + + | + */ |
+ +177 + | ++ + + + + + | + private void checkOrderInTagSection(DetailNode javadoc) { |
+ +178 + | ++ + + + + + | + int maxIndexOfPreviousTag = 0; |
+ +179 + | ++ + + + + + | +|
+ +180 + | ++ + + + + + | + for (DetailNode node : javadoc.getChildren()) { |
+ +181 + | +
+
+1
+
+
+1. checkOrderInTagSection : negated conditional → KILLED + + + + |
+ if (node.getType() == JavadocTokenTypes.JAVADOC_TAG) { |
+ +182 + | ++ + + + + + | + final String tagText = JavadocUtil.getFirstChild(node).getText(); |
+ +183 + | ++ + + + + + | + final int indexOfCurrentTag = tagOrder.indexOf(tagText); |
+ +184 + | ++ + + + + + | +|
+ +185 + | +
+
+1
+
+
+1. checkOrderInTagSection : negated conditional → KILLED + + + + |
+ if (indexOfCurrentTag != -1) { |
+ +186 + | +
+
+2
+
+
+1. checkOrderInTagSection : changed conditional boundary → KILLED + +2. checkOrderInTagSection : negated conditional → KILLED + + + + |
+ if (indexOfCurrentTag < maxIndexOfPreviousTag) { |
+ +187 + | +
+
+1
+
+
+1. checkOrderInTagSection : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheck::log → KILLED + + + + |
+ log(node.getLineNumber(), MSG_KEY, tagOrder.toString()); |
+ +188 + | ++ + + + + + | + } |
+ +189 + | ++ + + + + + | + else { |
+ +190 + | ++ + + + + + | + maxIndexOfPreviousTag = indexOfCurrentTag; |
+ +191 + | ++ + + + + + | + } |
+ +192 + | ++ + + + + + | + } |
+ +193 + | ++ + + + + + | + } |
+ +194 + | ++ + + + + + | + } |
+ +195 + | ++ + + + + + | + } |
+ +196 + | ++ + + + + + | +|
+ +197 + | ++ + + + + + | + /** |
+ +198 + | ++ + + + + + | + * Returns type of parent node. |
+ +199 + | ++ + + + + + | + * |
+ +200 + | ++ + + + + + | + * @param commentBlock child node. |
+ +201 + | ++ + + + + + | + * @return parent type. |
+ +202 + | ++ + + + + + | + */ |
+ +203 + | ++ + + + + + | + private static int getParentType(DetailAST commentBlock) { |
+ +204 + | ++ + + + + + | + final DetailAST parentNode = commentBlock.getParent(); |
+ +205 + | ++ + + + + + | + int result = 0; |
+ +206 + | +
+
+1
+
+
+1. getParentType : negated conditional → KILLED + + + + |
+ if (parentNode != null) { |
+ +207 + | ++ + + + + + | + result = parentNode.getType(); |
+ +208 + | +
+
+2
+
+
+1. getParentType : negated conditional → KILLED + +2. getParentType : negated conditional → KILLED + + + + |
+ if (result == TokenTypes.TYPE || result == TokenTypes.MODIFIERS) { |
+ +209 + | ++ + + + + + | + result = parentNode.getParent().getType(); |
+ +210 + | ++ + + + + + | + } |
+ +211 + | ++ + + + + + | + } |
+ +212 + | +
+
+1
+
+
+1. getParentType : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +213 + | ++ + + + + + | + } |
+ +214 + | ++ + + + + + | +|
+ +215 + | ++ + + + + + | +} |
Mutations | ||
131 | ++ |
+
+
+
+ 1.1 |
+
144 | ++ |
+
+
+
+ 1.1 |
+
153 | ++ |
+
+
+
+ 1.1 |
+
160 | ++ |
+
+
+
+ 1.1 |
+
167 | ++ |
+
+
+
+ 1.1 |
+
168 | ++ |
+
+
+
+ 1.1 |
+
181 | ++ |
+
+
+
+ 1.1 |
+
185 | ++ |
+
+
+
+ 1.1 |
+
186 | ++ |
+
+
+
+ 1.1 2.2 |
+
187 | ++ |
+
+
+
+ 1.1 |
+
206 | ++ |
+
+
+
+ 1.1 |
+
208 | ++ |
+
+
+
+ 1.1 2.2 |
+
212 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +/** |
+ +23 + | ++ + + + + + | + * Used to keep track of a tag and the text that follows it. |
+ +24 + | ++ + + + + + | + * |
+ +25 + | ++ + + + + + | + */ |
+ +26 + | ++ + + + + + | +class HtmlTag { |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | + /** The maximum length of text to display with this tag. */ |
+ +29 + | ++ + + + + + | + private static final int MAX_TEXT_LEN = 60; |
+ +30 + | ++ + + + + + | +|
+ +31 + | ++ + + + + + | + /** The HTML tag name. */ |
+ +32 + | ++ + + + + + | + private final String id; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | + /** The line number in the source file where this tag was found. */ |
+ +35 + | ++ + + + + + | + private final int lineNo; |
+ +36 + | ++ + + + + + | +|
+ +37 + | ++ + + + + + | + /** The position within the line where this tag was found. */ |
+ +38 + | ++ + + + + + | + private final int position; |
+ +39 + | ++ + + + + + | +|
+ +40 + | ++ + + + + + | + /** The comment line of text where this tag appears. */ |
+ +41 + | ++ + + + + + | + private final String text; |
+ +42 + | ++ + + + + + | +|
+ +43 + | ++ + + + + + | + /** If this tag is self-closed. */ |
+ +44 + | ++ + + + + + | + private final boolean closedTag; |
+ +45 + | ++ + + + + + | +|
+ +46 + | ++ + + + + + | + /** If the tag is incomplete. */ |
+ +47 + | ++ + + + + + | + private final boolean incompleteTag; |
+ +48 + | ++ + + + + + | +|
+ +49 + | ++ + + + + + | + /** |
+ +50 + | ++ + + + + + | + * Construct the HtmlTag. |
+ +51 + | ++ + + + + + | + * |
+ +52 + | ++ + + + + + | + * @param id the HTML tag name. |
+ +53 + | ++ + + + + + | + * @param lineNo the source line number of this tag. |
+ +54 + | ++ + + + + + | + * @param position the position within the text of this tag. |
+ +55 + | ++ + + + + + | + * @param closedTag if this tag is self-closed (XHTML style) |
+ +56 + | ++ + + + + + | + * @param incomplete is the tag is incomplete. |
+ +57 + | ++ + + + + + | + * @param text the line of comment text for this tag. |
+ +58 + | ++ + + + + + | + */ |
+ +59 + | ++ + + + + + | + /* package */ HtmlTag(String id, int lineNo, int position, boolean closedTag, |
+ +60 + | ++ + + + + + | + boolean incomplete, String text) { |
+ +61 + | ++ + + + + + | + this.id = id; |
+ +62 + | ++ + + + + + | + this.lineNo = lineNo; |
+ +63 + | ++ + + + + + | + this.position = position; |
+ +64 + | ++ + + + + + | + this.text = text; |
+ +65 + | ++ + + + + + | + this.closedTag = closedTag; |
+ +66 + | ++ + + + + + | + incompleteTag = incomplete; |
+ +67 + | ++ + + + + + | + } |
+ +68 + | ++ + + + + + | +|
+ +69 + | ++ + + + + + | + /** |
+ +70 + | ++ + + + + + | + * Returns the id (name) of this tag. |
+ +71 + | ++ + + + + + | + * |
+ +72 + | ++ + + + + + | + * @return a String id. |
+ +73 + | ++ + + + + + | + */ |
+ +74 + | ++ + + + + + | + public String getId() { |
+ +75 + | +
+
+1
+
+
+1. getId : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::getId to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return id; |
+ +76 + | ++ + + + + + | + } |
+ +77 + | ++ + + + + + | +|
+ +78 + | ++ + + + + + | + /** |
+ +79 + | ++ + + + + + | + * Indicates if this tag is a close (end) tag. |
+ +80 + | ++ + + + + + | + * |
+ +81 + | ++ + + + + + | + * @return {@code true} is this is a close tag. |
+ +82 + | ++ + + + + + | + */ |
+ +83 + | ++ + + + + + | + public boolean isCloseTag() { |
+ +84 + | +
+
+6
+
+
+1. isCloseTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::isCloseTag → KILLED + +2. isCloseTag : Replaced integer subtraction with addition → KILLED + +3. isCloseTag : Replaced integer addition with subtraction → KILLED + +4. isCloseTag : negated conditional → KILLED + +5. isCloseTag : negated conditional → KILLED + +6. isCloseTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return position != text.length() - 1 && text.charAt(position + 1) == '/'; |
+ +85 + | ++ + + + + + | + } |
+ +86 + | ++ + + + + + | +|
+ +87 + | ++ + + + + + | + /** |
+ +88 + | ++ + + + + + | + * Indicates if this tag is a self-closed XHTML style. |
+ +89 + | ++ + + + + + | + * |
+ +90 + | ++ + + + + + | + * @return {@code true} is this is a self-closed tag. |
+ +91 + | ++ + + + + + | + */ |
+ +92 + | ++ + + + + + | + public boolean isClosedTag() { |
+ +93 + | +
+
+3
+
+
+1. isClosedTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::isClosedTag → KILLED + +2. isClosedTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::isClosedTag → KILLED + +3. isClosedTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return closedTag; |
+ +94 + | ++ + + + + + | + } |
+ +95 + | ++ + + + + + | +|
+ +96 + | ++ + + + + + | + /** |
+ +97 + | ++ + + + + + | + * Indicates if this tag is incomplete (has no close >). |
+ +98 + | ++ + + + + + | + * |
+ +99 + | ++ + + + + + | + * @return {@code true} if the tag is incomplete. |
+ +100 + | ++ + + + + + | + */ |
+ +101 + | ++ + + + + + | + public boolean isIncompleteTag() { |
+ +102 + | +
+
+3
+
+
+1. isIncompleteTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::isIncompleteTag → KILLED + +2. isIncompleteTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::isIncompleteTag → KILLED + +3. isIncompleteTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return incompleteTag; |
+ +103 + | ++ + + + + + | + } |
+ +104 + | ++ + + + + + | +|
+ +105 + | ++ + + + + + | + /** |
+ +106 + | ++ + + + + + | + * Returns the source line number where this tag was found. |
+ +107 + | ++ + + + + + | + * Used for displaying a Checkstyle violation. |
+ +108 + | ++ + + + + + | + * |
+ +109 + | ++ + + + + + | + * @return an int line number. |
+ +110 + | ++ + + + + + | + */ |
+ +111 + | ++ + + + + + | + public int getLineNo() { |
+ +112 + | +
+
+1
+
+
+1. getLineNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNo; |
+ +113 + | ++ + + + + + | + } |
+ +114 + | ++ + + + + + | +|
+ +115 + | ++ + + + + + | + /** |
+ +116 + | ++ + + + + + | + * Returns the position with in the comment line where this tag |
+ +117 + | ++ + + + + + | + * was found. Used for displaying a Checkstyle violation. |
+ +118 + | ++ + + + + + | + * |
+ +119 + | ++ + + + + + | + * @return an int relative to zero. |
+ +120 + | ++ + + + + + | + */ |
+ +121 + | ++ + + + + + | + public int getPosition() { |
+ +122 + | +
+
+1
+
+
+1. getPosition : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return position; |
+ +123 + | ++ + + + + + | + } |
+ +124 + | ++ + + + + + | +|
+ +125 + | ++ + + + + + | + @Override |
+ +126 + | ++ + + + + + | + public String toString() { |
+ +127 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "HtmlTag[id='" + id + '\'' |
+ +128 + | ++ + + + + + | + + ", lineNo=" + lineNo |
+ +129 + | ++ + + + + + | + + ", position=" + position |
+ +130 + | ++ + + + + + | + + ", text='" + text + '\'' |
+ +131 + | ++ + + + + + | + + ", closedTag=" + closedTag |
+ +132 + | ++ + + + + + | + + ", incompleteTag=" + incompleteTag + ']'; |
+ +133 + | ++ + + + + + | + } |
+ +134 + | ++ + + + + + | +|
+ +135 + | ++ + + + + + | + /** |
+ +136 + | ++ + + + + + | + * Returns the comment line of text where this tag appears. |
+ +137 + | ++ + + + + + | + * |
+ +138 + | ++ + + + + + | + * @return text of the tag |
+ +139 + | ++ + + + + + | + */ |
+ +140 + | ++ + + + + + | + public String getText() { |
+ +141 + | ++ + + + + + | + final int startOfText = position; |
+ +142 + | +
+
+1
+
+
+1. getText : Replaced integer addition with subtraction → KILLED + + + + |
+ final int endOfText = Math.min(startOfText + MAX_TEXT_LEN, text.length()); |
+ +143 + | +
+
+1
+
+
+1. getText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::getText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return text.substring(startOfText, endOfText); |
+ +144 + | ++ + + + + + | + } |
+ +145 + | ++ + + + + + | +|
+ +146 + | ++ + + + + + | +} |
Mutations | ||
75 | ++ |
+
+
+
+ 1.1 |
+
84 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 6.6 |
+
93 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
102 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
112 | ++ |
+
+
+
+ 1.1 |
+
122 | ++ |
+
+
+
+ 1.1 |
+
127 | ++ |
+
+
+
+ 1.1 2.2 |
+
142 | ++ |
+
+
+
+ 1.1 |
+
143 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +23 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +/** |
+ +29 + | ++ + + + + + | + * <p> |
+ +30 + | ++ + + + + + | + * Checks that Javadocs are located at the correct position. As specified at |
+ +31 + | ++ + + + + + | + * <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html"> |
+ +32 + | ++ + + + + + | + * Documentation Comment Specification for the Standard Doclet</a>, Javadocs are recognized |
+ +33 + | ++ + + + + + | + * only when placed immediately before module, package, class, interface, |
+ +34 + | ++ + + + + + | + * constructor, method, or field declarations. Any other position, like in the |
+ +35 + | ++ + + + + + | + * body of a method, will be ignored by the javadoc tool and is considered |
+ +36 + | ++ + + + + + | + * invalid by this check. |
+ +37 + | ++ + + + + + | + * </p> |
+ +38 + | ++ + + + + + | + * <p> |
+ +39 + | ++ + + + + + | + * To configure the check: |
+ +40 + | ++ + + + + + | + * </p> |
+ +41 + | ++ + + + + + | + * <pre> |
+ +42 + | ++ + + + + + | + * <module name="InvalidJavadocPosition"/> |
+ +43 + | ++ + + + + + | + * </pre> |
+ +44 + | ++ + + + + + | + * <p> |
+ +45 + | ++ + + + + + | + * The following code produces a violation because Javadocs should be before all annotations of |
+ +46 + | ++ + + + + + | + * the Javadoc's target: |
+ +47 + | ++ + + + + + | + * </p> |
+ +48 + | ++ + + + + + | + * <pre> |
+ +49 + | ++ + + + + + | + * @SuppressWarnings("serial") |
+ +50 + | ++ + + + + + | + * /** |
+ +51 + | ++ + + + + + | + * * This comment looks like javadoc but it at an invalid location. |
+ +52 + | ++ + + + + + | + * * Therefore, the text will not get into TestClass.html and the check will produce a violation. |
+ +53 + | ++ + + + + + | + * */ |
+ +54 + | ++ + + + + + | + * public class TestClass { |
+ +55 + | ++ + + + + + | + * } |
+ +56 + | ++ + + + + + | + * </pre> |
+ +57 + | ++ + + + + + | + * |
+ +58 + | ++ + + + + + | + * @since 8.23 |
+ +59 + | ++ + + + + + | + */ |
+ +60 + | ++ + + + + + | +@StatelessCheck |
+ +61 + | ++ + + + + + | +public class InvalidJavadocPositionCheck extends AbstractCheck { |
+ +62 + | ++ + + + + + | +|
+ +63 + | ++ + + + + + | + /** |
+ +64 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +65 + | ++ + + + + + | + * file. |
+ +66 + | ++ + + + + + | + */ |
+ +67 + | ++ + + + + + | + public static final String MSG_KEY = "invalid.position"; |
+ +68 + | ++ + + + + + | +|
+ +69 + | ++ + + + + + | + @Override |
+ +70 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +71 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +72 + | ++ + + + + + | + TokenTypes.BLOCK_COMMENT_BEGIN, |
+ +73 + | ++ + + + + + | + }; |
+ +74 + | ++ + + + + + | + } |
+ +75 + | ++ + + + + + | +|
+ +76 + | ++ + + + + + | + @Override |
+ +77 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +78 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getDefaultTokens(); |
+ +79 + | ++ + + + + + | + } |
+ +80 + | ++ + + + + + | +|
+ +81 + | ++ + + + + + | + @Override |
+ +82 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +83 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getDefaultTokens(); |
+ +84 + | ++ + + + + + | + } |
+ +85 + | ++ + + + + + | +|
+ +86 + | ++ + + + + + | + @Override |
+ +87 + | ++ + + + + + | + public boolean isCommentNodesRequired() { |
+ +88 + | +
+
+2
+
+
+1. isCommentNodesRequired : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheck::isCommentNodesRequired → KILLED + +2. isCommentNodesRequired : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return true; |
+ +89 + | ++ + + + + + | + } |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + @Override |
+ +92 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +93 + | ++ + + + + + | + final String commentContent = JavadocUtil.getBlockCommentContent(ast); |
+ +94 + | ++ + + + + + | +|
+ +95 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (JavadocUtil.isJavadocComment(commentContent) |
+ +96 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ && !JavadocUtil.isCorrectJavadocPosition(ast)) { |
+ +97 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheck::log → KILLED + + + + |
+ log(ast, MSG_KEY); |
+ +98 + | ++ + + + + + | + } |
+ +99 + | ++ + + + + + | + } |
+ +100 + | ++ + + + + + | +|
+ +101 + | ++ + + + + + | +} |
Mutations | ||
71 | ++ |
+
+
+
+ 1.1 |
+
78 | ++ |
+
+
+
+ 1.1 |
+
83 | ++ |
+
+
+
+ 1.1 |
+
88 | ++ |
+
+
+
+ 1.1 2.2 |
+
95 | ++ |
+
+
+
+ 1.1 |
+
96 | ++ |
+
+
+
+ 1.1 |
+
97 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +/** |
+ +23 + | ++ + + + + + | + * Value object for storing data about an invalid Javadoc validTags. |
+ +24 + | ++ + + + + + | + */ |
+ +25 + | ++ + + + + + | +public final class InvalidJavadocTag { |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | + /** The line in which the invalid tag occurs. */ |
+ +28 + | ++ + + + + + | + private final int line; |
+ +29 + | ++ + + + + + | + /** The column in which the invalid tag occurs. */ |
+ +30 + | ++ + + + + + | + private final int col; |
+ +31 + | ++ + + + + + | + /** The name of the invalid tag. */ |
+ +32 + | ++ + + + + + | + private final String name; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | + /** |
+ +35 + | ++ + + + + + | + * Creates an instance. |
+ +36 + | ++ + + + + + | + * |
+ +37 + | ++ + + + + + | + * @param line the line of the tag |
+ +38 + | ++ + + + + + | + * @param col the column of the tag |
+ +39 + | ++ + + + + + | + * @param name the name of the invalid tag |
+ +40 + | ++ + + + + + | + */ |
+ +41 + | ++ + + + + + | + public InvalidJavadocTag(int line, int col, String name) { |
+ +42 + | ++ + + + + + | + this.line = line; |
+ +43 + | ++ + + + + + | + this.col = col; |
+ +44 + | ++ + + + + + | + this.name = name; |
+ +45 + | ++ + + + + + | + } |
+ +46 + | ++ + + + + + | +|
+ +47 + | ++ + + + + + | + /** |
+ +48 + | ++ + + + + + | + * Getter for line field. |
+ +49 + | ++ + + + + + | + * |
+ +50 + | ++ + + + + + | + * @return line field |
+ +51 + | ++ + + + + + | + */ |
+ +52 + | ++ + + + + + | + public int getLine() { |
+ +53 + | +
+
+1
+
+
+1. getLine : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return line; |
+ +54 + | ++ + + + + + | + } |
+ +55 + | ++ + + + + + | +|
+ +56 + | ++ + + + + + | + /** |
+ +57 + | ++ + + + + + | + * Getter for col field. |
+ +58 + | ++ + + + + + | + * |
+ +59 + | ++ + + + + + | + * @return col field |
+ +60 + | ++ + + + + + | + */ |
+ +61 + | ++ + + + + + | + public int getCol() { |
+ +62 + | +
+
+1
+
+
+1. getCol : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return col; |
+ +63 + | ++ + + + + + | + } |
+ +64 + | ++ + + + + + | +|
+ +65 + | ++ + + + + + | + /** |
+ +66 + | ++ + + + + + | + * Getter for name field. |
+ +67 + | ++ + + + + + | + * |
+ +68 + | ++ + + + + + | + * @return name field |
+ +69 + | ++ + + + + + | + */ |
+ +70 + | ++ + + + + + | + public String getName() { |
+ +71 + | +
+
+1
+
+
+1. getName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocTag::getName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return name; |
+ +72 + | ++ + + + + + | + } |
+ +73 + | ++ + + + + + | +|
+ +74 + | ++ + + + + + | +} |
Mutations | ||
53 | ++ |
+
+
+
+ 1.1 |
+
62 | ++ |
+
+
+
+ 1.1 |
+
71 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Set; |
+ +24 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +25 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +26 + | ++ + + + + + | +import java.util.stream.Collectors; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +31 + | ++ + + + + + | +|
+ +32 + | ++ + + + + + | +/** |
+ +33 + | ++ + + + + + | + * <p> |
+ +34 + | ++ + + + + + | + * Checks that a |
+ +35 + | ++ + + + + + | + * <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags"> |
+ +36 + | ++ + + + + + | + * javadoc block tag</a> appears only at the beginning of a line, ignoring |
+ +37 + | ++ + + + + + | + * leading asterisks and white space. A block tag is a token that starts with |
+ +38 + | ++ + + + + + | + * {@code @} symbol and is preceded by a whitespace. This check ignores block |
+ +39 + | ++ + + + + + | + * tags in comments and inside inline tags {@code } and {@literal }. |
+ +40 + | ++ + + + + + | + * </p> |
+ +41 + | ++ + + + + + | + * <p> |
+ +42 + | ++ + + + + + | + * Rationale: according to |
+ +43 + | ++ + + + + + | + * <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags"> |
+ +44 + | ++ + + + + + | + * the specification</a> all javadoc block tags should be placed at the beginning |
+ +45 + | ++ + + + + + | + * of a line. Tags that are not placed at the beginning are treated as plain text. |
+ +46 + | ++ + + + + + | + * To recognize intentional tag placement to text area it is better to escape the |
+ +47 + | ++ + + + + + | + * {@code @} symbol, and all non-escaped tags should be located at the beginning |
+ +48 + | ++ + + + + + | + * of the line. See NOTE section for details on how to escape. |
+ +49 + | ++ + + + + + | + * </p> |
+ +50 + | ++ + + + + + | + * <p> |
+ +51 + | ++ + + + + + | + * To place a tag explicitly as text, escape the {@code @} symbol with HTML entity |
+ +52 + | ++ + + + + + | + * &#64; or place it inside {@code {@code }}, for example: |
+ +53 + | ++ + + + + + | + * </p> |
+ +54 + | ++ + + + + + | + * <pre> |
+ +55 + | ++ + + + + + | + * /** |
+ +56 + | ++ + + + + + | + * * &#64;serial literal in {@code @serial} Javadoc tag. |
+ +57 + | ++ + + + + + | + * */ |
+ +58 + | ++ + + + + + | + * </pre> |
+ +59 + | ++ + + + + + | + * <ul> |
+ +60 + | ++ + + + + + | + * <li> |
+ +61 + | ++ + + + + + | + * Property {@code tags} - Specify the javadoc tags to process. |
+ +62 + | ++ + + + + + | + * Default value is {@code author, deprecated, exception, hidden, param, provides, |
+ +63 + | ++ + + + + + | + * return, see, serial, serialData, serialField, since, throws, uses, version}. |
+ +64 + | ++ + + + + + | + * </li> |
+ +65 + | ++ + + + + + | + * <li> |
+ +66 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +67 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +68 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +69 + | ++ + + + + + | + * Default value is {@code false}. |
+ +70 + | ++ + + + + + | + * </li> |
+ +71 + | ++ + + + + + | + * </ul> |
+ +72 + | ++ + + + + + | + * <p> |
+ +73 + | ++ + + + + + | + * To configure the default check: |
+ +74 + | ++ + + + + + | + * </p> |
+ +75 + | ++ + + + + + | + * <pre> |
+ +76 + | ++ + + + + + | + * <module name="JavadocBlockTagLocation"/> |
+ +77 + | ++ + + + + + | + * </pre> |
+ +78 + | ++ + + + + + | + * <p> |
+ +79 + | ++ + + + + + | + * Example: |
+ +80 + | ++ + + + + + | + * </p> |
+ +81 + | ++ + + + + + | + * <pre> |
+ +82 + | ++ + + + + + | + * /** |
+ +83 + | ++ + + + + + | + * * Escaped tag &#64;version (OK) |
+ +84 + | ++ + + + + + | + * * Plain text with {@code @see} (OK) |
+ +85 + | ++ + + + + + | + * * A @custom tag (OK) |
+ +86 + | ++ + + + + + | + * * <!-- @see commented out (OK) --> |
+ +87 + | ++ + + + + + | + * * email@author (OK) |
+ +88 + | ++ + + + + + | + * * (@param in parentheses) (OK) |
+ +89 + | ++ + + + + + | + * * '@param in single quotes' (OK) |
+ +90 + | ++ + + + + + | + * * @since 1.0 (OK) |
+ +91 + | ++ + + + + + | + * * text @return (violation) |
+ +92 + | ++ + + + + + | + * * * @param (violation) |
+ +93 + | ++ + + + + + | + * +* @serial (violation) |
+ +94 + | ++ + + + + + | + * * @see first (OK) @see second (violation) |
+ +95 + | ++ + + + + + | + * */ |
+ +96 + | ++ + + + + + | + * public int field; |
+ +97 + | ++ + + + + + | + * </pre> |
+ +98 + | ++ + + + + + | + * <p> |
+ +99 + | ++ + + + + + | + * To configure the check to verify tags from |
+ +100 + | ++ + + + + + | + * <a href="https://openjdk.java.net/jeps/8068562">JEP 8068562</a> only: |
+ +101 + | ++ + + + + + | + * </p> |
+ +102 + | ++ + + + + + | + * <pre> |
+ +103 + | ++ + + + + + | + * <module name="JavadocBlockTagLocation"> |
+ +104 + | ++ + + + + + | + * <property name="tags" value="apiNote, implSpec, implNote"/> |
+ +105 + | ++ + + + + + | + * </module> |
+ +106 + | ++ + + + + + | + * </pre> |
+ +107 + | ++ + + + + + | + * <p> |
+ +108 + | ++ + + + + + | + * To configure the check to verify all default tags and some custom tags in addition: |
+ +109 + | ++ + + + + + | + * </p> |
+ +110 + | ++ + + + + + | + * <pre> |
+ +111 + | ++ + + + + + | + * <module name="JavadocBlockTagLocation"> |
+ +112 + | ++ + + + + + | + * <!-- default tags --> |
+ +113 + | ++ + + + + + | + * <property name="tags" value="author, deprecated, exception, hidden"/> |
+ +114 + | ++ + + + + + | + * <property name="tags" value="param, provides, return, see, serial"/> |
+ +115 + | ++ + + + + + | + * <property name="tags" value="serialData, serialField, since, throws"/> |
+ +116 + | ++ + + + + + | + * <property name="tags" value="uses, version"/> |
+ +117 + | ++ + + + + + | + * <!-- additional tags used in the project --> |
+ +118 + | ++ + + + + + | + * <property name="tags" value="noinspection"/> |
+ +119 + | ++ + + + + + | + * </module> |
+ +120 + | ++ + + + + + | + * </pre> |
+ +121 + | ++ + + + + + | + * |
+ +122 + | ++ + + + + + | + * @since 8.24 |
+ +123 + | ++ + + + + + | + */ |
+ +124 + | ++ + + + + + | +@StatelessCheck |
+ +125 + | ++ + + + + + | +public class JavadocBlockTagLocationCheck extends AbstractJavadocCheck { |
+ +126 + | ++ + + + + + | +|
+ +127 + | ++ + + + + + | + /** |
+ +128 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" file. |
+ +129 + | ++ + + + + + | + */ |
+ +130 + | ++ + + + + + | + public static final String MSG_BLOCK_TAG_LOCATION = "javadoc.blockTagLocation"; |
+ +131 + | ++ + + + + + | +|
+ +132 + | ++ + + + + + | + /** |
+ +133 + | ++ + + + + + | + * This regexp is used to extract the javadoc tags. |
+ +134 + | ++ + + + + + | + */ |
+ +135 + | ++ + + + + + | + private static final Pattern JAVADOC_BLOCK_TAG_PATTERN = Pattern.compile("\\s@(\\w+)"); |
+ +136 + | ++ + + + + + | +|
+ +137 + | ++ + + + + + | + /** |
+ +138 + | ++ + + + + + | + * Block tags from Java 11 |
+ +139 + | ++ + + + + + | + * <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html"> |
+ +140 + | ++ + + + + + | + * Documentation Comment Specification</a>. |
+ +141 + | ++ + + + + + | + */ |
+ +142 + | ++ + + + + + | + private static final String[] DEFAULT_TAGS = { |
+ +143 + | ++ + + + + + | + "author", |
+ +144 + | ++ + + + + + | + "deprecated", |
+ +145 + | ++ + + + + + | + "exception", |
+ +146 + | ++ + + + + + | + "hidden", |
+ +147 + | ++ + + + + + | + "param", |
+ +148 + | ++ + + + + + | + "provides", |
+ +149 + | ++ + + + + + | + "return", |
+ +150 + | ++ + + + + + | + "see", |
+ +151 + | ++ + + + + + | + "serial", |
+ +152 + | ++ + + + + + | + "serialData", |
+ +153 + | ++ + + + + + | + "serialField", |
+ +154 + | ++ + + + + + | + "since", |
+ +155 + | ++ + + + + + | + "throws", |
+ +156 + | ++ + + + + + | + "uses", |
+ +157 + | ++ + + + + + | + "version", |
+ +158 + | ++ + + + + + | + }; |
+ +159 + | ++ + + + + + | +|
+ +160 + | ++ + + + + + | + /** |
+ +161 + | ++ + + + + + | + * Specify the javadoc tags to process. |
+ +162 + | ++ + + + + + | + */ |
+ +163 + | ++ + + + + + | + private Set<String> tags; |
+ +164 + | ++ + + + + + | +|
+ +165 + | ++ + + + + + | + /** |
+ +166 + | ++ + + + + + | + * Creates a new {@code JavadocBlockTagLocationCheck} instance with default settings. |
+ +167 + | ++ + + + + + | + */ |
+ +168 + | ++ + + + + + | + public JavadocBlockTagLocationCheck() { |
+ +169 + | +
+
+1
+
+
+1. + + |
+ setTags(DEFAULT_TAGS); |
+ +170 + | ++ + + + + + | + } |
+ +171 + | ++ + + + + + | +|
+ +172 + | ++ + + + + + | + /** |
+ +173 + | ++ + + + + + | + * Setter to specify the javadoc tags to process. |
+ +174 + | ++ + + + + + | + * |
+ +175 + | ++ + + + + + | + * @param values user's values. |
+ +176 + | ++ + + + + + | + */ |
+ +177 + | ++ + + + + + | + public final void setTags(String... values) { |
+ +178 + | ++ + + + + + | + tags = Arrays.stream(values).collect(Collectors.toSet()); |
+ +179 + | ++ + + + + + | + } |
+ +180 + | ++ + + + + + | +|
+ +181 + | ++ + + + + + | + /** |
+ +182 + | ++ + + + + + | + * The javadoc tokens that this check must be registered for. According to |
+ +183 + | ++ + + + + + | + * <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html#block-tags"> |
+ +184 + | ++ + + + + + | + * the specs</a> each block tag must appear at the beginning of a line, otherwise |
+ +185 + | ++ + + + + + | + * it will be interpreted as a plain text. This check looks for a block tag |
+ +186 + | ++ + + + + + | + * in the javadoc text, thus it needs the {@code TEXT} tokens. |
+ +187 + | ++ + + + + + | + * |
+ +188 + | ++ + + + + + | + * @return the javadoc token set this must be registered for. |
+ +189 + | ++ + + + + + | + * @see JavadocTokenTypes |
+ +190 + | ++ + + + + + | + */ |
+ +191 + | ++ + + + + + | + @Override |
+ +192 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +193 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +194 + | ++ + + + + + | + JavadocTokenTypes.TEXT, |
+ +195 + | ++ + + + + + | + }; |
+ +196 + | ++ + + + + + | + } |
+ +197 + | ++ + + + + + | +|
+ +198 + | ++ + + + + + | + @Override |
+ +199 + | ++ + + + + + | + public int[] getAcceptableJavadocTokens() { |
+ +200 + | +
+
+1
+
+
+1. getAcceptableJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck::getAcceptableJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredJavadocTokens(); |
+ +201 + | ++ + + + + + | + } |
+ +202 + | ++ + + + + + | +|
+ +203 + | ++ + + + + + | + @Override |
+ +204 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +205 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredJavadocTokens(); |
+ +206 + | ++ + + + + + | + } |
+ +207 + | ++ + + + + + | +|
+ +208 + | ++ + + + + + | + @Override |
+ +209 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +210 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!isCommentOrInlineTag(ast.getParent())) { |
+ +211 + | ++ + + + + + | + final Matcher tagMatcher = JAVADOC_BLOCK_TAG_PATTERN.matcher(ast.getText()); |
+ +212 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ while (tagMatcher.find()) { |
+ +213 + | ++ + + + + + | + final String tagName = tagMatcher.group(1); |
+ +214 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (tags.contains(tagName)) { |
+ +215 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_BLOCK_TAG_LOCATION, tagName); |
+ +216 + | ++ + + + + + | + } |
+ +217 + | ++ + + + + + | + } |
+ +218 + | ++ + + + + + | + } |
+ +219 + | ++ + + + + + | + } |
+ +220 + | ++ + + + + + | +|
+ +221 + | ++ + + + + + | + /** |
+ +222 + | ++ + + + + + | + * Checks if the node can contain an unescaped block tag without violation. |
+ +223 + | ++ + + + + + | + * |
+ +224 + | ++ + + + + + | + * @param node to check |
+ +225 + | ++ + + + + + | + * @return {@code true} if node is {@code @code}, {@code @literal} or HTML comment. |
+ +226 + | ++ + + + + + | + */ |
+ +227 + | ++ + + + + + | + private static boolean isCommentOrInlineTag(DetailNode node) { |
+ +228 + | +
+
+3
+
+
+1. isCommentOrInlineTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck::isCommentOrInlineTag → KILLED + +2. isCommentOrInlineTag : negated conditional → KILLED + +3. isCommentOrInlineTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return node.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG |
+ +229 + | +
+
+1
+
+
+1. isCommentOrInlineTag : negated conditional → KILLED + + + + |
+ || node.getType() == JavadocTokenTypes.HTML_COMMENT; |
+ +230 + | ++ + + + + + | + } |
+ +231 + | ++ + + + + + | +|
+ +232 + | ++ + + + + + | +} |
Mutations | ||
169 | ++ |
+
+
+
+ 1.1 |
+
193 | ++ |
+
+
+
+ 1.1 |
+
200 | ++ |
+
+
+
+ 1.1 |
+
205 | ++ |
+
+
+
+ 1.1 |
+
210 | ++ |
+
+
+
+ 1.1 |
+
212 | ++ |
+
+
+
+ 1.1 |
+
214 | ++ |
+
+
+
+ 1.1 |
+
215 | ++ |
+
+
+
+ 1.1 |
+
228 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
229 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Locale; |
+ +23 + | ++ + + + + + | +|
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.TokenUtil; |
+ +30 + | ++ + + + + + | +|
+ +31 + | ++ + + + + + | +/** |
+ +32 + | ++ + + + + + | + * <p> |
+ +33 + | ++ + + + + + | + * Checks that the Javadoc content begins from the same position |
+ +34 + | ++ + + + + + | + * for all Javadoc comments in the project. Any leading asterisks and spaces |
+ +35 + | ++ + + + + + | + * are not counted as the beginning of the content and are therefore ignored. |
+ +36 + | ++ + + + + + | + * </p> |
+ +37 + | ++ + + + + + | + * <p> |
+ +38 + | ++ + + + + + | + * It is possible to enforce two different styles: |
+ +39 + | ++ + + + + + | + * </p> |
+ +40 + | ++ + + + + + | + * <ul> |
+ +41 + | ++ + + + + + | + * <li> |
+ +42 + | ++ + + + + + | + * {@code first_line} - Javadoc content starts from the first line: |
+ +43 + | ++ + + + + + | + * <pre> |
+ +44 + | ++ + + + + + | + * /** Summary text. |
+ +45 + | ++ + + + + + | + * * More details. |
+ +46 + | ++ + + + + + | + * */ |
+ +47 + | ++ + + + + + | + * public void method(); |
+ +48 + | ++ + + + + + | + * </pre> |
+ +49 + | ++ + + + + + | + * </li> |
+ +50 + | ++ + + + + + | + * <li> |
+ +51 + | ++ + + + + + | + * {@code second_line} - Javadoc content starts from the second line: |
+ +52 + | ++ + + + + + | + * <pre> |
+ +53 + | ++ + + + + + | + * /** |
+ +54 + | ++ + + + + + | + * * Summary text. |
+ +55 + | ++ + + + + + | + * * More details. |
+ +56 + | ++ + + + + + | + * */ |
+ +57 + | ++ + + + + + | + * public void method(); |
+ +58 + | ++ + + + + + | + * </pre> |
+ +59 + | ++ + + + + + | + * </li> |
+ +60 + | ++ + + + + + | + * </ul> |
+ +61 + | ++ + + + + + | + * <p> |
+ +62 + | ++ + + + + + | + * This check does not validate the Javadoc summary itself nor its presence. |
+ +63 + | ++ + + + + + | + * The check will not report any violations for missing or malformed javadoc summary. |
+ +64 + | ++ + + + + + | + * To validate the Javadoc summary use |
+ +65 + | ++ + + + + + | + * <a href="https://checkstyle.org/config_javadoc.html#SummaryJavadoc">SummaryJavadoc</a> check. |
+ +66 + | ++ + + + + + | + * </p> |
+ +67 + | ++ + + + + + | + * <p> |
+ +68 + | ++ + + + + + | + * The <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/doc-comment-spec.html"> |
+ +69 + | ++ + + + + + | + * Documentation Comment Specification</a> permits leading asterisks on the first line. |
+ +70 + | ++ + + + + + | + * For these Javadoc comments: |
+ +71 + | ++ + + + + + | + * </p> |
+ +72 + | ++ + + + + + | + * <pre> |
+ +73 + | ++ + + + + + | + * /*** |
+ +74 + | ++ + + + + + | + * * Some text. |
+ +75 + | ++ + + + + + | + * */ |
+ +76 + | ++ + + + + + | + * /************ |
+ +77 + | ++ + + + + + | + * * Some text. |
+ +78 + | ++ + + + + + | + * */ |
+ +79 + | ++ + + + + + | + * /** ** |
+ +80 + | ++ + + + + + | + * * Some text. |
+ +81 + | ++ + + + + + | + * */ |
+ +82 + | ++ + + + + + | + * </pre> |
+ +83 + | ++ + + + + + | + * <p> |
+ +84 + | ++ + + + + + | + * The documentation generated will be just "Some text." without any asterisks. |
+ +85 + | ++ + + + + + | + * Since these asterisks will not appear in the generated documentation, |
+ +86 + | ++ + + + + + | + * they should not be considered as the beginning of the Javadoc content. |
+ +87 + | ++ + + + + + | + * In such cases, the check assumes that the Javadoc content begins on the second line. |
+ +88 + | ++ + + + + + | + * </p> |
+ +89 + | ++ + + + + + | + * <ul> |
+ +90 + | ++ + + + + + | + * <li> |
+ +91 + | ++ + + + + + | + * Property {@code location} - Specify the policy on placement of the Javadoc content. |
+ +92 + | ++ + + + + + | + * Default value is {@code second_line}. |
+ +93 + | ++ + + + + + | + * </li> |
+ +94 + | ++ + + + + + | + * </ul> |
+ +95 + | ++ + + + + + | + * <p> |
+ +96 + | ++ + + + + + | + * By default Check validate that the Javadoc content starts from the second line: |
+ +97 + | ++ + + + + + | + * </p> |
+ +98 + | ++ + + + + + | + * <pre> |
+ +99 + | ++ + + + + + | + * <module name="JavadocContentLocationCheck"/> |
+ +100 + | ++ + + + + + | + * </pre> |
+ +101 + | ++ + + + + + | + * <p> |
+ +102 + | ++ + + + + + | + * This setting produces a violation for each multi-line comment starting |
+ +103 + | ++ + + + + + | + * on the same line as the initial asterisks: |
+ +104 + | ++ + + + + + | + * </p> |
+ +105 + | ++ + + + + + | + * <pre> |
+ +106 + | ++ + + + + + | + * /** This comment causes a violation because it starts from the first line |
+ +107 + | ++ + + + + + | + * * and spans several lines. |
+ +108 + | ++ + + + + + | + * */ |
+ +109 + | ++ + + + + + | + * /** |
+ +110 + | ++ + + + + + | + * * This comment is OK because it starts from the second line. |
+ +111 + | ++ + + + + + | + * */ |
+ +112 + | ++ + + + + + | + * /** This comment is OK because it is on the single line. */ |
+ +113 + | ++ + + + + + | + * </pre> |
+ +114 + | ++ + + + + + | + * <p> |
+ +115 + | ++ + + + + + | + * To ensure that Javadoc content starts from the first line: |
+ +116 + | ++ + + + + + | + * </p> |
+ +117 + | ++ + + + + + | + * <pre> |
+ +118 + | ++ + + + + + | + * <module name="JavadocContentLocationCheck"> |
+ +119 + | ++ + + + + + | + * <property name="location" value="first_line"/> |
+ +120 + | ++ + + + + + | + * </module> |
+ +121 + | ++ + + + + + | + * </pre> |
+ +122 + | ++ + + + + + | + * <p> |
+ +123 + | ++ + + + + + | + * This setting produces a violation for each comment not |
+ +124 + | ++ + + + + + | + * starting on the same line as the initial asterisks: |
+ +125 + | ++ + + + + + | + * </p> |
+ +126 + | ++ + + + + + | + * <pre> |
+ +127 + | ++ + + + + + | + * /** This comment is OK because it starts on the first line. |
+ +128 + | ++ + + + + + | + * * There may be additional text. |
+ +129 + | ++ + + + + + | + * */ |
+ +130 + | ++ + + + + + | + * /** |
+ +131 + | ++ + + + + + | + * * This comment causes a violation because it starts on the second line. |
+ +132 + | ++ + + + + + | + * */ |
+ +133 + | ++ + + + + + | + * /** This single-line comment also is OK. */ |
+ +134 + | ++ + + + + + | + * </pre> |
+ +135 + | ++ + + + + + | + * |
+ +136 + | ++ + + + + + | + * @since 8.27 |
+ +137 + | ++ + + + + + | + */ |
+ +138 + | ++ + + + + + | +@StatelessCheck |
+ +139 + | ++ + + + + + | +public class JavadocContentLocationCheck extends AbstractCheck { |
+ +140 + | ++ + + + + + | +|
+ +141 + | ++ + + + + + | + /** |
+ +142 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" file. |
+ +143 + | ++ + + + + + | + */ |
+ +144 + | ++ + + + + + | + public static final String MSG_JAVADOC_CONTENT_FIRST_LINE = "javadoc.content.first.line"; |
+ +145 + | ++ + + + + + | +|
+ +146 + | ++ + + + + + | + /** |
+ +147 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" file. |
+ +148 + | ++ + + + + + | + */ |
+ +149 + | ++ + + + + + | + public static final String MSG_JAVADOC_CONTENT_SECOND_LINE = "javadoc.content.second.line"; |
+ +150 + | ++ + + + + + | +|
+ +151 + | ++ + + + + + | + /** |
+ +152 + | ++ + + + + + | + * Specify the policy on placement of the Javadoc content. |
+ +153 + | ++ + + + + + | + */ |
+ +154 + | ++ + + + + + | + private JavadocContentLocationOption location = JavadocContentLocationOption.SECOND_LINE; |
+ +155 + | ++ + + + + + | +|
+ +156 + | ++ + + + + + | + @Override |
+ +157 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +158 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +159 + | ++ + + + + + | + TokenTypes.BLOCK_COMMENT_BEGIN, |
+ +160 + | ++ + + + + + | + }; |
+ +161 + | ++ + + + + + | + } |
+ +162 + | ++ + + + + + | +|
+ +163 + | ++ + + + + + | + @Override |
+ +164 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +165 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +166 + | ++ + + + + + | + } |
+ +167 + | ++ + + + + + | +|
+ +168 + | ++ + + + + + | + @Override |
+ +169 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +170 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +171 + | ++ + + + + + | + } |
+ +172 + | ++ + + + + + | +|
+ +173 + | ++ + + + + + | + @Override |
+ +174 + | ++ + + + + + | + public boolean isCommentNodesRequired() { |
+ +175 + | +
+
+2
+
+
+1. isCommentNodesRequired : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::isCommentNodesRequired → KILLED + +2. isCommentNodesRequired : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return true; |
+ +176 + | ++ + + + + + | + } |
+ +177 + | ++ + + + + + | +|
+ +178 + | ++ + + + + + | + /** |
+ +179 + | ++ + + + + + | + * Setter to specify the policy on placement of the Javadoc content. |
+ +180 + | ++ + + + + + | + * |
+ +181 + | ++ + + + + + | + * @param value string to decode location from |
+ +182 + | ++ + + + + + | + * @throws IllegalArgumentException if unable to decode |
+ +183 + | ++ + + + + + | + */ |
+ +184 + | ++ + + + + + | + public void setLocation(String value) { |
+ +185 + | ++ + + + + + | + location = JavadocContentLocationOption.valueOf(value.trim().toUpperCase(Locale.ENGLISH)); |
+ +186 + | ++ + + + + + | + } |
+ +187 + | ++ + + + + + | +|
+ +188 + | ++ + + + + + | + @Override |
+ +189 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +190 + | +
+
+2
+
+
+1. visitToken : negated conditional → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (isMultilineComment(ast) && JavadocUtil.isJavadocComment(ast)) { |
+ +191 + | ++ + + + + + | + final String commentContent = JavadocUtil.getJavadocCommentContent(ast); |
+ +192 + | ++ + + + + + | + final int indexOfFirstNonBlankLine = findIndexOfFirstNonBlankLine(commentContent); |
+ +193 + | +
+
+2
+
+
+1. visitToken : changed conditional boundary → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (indexOfFirstNonBlankLine >= 0) { |
+ +194 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (location == JavadocContentLocationOption.FIRST_LINE) { |
+ +195 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (indexOfFirstNonBlankLine != 0) { |
+ +196 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::log → KILLED + + + + |
+ log(ast, MSG_JAVADOC_CONTENT_FIRST_LINE); |
+ +197 + | ++ + + + + + | + } |
+ +198 + | ++ + + + + + | + } |
+ +199 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ else if (indexOfFirstNonBlankLine != 1) { |
+ +200 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::log → KILLED + + + + |
+ log(ast, MSG_JAVADOC_CONTENT_SECOND_LINE); |
+ +201 + | ++ + + + + + | + } |
+ +202 + | ++ + + + + + | + } |
+ +203 + | ++ + + + + + | + } |
+ +204 + | ++ + + + + + | + } |
+ +205 + | ++ + + + + + | +|
+ +206 + | ++ + + + + + | + /** |
+ +207 + | ++ + + + + + | + * Checks if a DetailAST of type {@code TokenTypes.BLOCK_COMMENT_BEGIN} span |
+ +208 + | ++ + + + + + | + * more than one line. The node always has at least one child of the type |
+ +209 + | ++ + + + + + | + * {@code TokenTypes.BLOCK_COMMENT_END}. |
+ +210 + | ++ + + + + + | + * |
+ +211 + | ++ + + + + + | + * @param node node to check |
+ +212 + | ++ + + + + + | + * @return {@code true} for multi-line comment nodes |
+ +213 + | ++ + + + + + | + */ |
+ +214 + | ++ + + + + + | + private static boolean isMultilineComment(DetailAST node) { |
+ +215 + | +
+
+3
+
+
+1. isMultilineComment : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheck::isMultilineComment → KILLED + +2. isMultilineComment : negated conditional → KILLED + +3. isMultilineComment : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return !TokenUtil.areOnSameLine(node, node.getLastChild()); |
+ +216 + | ++ + + + + + | + } |
+ +217 + | ++ + + + + + | +|
+ +218 + | ++ + + + + + | + /** |
+ +219 + | ++ + + + + + | + * Returns the index of the first non-blank line. |
+ +220 + | ++ + + + + + | + * All lines consists only of asterisks and whitespaces are treated as blank. |
+ +221 + | ++ + + + + + | + * |
+ +222 + | ++ + + + + + | + * @param commentContent Javadoc content to process |
+ +223 + | ++ + + + + + | + * @return the index of the first non-blank line or {@code -1} if all lines are blank |
+ +224 + | ++ + + + + + | + */ |
+ +225 + | ++ + + + + + | + private static int findIndexOfFirstNonBlankLine(String commentContent) { |
+ +226 + | ++ + + + + + | + int lineNo = 0; |
+ +227 + | ++ + + + + + | + boolean noContent = true; |
+ +228 + | +
+
+3
+
+
+1. findIndexOfFirstNonBlankLine : changed conditional boundary → KILLED + +2. findIndexOfFirstNonBlankLine : Changed increment from 1 to -1 → KILLED + +3. findIndexOfFirstNonBlankLine : negated conditional → KILLED + + + + |
+ for (int i = 0; i < commentContent.length(); ++i) { |
+ +229 + | ++ + + + + + | + final char character = commentContent.charAt(i); |
+ +230 + | +
+
+1
+
+
+1. findIndexOfFirstNonBlankLine : negated conditional → KILLED + + + + |
+ if (character == '\n') { |
+ +231 + | +
+
+1
+
+
+1. findIndexOfFirstNonBlankLine : Changed increment from 1 to -1 → KILLED + + + + |
+ ++lineNo; |
+ +232 + | ++ + + + + + | + } |
+ +233 + | +
+
+2
+
+
+1. findIndexOfFirstNonBlankLine : negated conditional → KILLED + +2. findIndexOfFirstNonBlankLine : negated conditional → KILLED + + + + |
+ else if (character != '*' && !Character.isWhitespace(character)) { |
+ +234 + | ++ + + + + + | + noContent = false; |
+ +235 + | ++ + + + + + | + break; |
+ +236 + | ++ + + + + + | + } |
+ +237 + | ++ + + + + + | + } |
+ +238 + | +
+
+1
+
+
+1. findIndexOfFirstNonBlankLine : negated conditional → KILLED + + + + |
+ if (noContent) { |
+ +239 + | ++ + + + + + | + lineNo = -1; |
+ +240 + | ++ + + + + + | + } |
+ +241 + | +
+
+1
+
+
+1. findIndexOfFirstNonBlankLine : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNo; |
+ +242 + | ++ + + + + + | + } |
+ +243 + | ++ + + + + + | +|
+ +244 + | ++ + + + + + | +} |
Mutations | ||
158 | ++ |
+
+
+
+ 1.1 |
+
165 | ++ |
+
+
+
+ 1.1 |
+
170 | ++ |
+
+
+
+ 1.1 |
+
175 | ++ |
+
+
+
+ 1.1 2.2 |
+
190 | ++ |
+
+
+
+ 1.1 2.2 |
+
193 | ++ |
+
+
+
+ 1.1 2.2 |
+
194 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 |
+
196 | ++ |
+
+
+
+ 1.1 |
+
199 | ++ |
+
+
+
+ 1.1 |
+
200 | ++ |
+
+
+
+ 1.1 |
+
215 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
228 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
230 | ++ |
+
+
+
+ 1.1 |
+
231 | ++ |
+
+
+
+ 1.1 |
+
233 | ++ |
+
+
+
+ 1.1 2.2 |
+
238 | ++ |
+
+
+
+ 1.1 |
+
241 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayDeque; |
+ +23 + | ++ + + + + + | +import java.util.ArrayList; |
+ +24 + | ++ + + + + + | +import java.util.Arrays; |
+ +25 + | ++ + + + + + | +import java.util.Collections; |
+ +26 + | ++ + + + + + | +import java.util.Deque; |
+ +27 + | ++ + + + + + | +import java.util.HashMap; |
+ +28 + | ++ + + + + + | +import java.util.HashSet; |
+ +29 + | ++ + + + + + | +import java.util.Iterator; |
+ +30 + | ++ + + + + + | +import java.util.List; |
+ +31 + | ++ + + + + + | +import java.util.ListIterator; |
+ +32 + | ++ + + + + + | +import java.util.Map; |
+ +33 + | ++ + + + + + | +import java.util.Set; |
+ +34 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +35 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +36 + | ++ + + + + + | +|
+ +37 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.FileStatefulCheck; |
+ +38 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +39 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +40 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +41 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FullIdent; |
+ +42 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +43 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +44 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +45 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil; |
+ +46 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CheckUtil; |
+ +47 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +48 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +49 + | ++ + + + + + | +|
+ +50 + | ++ + + + + + | +/** |
+ +51 + | ++ + + + + + | + * <p> |
+ +52 + | ++ + + + + + | + * Checks the Javadoc of a method or constructor. |
+ +53 + | ++ + + + + + | + * The scope to verify is specified using the {@code Scope} class and defaults |
+ +54 + | ++ + + + + + | + * to {@code Scope.PRIVATE}. To verify another scope, set property scope to |
+ +55 + | ++ + + + + + | + * a different <a href="https://checkstyle.org/property_types.html#scope">scope</a>. |
+ +56 + | ++ + + + + + | + * </p> |
+ +57 + | ++ + + + + + | + * <p> |
+ +58 + | ++ + + + + + | + * Violates parameters and type parameters for which no param tags are present can |
+ +59 + | ++ + + + + + | + * be suppressed by defining property {@code allowMissingParamTags}. |
+ +60 + | ++ + + + + + | + * </p> |
+ +61 + | ++ + + + + + | + * <p> |
+ +62 + | ++ + + + + + | + * Violates methods which return non-void but for which no return tag is present can |
+ +63 + | ++ + + + + + | + * be suppressed by defining property {@code allowMissingReturnTag}. |
+ +64 + | ++ + + + + + | + * </p> |
+ +65 + | ++ + + + + + | + * <p> |
+ +66 + | ++ + + + + + | + * Violates exceptions which are declared to be thrown (by {@code throws} in the method |
+ +67 + | ++ + + + + + | + * signature or by {@code throw new} in the method body), but for which no throws tag is |
+ +68 + | ++ + + + + + | + * present by activation of property {@code validateThrows}. |
+ +69 + | ++ + + + + + | + * Note that {@code throw new} is not checked in the following places: |
+ +70 + | ++ + + + + + | + * </p> |
+ +71 + | ++ + + + + + | + * <ul> |
+ +72 + | ++ + + + + + | + * <li> |
+ +73 + | ++ + + + + + | + * Inside a try block (with catch). It is not possible to determine if the thrown |
+ +74 + | ++ + + + + + | + * exception can be caught by the catch block as there is no knowledge of the |
+ +75 + | ++ + + + + + | + * inheritance hierarchy, so the try block is ignored entirely. However, catch |
+ +76 + | ++ + + + + + | + * and finally blocks, as well as try blocks without catch, are still checked. |
+ +77 + | ++ + + + + + | + * </li> |
+ +78 + | ++ + + + + + | + * <li> |
+ +79 + | ++ + + + + + | + * Local classes, anonymous classes and lambda expressions. It is not known when the |
+ +80 + | ++ + + + + + | + * throw statements inside such classes are going to be evaluated, so they are ignored. |
+ +81 + | ++ + + + + + | + * </li> |
+ +82 + | ++ + + + + + | + * </ul> |
+ +83 + | ++ + + + + + | + * <p> |
+ +84 + | ++ + + + + + | + * ATTENTION: Checkstyle does not have information about hierarchy of exception types |
+ +85 + | ++ + + + + + | + * so usage of base class is considered as separate exception type. |
+ +86 + | ++ + + + + + | + * As workaround you need to specify both types in javadoc (parent and exact type). |
+ +87 + | ++ + + + + + | + * </p> |
+ +88 + | ++ + + + + + | + * <p> |
+ +89 + | ++ + + + + + | + * Javadoc is not required on a method that is tagged with the {@code @Override} |
+ +90 + | ++ + + + + + | + * annotation. However under Java 5 it is not possible to mark a method required |
+ +91 + | ++ + + + + + | + * for an interface (this was <i>corrected</i> under Java 6). Hence Checkstyle |
+ +92 + | ++ + + + + + | + * supports using the convention of using a single {@code {@inheritDoc}} tag |
+ +93 + | ++ + + + + + | + * instead of all the other tags. |
+ +94 + | ++ + + + + + | + * </p> |
+ +95 + | ++ + + + + + | + * <p> |
+ +96 + | ++ + + + + + | + * Note that only inheritable items will allow the {@code {@inheritDoc}} |
+ +97 + | ++ + + + + + | + * tag to be used in place of comments. Static methods at all visibilities, |
+ +98 + | ++ + + + + + | + * private non-static methods and constructors are not inheritable. |
+ +99 + | ++ + + + + + | + * </p> |
+ +100 + | ++ + + + + + | + * <p> |
+ +101 + | ++ + + + + + | + * For example, if the following method is implementing a method required by |
+ +102 + | ++ + + + + + | + * an interface, then the Javadoc could be done as: |
+ +103 + | ++ + + + + + | + * </p> |
+ +104 + | ++ + + + + + | + * <pre> |
+ +105 + | ++ + + + + + | + * /** {@inheritDoc} */ |
+ +106 + | ++ + + + + + | + * public int checkReturnTag(final int aTagIndex, |
+ +107 + | ++ + + + + + | + * JavadocTag[] aTags, |
+ +108 + | ++ + + + + + | + * int aLineNo) |
+ +109 + | ++ + + + + + | + * </pre> |
+ +110 + | ++ + + + + + | + * <ul> |
+ +111 + | ++ + + + + + | + * <li> |
+ +112 + | ++ + + + + + | + * Property {@code allowedAnnotations} - Specify the list of annotations |
+ +113 + | ++ + + + + + | + * that allow missed documentation. |
+ +114 + | ++ + + + + + | + * Default value is {@code Override}. |
+ +115 + | ++ + + + + + | + * </li> |
+ +116 + | ++ + + + + + | + * <li> |
+ +117 + | ++ + + + + + | + * Property {@code validateThrows} - Control whether to validate {@code throws} tags. |
+ +118 + | ++ + + + + + | + * Default value is {@code false}. |
+ +119 + | ++ + + + + + | + * </li> |
+ +120 + | ++ + + + + + | + * <li> |
+ +121 + | ++ + + + + + | + * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. |
+ +122 + | ++ + + + + + | + * Default value is {@code private}. |
+ +123 + | ++ + + + + + | + * </li> |
+ +124 + | ++ + + + + + | + * <li> |
+ +125 + | ++ + + + + + | + * Property {@code excludeScope} - Specify the visibility scope where Javadoc comments |
+ +126 + | ++ + + + + + | + * are not checked. |
+ +127 + | ++ + + + + + | + * Default value is {@code null}. |
+ +128 + | ++ + + + + + | + * </li> |
+ +129 + | ++ + + + + + | + * <li> |
+ +130 + | ++ + + + + + | + * Property {@code allowMissingParamTags} - Control whether to ignore violations |
+ +131 + | ++ + + + + + | + * when a method has parameters but does not have matching {@code param} tags in the javadoc. |
+ +132 + | ++ + + + + + | + * Default value is {@code false}. |
+ +133 + | ++ + + + + + | + * </li> |
+ +134 + | ++ + + + + + | + * <li> |
+ +135 + | ++ + + + + + | + * Property {@code allowMissingReturnTag} - Control whether to ignore violations |
+ +136 + | ++ + + + + + | + * when a method returns non-void type and does not have a {@code return} tag in the javadoc. |
+ +137 + | ++ + + + + + | + * Default value is {@code false}. |
+ +138 + | ++ + + + + + | + * </li> |
+ +139 + | ++ + + + + + | + * <li> |
+ +140 + | ++ + + + + + | + * Property {@code tokens} - tokens to check Default value is: |
+ +141 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF"> |
+ +142 + | ++ + + + + + | + * METHOD_DEF</a>, |
+ +143 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF"> |
+ +144 + | ++ + + + + + | + * CTOR_DEF</a>, |
+ +145 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF"> |
+ +146 + | ++ + + + + + | + * ANNOTATION_FIELD_DEF</a>. |
+ +147 + | ++ + + + + + | + * </li> |
+ +148 + | ++ + + + + + | + * </ul> |
+ +149 + | ++ + + + + + | + * <p> |
+ +150 + | ++ + + + + + | + * To configure the default check: |
+ +151 + | ++ + + + + + | + * </p> |
+ +152 + | ++ + + + + + | + * <pre> |
+ +153 + | ++ + + + + + | + * <module name="JavadocMethod"/> |
+ +154 + | ++ + + + + + | + * </pre> |
+ +155 + | ++ + + + + + | + * <p> |
+ +156 + | ++ + + + + + | + * To configure the check for {@code public} scope, ignoring any missing param tags is: |
+ +157 + | ++ + + + + + | + * </p> |
+ +158 + | ++ + + + + + | + * <pre> |
+ +159 + | ++ + + + + + | + * <module name="JavadocMethod"> |
+ +160 + | ++ + + + + + | + * <property name="scope" value="public"/> |
+ +161 + | ++ + + + + + | + * <property name="allowMissingParamTags" value="true"/> |
+ +162 + | ++ + + + + + | + * </module> |
+ +163 + | ++ + + + + + | + * </pre> |
+ +164 + | ++ + + + + + | + * <p> |
+ +165 + | ++ + + + + + | + * To configure the check for methods which are in {@code private}, |
+ +166 + | ++ + + + + + | + * but not in {@code protected} scope: |
+ +167 + | ++ + + + + + | + * </p> |
+ +168 + | ++ + + + + + | + * <pre> |
+ +169 + | ++ + + + + + | + * <module name="JavadocMethod"> |
+ +170 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +171 + | ++ + + + + + | + * <property name="excludeScope" value="protected"/> |
+ +172 + | ++ + + + + + | + * </module> |
+ +173 + | ++ + + + + + | + * </pre> |
+ +174 + | ++ + + + + + | + * <p> |
+ +175 + | ++ + + + + + | + * To configure the check to validate {@code throws} tags, you can use following config. |
+ +176 + | ++ + + + + + | + * </p> |
+ +177 + | ++ + + + + + | + * <pre> |
+ +178 + | ++ + + + + + | + * <module name="JavadocMethod"> |
+ +179 + | ++ + + + + + | + * <property name="validateThrows" value="true"/> |
+ +180 + | ++ + + + + + | + * </module> |
+ +181 + | ++ + + + + + | + * </pre> |
+ +182 + | ++ + + + + + | + * <pre> |
+ +183 + | ++ + + + + + | + * /** |
+ +184 + | ++ + + + + + | + * * Actual exception thrown is child class of class that is declared in throws. |
+ +185 + | ++ + + + + + | + * * It is limitation of checkstyle (as checkstyle does not know type hierarchy). |
+ +186 + | ++ + + + + + | + * * Javadoc is valid not declaring FileNotFoundException |
+ +187 + | ++ + + + + + | + * * BUT checkstyle can not distinguish relationship between exceptions. |
+ +188 + | ++ + + + + + | + * * @param file some file |
+ +189 + | ++ + + + + + | + * * @throws IOException if some problem |
+ +190 + | ++ + + + + + | + * */ |
+ +191 + | ++ + + + + + | + * public void doSomething8(File file) throws IOException { |
+ +192 + | ++ + + + + + | + * if (file == null) { |
+ +193 + | ++ + + + + + | + * throw new FileNotFoundException(); // violation |
+ +194 + | ++ + + + + + | + * } |
+ +195 + | ++ + + + + + | + * } |
+ +196 + | ++ + + + + + | + * |
+ +197 + | ++ + + + + + | + * /** |
+ +198 + | ++ + + + + + | + * * Exact throw type referencing in javadoc even first is parent of second type. |
+ +199 + | ++ + + + + + | + * * It is a limitation of checkstyle (as checkstyle does not know type hierarchy). |
+ +200 + | ++ + + + + + | + * * This javadoc is valid for checkstyle and for javadoc tool. |
+ +201 + | ++ + + + + + | + * * @param file some file |
+ +202 + | ++ + + + + + | + * * @throws IOException if some problem |
+ +203 + | ++ + + + + + | + * * @throws FileNotFoundException if file is not found |
+ +204 + | ++ + + + + + | + * */ |
+ +205 + | ++ + + + + + | + * public void doSomething9(File file) throws IOException { |
+ +206 + | ++ + + + + + | + * if (file == null) { |
+ +207 + | ++ + + + + + | + * throw new FileNotFoundException(); |
+ +208 + | ++ + + + + + | + * } |
+ +209 + | ++ + + + + + | + * } |
+ +210 + | ++ + + + + + | + * |
+ +211 + | ++ + + + + + | + * /** |
+ +212 + | ++ + + + + + | + * * Ignore try block, but keep catch and finally blocks. |
+ +213 + | ++ + + + + + | + * * |
+ +214 + | ++ + + + + + | + * * @param s String to parse |
+ +215 + | ++ + + + + + | + * * @return A positive integer |
+ +216 + | ++ + + + + + | + * */ |
+ +217 + | ++ + + + + + | + * public int parsePositiveInt(String s) { |
+ +218 + | ++ + + + + + | + * try { |
+ +219 + | ++ + + + + + | + * int value = Integer.parseInt(s); |
+ +220 + | ++ + + + + + | + * if (value <= 0) { |
+ +221 + | ++ + + + + + | + * throw new NumberFormatException(value + " is negative/zero"); // ok, try |
+ +222 + | ++ + + + + + | + * } |
+ +223 + | ++ + + + + + | + * return value; |
+ +224 + | ++ + + + + + | + * } catch (NumberFormatException ex) { |
+ +225 + | ++ + + + + + | + * throw new IllegalArgumentException("Invalid number", ex); // violation, catch |
+ +226 + | ++ + + + + + | + * } finally { |
+ +227 + | ++ + + + + + | + * throw new IllegalStateException("Should never reach here"); // violation, finally |
+ +228 + | ++ + + + + + | + * } |
+ +229 + | ++ + + + + + | + * } |
+ +230 + | ++ + + + + + | + * |
+ +231 + | ++ + + + + + | + * /** |
+ +232 + | ++ + + + + + | + * * Try block without catch is not ignored. |
+ +233 + | ++ + + + + + | + * * |
+ +234 + | ++ + + + + + | + * * @return a String from standard input, if there is one |
+ +235 + | ++ + + + + + | + * */ |
+ +236 + | ++ + + + + + | + * public String readLine() { |
+ +237 + | ++ + + + + + | + * try (Scanner sc = new Scanner(System.in)) { |
+ +238 + | ++ + + + + + | + * if (!sc.hasNext()) { |
+ +239 + | ++ + + + + + | + * throw new IllegalStateException("Empty input"); // violation, not caught |
+ +240 + | ++ + + + + + | + * } |
+ +241 + | ++ + + + + + | + * return sc.next(); |
+ +242 + | ++ + + + + + | + * } |
+ +243 + | ++ + + + + + | + * } |
+ +244 + | ++ + + + + + | + * |
+ +245 + | ++ + + + + + | + * /** |
+ +246 + | ++ + + + + + | + * * Lambda expressions are ignored as we do not know when the exception will be thrown. |
+ +247 + | ++ + + + + + | + * * |
+ +248 + | ++ + + + + + | + * * @param s a String to be printed at some point in the future |
+ +249 + | ++ + + + + + | + * * @return a Runnable to be executed when the string is to be printed |
+ +250 + | ++ + + + + + | + * */ |
+ +251 + | ++ + + + + + | + * public Runnable printLater(String s) { |
+ +252 + | ++ + + + + + | + * return () -> { |
+ +253 + | ++ + + + + + | + * if (s == null) { |
+ +254 + | ++ + + + + + | + * throw new NullPointerException(); // ok |
+ +255 + | ++ + + + + + | + * } |
+ +256 + | ++ + + + + + | + * System.out.println(s); |
+ +257 + | ++ + + + + + | + * }; |
+ +258 + | ++ + + + + + | + * } |
+ +259 + | ++ + + + + + | + * </pre> |
+ +260 + | ++ + + + + + | + * |
+ +261 + | ++ + + + + + | + * @since 3.0 |
+ +262 + | ++ + + + + + | + */ |
+ +263 + | ++ + + + + + | +@FileStatefulCheck |
+ +264 + | ++ + + + + + | +public class JavadocMethodCheck extends AbstractCheck { |
+ +265 + | ++ + + + + + | +|
+ +266 + | ++ + + + + + | + /** |
+ +267 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +268 + | ++ + + + + + | + * file. |
+ +269 + | ++ + + + + + | + */ |
+ +270 + | ++ + + + + + | + public static final String MSG_CLASS_INFO = "javadoc.classInfo"; |
+ +271 + | ++ + + + + + | +|
+ +272 + | ++ + + + + + | + /** |
+ +273 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +274 + | ++ + + + + + | + * file. |
+ +275 + | ++ + + + + + | + */ |
+ +276 + | ++ + + + + + | + public static final String MSG_UNUSED_TAG_GENERAL = "javadoc.unusedTagGeneral"; |
+ +277 + | ++ + + + + + | +|
+ +278 + | ++ + + + + + | + /** |
+ +279 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +280 + | ++ + + + + + | + * file. |
+ +281 + | ++ + + + + + | + */ |
+ +282 + | ++ + + + + + | + public static final String MSG_INVALID_INHERIT_DOC = "javadoc.invalidInheritDoc"; |
+ +283 + | ++ + + + + + | +|
+ +284 + | ++ + + + + + | + /** |
+ +285 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +286 + | ++ + + + + + | + * file. |
+ +287 + | ++ + + + + + | + */ |
+ +288 + | ++ + + + + + | + public static final String MSG_UNUSED_TAG = "javadoc.unusedTag"; |
+ +289 + | ++ + + + + + | +|
+ +290 + | ++ + + + + + | + /** |
+ +291 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +292 + | ++ + + + + + | + * file. |
+ +293 + | ++ + + + + + | + */ |
+ +294 + | ++ + + + + + | + public static final String MSG_EXPECTED_TAG = "javadoc.expectedTag"; |
+ +295 + | ++ + + + + + | +|
+ +296 + | ++ + + + + + | + /** |
+ +297 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +298 + | ++ + + + + + | + * file. |
+ +299 + | ++ + + + + + | + */ |
+ +300 + | ++ + + + + + | + public static final String MSG_RETURN_EXPECTED = "javadoc.return.expected"; |
+ +301 + | ++ + + + + + | +|
+ +302 + | ++ + + + + + | + /** |
+ +303 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +304 + | ++ + + + + + | + * file. |
+ +305 + | ++ + + + + + | + */ |
+ +306 + | ++ + + + + + | + public static final String MSG_DUPLICATE_TAG = "javadoc.duplicateTag"; |
+ +307 + | ++ + + + + + | +|
+ +308 + | ++ + + + + + | + /** Compiled regexp to match Javadoc tags that take an argument. */ |
+ +309 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_ARG = CommonUtil.createPattern( |
+ +310 + | ++ + + + + + | + "^\\s*(?>\\*|\\/\\*\\*)?\\s*@(throws|exception|param)\\s+(\\S+)\\s+\\S*"); |
+ +311 + | ++ + + + + + | + /** Compiled regexp to match Javadoc tags with argument but with missing description. */ |
+ +312 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_ARG_MISSING_DESCRIPTION = |
+ +313 + | ++ + + + + + | + CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(throws|exception|param)\\s+" |
+ +314 + | ++ + + + + + | + + "(\\S[^*]*)(?:(\\s+|\\*\\/))?"); |
+ +315 + | ++ + + + + + | +|
+ +316 + | ++ + + + + + | + /** Compiled regexp to look for a continuation of the comment. */ |
+ +317 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_MULTILINE_CONT = |
+ +318 + | ++ + + + + + | + CommonUtil.createPattern("(\\*\\/|@|[^\\s\\*])"); |
+ +319 + | ++ + + + + + | +|
+ +320 + | ++ + + + + + | + /** Multiline finished at end of comment. */ |
+ +321 + | ++ + + + + + | + private static final String END_JAVADOC = "*/"; |
+ +322 + | ++ + + + + + | + /** Multiline finished at next Javadoc. */ |
+ +323 + | ++ + + + + + | + private static final String NEXT_TAG = "@"; |
+ +324 + | ++ + + + + + | +|
+ +325 + | ++ + + + + + | + /** Compiled regexp to match Javadoc tags with no argument. */ |
+ +326 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_NOARG = |
+ +327 + | ++ + + + + + | + CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(return|see)\\s+\\S"); |
+ +328 + | ++ + + + + + | + /** Compiled regexp to match first part of multilineJavadoc tags. */ |
+ +329 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_NOARG_MULTILINE_START = |
+ +330 + | ++ + + + + + | + CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(return|see)\\s*$"); |
+ +331 + | ++ + + + + + | + /** Compiled regexp to match Javadoc tags with no argument and {}. */ |
+ +332 + | ++ + + + + + | + private static final Pattern MATCH_JAVADOC_NOARG_CURLY = |
+ +333 + | ++ + + + + + | + CommonUtil.createPattern("\\{\\s*@(inheritDoc)\\s*\\}"); |
+ +334 + | ++ + + + + + | +|
+ +335 + | ++ + + + + + | + /** Stack of maps for type params. */ |
+ +336 + | +
+
+1
+
+
+1. + + |
+ private final Deque<Map<String, ClassInfo>> currentTypeParams = new ArrayDeque<>(); |
+ +337 + | ++ + + + + + | +|
+ +338 + | ++ + + + + + | + /** Name of current class. */ |
+ +339 + | ++ + + + + + | + private String currentClassName; |
+ +340 + | ++ + + + + + | +|
+ +341 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +342 + | ++ + + + + + | + private Scope scope = Scope.PRIVATE; |
+ +343 + | ++ + + + + + | +|
+ +344 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +345 + | ++ + + + + + | + private Scope excludeScope; |
+ +346 + | ++ + + + + + | +|
+ +347 + | ++ + + + + + | + /** |
+ +348 + | ++ + + + + + | + * Control whether to validate {@code throws} tags. |
+ +349 + | ++ + + + + + | + */ |
+ +350 + | ++ + + + + + | + private boolean validateThrows; |
+ +351 + | ++ + + + + + | +|
+ +352 + | ++ + + + + + | + /** |
+ +353 + | ++ + + + + + | + * Control whether to ignore violations when a method has parameters but does |
+ +354 + | ++ + + + + + | + * not have matching {@code param} tags in the javadoc. |
+ +355 + | ++ + + + + + | + */ |
+ +356 + | ++ + + + + + | + private boolean allowMissingParamTags; |
+ +357 + | ++ + + + + + | +|
+ +358 + | ++ + + + + + | + /** |
+ +359 + | ++ + + + + + | + * Control whether to ignore violations when a method returns non-void type |
+ +360 + | ++ + + + + + | + * and does not have a {@code return} tag in the javadoc. |
+ +361 + | ++ + + + + + | + */ |
+ +362 + | ++ + + + + + | + private boolean allowMissingReturnTag; |
+ +363 + | ++ + + + + + | +|
+ +364 + | ++ + + + + + | + /** Specify the list of annotations that allow missed documentation. */ |
+ +365 + | ++ + + + + + | + private List<String> allowedAnnotations = Collections.singletonList("Override"); |
+ +366 + | ++ + + + + + | +|
+ +367 + | ++ + + + + + | + /** |
+ +368 + | ++ + + + + + | + * Setter to control whether to validate {@code throws} tags. |
+ +369 + | ++ + + + + + | + * |
+ +370 + | ++ + + + + + | + * @param value user's value. |
+ +371 + | ++ + + + + + | + */ |
+ +372 + | ++ + + + + + | + public void setValidateThrows(boolean value) { |
+ +373 + | ++ + + + + + | + validateThrows = value; |
+ +374 + | ++ + + + + + | + } |
+ +375 + | ++ + + + + + | +|
+ +376 + | ++ + + + + + | + /** |
+ +377 + | ++ + + + + + | + * Setter to specify the list of annotations that allow missed documentation. |
+ +378 + | ++ + + + + + | + * |
+ +379 + | ++ + + + + + | + * @param userAnnotations user's value. |
+ +380 + | ++ + + + + + | + */ |
+ +381 + | ++ + + + + + | + public void setAllowedAnnotations(String... userAnnotations) { |
+ +382 + | ++ + + + + + | + allowedAnnotations = Arrays.asList(userAnnotations); |
+ +383 + | ++ + + + + + | + } |
+ +384 + | ++ + + + + + | +|
+ +385 + | ++ + + + + + | + /** |
+ +386 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +387 + | ++ + + + + + | + * |
+ +388 + | ++ + + + + + | + * @param scope a scope. |
+ +389 + | ++ + + + + + | + */ |
+ +390 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +391 + | ++ + + + + + | + this.scope = scope; |
+ +392 + | ++ + + + + + | + } |
+ +393 + | ++ + + + + + | +|
+ +394 + | ++ + + + + + | + /** |
+ +395 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +396 + | ++ + + + + + | + * |
+ +397 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +398 + | ++ + + + + + | + */ |
+ +399 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +400 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +401 + | ++ + + + + + | + } |
+ +402 + | ++ + + + + + | +|
+ +403 + | ++ + + + + + | + /** |
+ +404 + | ++ + + + + + | + * Setter to control whether to ignore violations when a method has parameters |
+ +405 + | ++ + + + + + | + * but does not have matching {@code param} tags in the javadoc. |
+ +406 + | ++ + + + + + | + * |
+ +407 + | ++ + + + + + | + * @param flag a {@code Boolean} value |
+ +408 + | ++ + + + + + | + */ |
+ +409 + | ++ + + + + + | + public void setAllowMissingParamTags(boolean flag) { |
+ +410 + | ++ + + + + + | + allowMissingParamTags = flag; |
+ +411 + | ++ + + + + + | + } |
+ +412 + | ++ + + + + + | +|
+ +413 + | ++ + + + + + | + /** |
+ +414 + | ++ + + + + + | + * Setter to control whether to ignore violations when a method returns non-void type |
+ +415 + | ++ + + + + + | + * and does not have a {@code return} tag in the javadoc. |
+ +416 + | ++ + + + + + | + * |
+ +417 + | ++ + + + + + | + * @param flag a {@code Boolean} value |
+ +418 + | ++ + + + + + | + */ |
+ +419 + | ++ + + + + + | + public void setAllowMissingReturnTag(boolean flag) { |
+ +420 + | ++ + + + + + | + allowMissingReturnTag = flag; |
+ +421 + | ++ + + + + + | + } |
+ +422 + | ++ + + + + + | +|
+ +423 + | ++ + + + + + | + @Override |
+ +424 + | ++ + + + + + | + public final int[] getRequiredTokens() { |
+ +425 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +426 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +427 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +428 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +429 + | ++ + + + + + | + }; |
+ +430 + | ++ + + + + + | + } |
+ +431 + | ++ + + + + + | +|
+ +432 + | ++ + + + + + | + @Override |
+ +433 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +434 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +435 + | ++ + + + + + | + } |
+ +436 + | ++ + + + + + | +|
+ +437 + | ++ + + + + + | + @Override |
+ +438 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +439 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +440 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +441 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +442 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +443 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +444 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +445 + | ++ + + + + + | + TokenTypes.ANNOTATION_FIELD_DEF, |
+ +446 + | ++ + + + + + | + }; |
+ +447 + | ++ + + + + + | + } |
+ +448 + | ++ + + + + + | +|
+ +449 + | ++ + + + + + | + @Override |
+ +450 + | ++ + + + + + | + public void beginTree(DetailAST rootAST) { |
+ +451 + | ++ + + + + + | + currentClassName = ""; |
+ +452 + | ++ + + + + + | + } |
+ +453 + | ++ + + + + + | +|
+ +454 + | ++ + + + + + | + @Override |
+ +455 + | ++ + + + + + | + public final void visitToken(DetailAST ast) { |
+ +456 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (ast.getType() == TokenTypes.CLASS_DEF |
+ +457 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ || ast.getType() == TokenTypes.INTERFACE_DEF |
+ +458 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ || ast.getType() == TokenTypes.ENUM_DEF) { |
+ +459 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processClass → KILLED + + + + |
+ processClass(ast); |
+ +460 + | ++ + + + + + | + } |
+ +461 + | ++ + + + + + | + else { |
+ +462 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (ast.getType() == TokenTypes.METHOD_DEF) { |
+ +463 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processTypeParams → KILLED + + + + |
+ processTypeParams(ast); |
+ +464 + | ++ + + + + + | + } |
+ +465 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processAST → KILLED + + + + |
+ processAST(ast); |
+ +466 + | ++ + + + + + | + } |
+ +467 + | ++ + + + + + | + } |
+ +468 + | ++ + + + + + | +|
+ +469 + | ++ + + + + + | + @Override |
+ +470 + | ++ + + + + + | + public final void leaveToken(DetailAST ast) { |
+ +471 + | +
+
+1
+
+
+1. leaveToken : negated conditional → KILLED + + + + |
+ if (ast.getType() == TokenTypes.CLASS_DEF |
+ +472 + | +
+
+1
+
+
+1. leaveToken : negated conditional → KILLED + + + + |
+ || ast.getType() == TokenTypes.INTERFACE_DEF |
+ +473 + | +
+
+1
+
+
+1. leaveToken : negated conditional → KILLED + + + + |
+ || ast.getType() == TokenTypes.ENUM_DEF) { |
+ +474 + | ++ + + + + + | + // perhaps it was inner class |
+ +475 + | ++ + + + + + | + final int dotIdx = currentClassName.lastIndexOf('$'); |
+ +476 + | ++ + + + + + | + currentClassName = currentClassName.substring(0, dotIdx); |
+ +477 + | ++ + + + + + | + currentTypeParams.pop(); |
+ +478 + | ++ + + + + + | + } |
+ +479 + | +
+
+1
+
+
+1. leaveToken : negated conditional → KILLED + + + + |
+ else if (ast.getType() == TokenTypes.METHOD_DEF) { |
+ +480 + | ++ + + + + + | + currentTypeParams.pop(); |
+ +481 + | ++ + + + + + | + } |
+ +482 + | ++ + + + + + | + } |
+ +483 + | ++ + + + + + | +|
+ +484 + | ++ + + + + + | + /** |
+ +485 + | ++ + + + + + | + * Called to process an AST when visiting it. |
+ +486 + | ++ + + + + + | + * |
+ +487 + | ++ + + + + + | + * @param ast the AST to process. Guaranteed to not be PACKAGE_DEF or |
+ +488 + | ++ + + + + + | + * IMPORT tokens. |
+ +489 + | ++ + + + + + | + */ |
+ +490 + | ++ + + + + + | + private void processAST(DetailAST ast) { |
+ +491 + | ++ + + + + + | + final Scope theScope = calculateScope(ast); |
+ +492 + | +
+
+1
+
+
+1. processAST : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast, theScope)) { |
+ +493 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +494 + | ++ + + + + + | + final TextBlock textBlock = contents.getJavadocBefore(ast.getLineNo()); |
+ +495 + | ++ + + + + + | +|
+ +496 + | +
+
+1
+
+
+1. processAST : negated conditional → KILLED + + + + |
+ if (textBlock != null) { |
+ +497 + | +
+
+1
+
+
+1. processAST : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkComment → KILLED + + + + |
+ checkComment(ast, textBlock); |
+ +498 + | ++ + + + + + | + } |
+ +499 + | ++ + + + + + | + } |
+ +500 + | ++ + + + + + | + } |
+ +501 + | ++ + + + + + | +|
+ +502 + | ++ + + + + + | + /** |
+ +503 + | ++ + + + + + | + * Whether we should check this node. |
+ +504 + | ++ + + + + + | + * |
+ +505 + | ++ + + + + + | + * @param ast a given node. |
+ +506 + | ++ + + + + + | + * @param nodeScope the scope of the node. |
+ +507 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +508 + | ++ + + + + + | + */ |
+ +509 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast, final Scope nodeScope) { |
+ +510 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +511 + | ++ + + + + + | +|
+ +512 + | +
+
+5
+
+
+1. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::shouldCheck → KILLED + +2. shouldCheck : negated conditional → KILLED + +3. shouldCheck : negated conditional → KILLED + +4. shouldCheck : negated conditional → KILLED + +5. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return (excludeScope == null |
+ +513 + | ++ + + + + + | + || nodeScope != excludeScope |
+ +514 + | ++ + + + + + | + && surroundingScope != excludeScope) |
+ +515 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && nodeScope.isIn(scope) |
+ +516 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && surroundingScope.isIn(scope); |
+ +517 + | ++ + + + + + | + } |
+ +518 + | ++ + + + + + | +|
+ +519 + | ++ + + + + + | + /** |
+ +520 + | ++ + + + + + | + * Checks the Javadoc for a method. |
+ +521 + | ++ + + + + + | + * |
+ +522 + | ++ + + + + + | + * @param ast the token for the method |
+ +523 + | ++ + + + + + | + * @param comment the Javadoc comment |
+ +524 + | ++ + + + + + | + */ |
+ +525 + | ++ + + + + + | + private void checkComment(DetailAST ast, TextBlock comment) { |
+ +526 + | ++ + + + + + | + final List<JavadocTag> tags = getMethodTags(comment); |
+ +527 + | ++ + + + + + | +|
+ +528 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (!hasShortCircuitTag(ast, tags)) { |
+ +529 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (ast.getType() == TokenTypes.ANNOTATION_FIELD_DEF) { |
+ +530 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkReturnTag → KILLED + + + + |
+ checkReturnTag(tags, ast.getLineNo(), true); |
+ +531 + | ++ + + + + + | + } |
+ +532 + | ++ + + + + + | + else { |
+ +533 + | ++ + + + + + | + final Iterator<JavadocTag> it = tags.iterator(); |
+ +534 + | ++ + + + + + | + // Check for inheritDoc |
+ +535 + | ++ + + + + + | + boolean hasInheritDocTag = false; |
+ +536 + | +
+
+2
+
+
+1. checkComment : negated conditional → KILLED + +2. checkComment : negated conditional → KILLED + + + + |
+ while (!hasInheritDocTag && it.hasNext()) { |
+ +537 + | ++ + + + + + | + hasInheritDocTag = it.next().isInheritDocTag(); |
+ +538 + | ++ + + + + + | + } |
+ +539 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ final boolean reportExpectedTags = !hasInheritDocTag |
+ +540 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ && !AnnotationUtil.containsAnnotation(ast, allowedAnnotations); |
+ +541 + | ++ + + + + + | +|
+ +542 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkParamTags → KILLED + + + + |
+ checkParamTags(tags, ast, reportExpectedTags); |
+ +543 + | ++ + + + + + | + final List<ExceptionInfo> throwed = |
+ +544 + | ++ + + + + + | + combineExceptionInfo(getThrows(ast), getThrowed(ast)); |
+ +545 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkThrowsTags → KILLED + + + + |
+ checkThrowsTags(tags, throwed, reportExpectedTags); |
+ +546 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (CheckUtil.isNonVoidMethod(ast)) { |
+ +547 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkReturnTag → KILLED + + + + |
+ checkReturnTag(tags, ast.getLineNo(), reportExpectedTags); |
+ +548 + | ++ + + + + + | + } |
+ +549 + | ++ + + + + + | + } |
+ +550 + | ++ + + + + + | +|
+ +551 + | ++ + + + + + | + // Dump out all unused tags |
+ +552 + | +
+
+3
+
+
+1. lambda$checkComment$0 : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::lambda$checkComment$0 → KILLED + +2. lambda$checkComment$0 : negated conditional → KILLED + +3. lambda$checkComment$0 : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ tags.stream().filter(javadocTag -> !javadocTag.isSeeOrInheritDocTag()) |
+ +553 + | +
+
+2
+
+
+1. checkComment : removed call to java/util/stream/Stream::forEach → KILLED + +2. lambda$checkComment$1 : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ .forEach(javadocTag -> log(javadocTag.getLineNo(), MSG_UNUSED_TAG_GENERAL)); |
+ +554 + | ++ + + + + + | + } |
+ +555 + | ++ + + + + + | + } |
+ +556 + | ++ + + + + + | +|
+ +557 + | ++ + + + + + | + /** |
+ +558 + | ++ + + + + + | + * Validates whether the Javadoc has a short circuit tag. Currently this is |
+ +559 + | ++ + + + + + | + * the inheritTag. Any violations are logged. |
+ +560 + | ++ + + + + + | + * |
+ +561 + | ++ + + + + + | + * @param ast the construct being checked |
+ +562 + | ++ + + + + + | + * @param tags the list of Javadoc tags associated with the construct |
+ +563 + | ++ + + + + + | + * @return true if the construct has a short circuit tag. |
+ +564 + | ++ + + + + + | + */ |
+ +565 + | ++ + + + + + | + private boolean hasShortCircuitTag(final DetailAST ast, final List<JavadocTag> tags) { |
+ +566 + | ++ + + + + + | + boolean result = true; |
+ +567 + | ++ + + + + + | + // Check if it contains {@inheritDoc} tag |
+ +568 + | +
+
+1
+
+
+1. hasShortCircuitTag : negated conditional → KILLED + + + + |
+ if (tags.size() == 1 |
+ +569 + | +
+
+1
+
+
+1. hasShortCircuitTag : negated conditional → KILLED + + + + |
+ && tags.get(0).isInheritDocTag()) { |
+ +570 + | ++ + + + + + | + // Invalid if private, a constructor, or a static method |
+ +571 + | +
+
+1
+
+
+1. hasShortCircuitTag : negated conditional → KILLED + + + + |
+ if (!JavadocTagInfo.INHERIT_DOC.isValidOn(ast)) { |
+ +572 + | +
+
+1
+
+
+1. hasShortCircuitTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(ast, MSG_INVALID_INHERIT_DOC); |
+ +573 + | ++ + + + + + | + } |
+ +574 + | ++ + + + + + | + } |
+ +575 + | ++ + + + + + | + else { |
+ +576 + | ++ + + + + + | + result = false; |
+ +577 + | ++ + + + + + | + } |
+ +578 + | +
+
+3
+
+
+1. hasShortCircuitTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::hasShortCircuitTag → KILLED + +2. hasShortCircuitTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::hasShortCircuitTag → KILLED + +3. hasShortCircuitTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +579 + | ++ + + + + + | + } |
+ +580 + | ++ + + + + + | +|
+ +581 + | ++ + + + + + | + /** |
+ +582 + | ++ + + + + + | + * Returns the scope for the method/constructor at the specified AST. If |
+ +583 + | ++ + + + + + | + * the method is in an interface or annotation block, the scope is assumed |
+ +584 + | ++ + + + + + | + * to be public. |
+ +585 + | ++ + + + + + | + * |
+ +586 + | ++ + + + + + | + * @param ast the token of the method/constructor |
+ +587 + | ++ + + + + + | + * @return the scope of the method/constructor |
+ +588 + | ++ + + + + + | + */ |
+ +589 + | ++ + + + + + | + private static Scope calculateScope(final DetailAST ast) { |
+ +590 + | ++ + + + + + | + final Scope scope; |
+ +591 + | ++ + + + + + | +|
+ +592 + | +
+
+1
+
+
+1. calculateScope : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
+ +593 + | ++ + + + + + | + scope = Scope.PUBLIC; |
+ +594 + | ++ + + + + + | + } |
+ +595 + | ++ + + + + + | + else { |
+ +596 + | ++ + + + + + | + final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); |
+ +597 + | ++ + + + + + | + scope = ScopeUtil.getScopeFromMods(mods); |
+ +598 + | ++ + + + + + | + } |
+ +599 + | +
+
+1
+
+
+1. calculateScope : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::calculateScope to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return scope; |
+ +600 + | ++ + + + + + | + } |
+ +601 + | ++ + + + + + | +|
+ +602 + | ++ + + + + + | + /** |
+ +603 + | ++ + + + + + | + * Returns the tags in a javadoc comment. Only finds throws, exception, |
+ +604 + | ++ + + + + + | + * param, return and see tags. |
+ +605 + | ++ + + + + + | + * |
+ +606 + | ++ + + + + + | + * @param comment the Javadoc comment |
+ +607 + | ++ + + + + + | + * @return the tags found |
+ +608 + | ++ + + + + + | + */ |
+ +609 + | ++ + + + + + | + private static List<JavadocTag> getMethodTags(TextBlock comment) { |
+ +610 + | ++ + + + + + | + final String[] lines = comment.getText(); |
+ +611 + | +
+
+1
+
+
+1. getMethodTags : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<JavadocTag> tags = new ArrayList<>(); |
+ +612 + | +
+
+1
+
+
+1. getMethodTags : Replaced integer subtraction with addition → KILLED + + + + |
+ int currentLine = comment.getStartLineNo() - 1; |
+ +613 + | ++ + + + + + | + final int startColumnNumber = comment.getStartColNo(); |
+ +614 + | ++ + + + + + | +|
+ +615 + | +
+
+3
+
+
+1. getMethodTags : changed conditional boundary → KILLED + +2. getMethodTags : Changed increment from 1 to -1 → KILLED + +3. getMethodTags : negated conditional → KILLED + + + + |
+ for (int i = 0; i < lines.length; i++) { |
+ +616 + | +
+
+1
+
+
+1. getMethodTags : Changed increment from 1 to -1 → KILLED + + + + |
+ currentLine++; |
+ +617 + | ++ + + + + + | + final Matcher javadocArgMatcher = |
+ +618 + | ++ + + + + + | + MATCH_JAVADOC_ARG.matcher(lines[i]); |
+ +619 + | ++ + + + + + | + final Matcher javadocArgMissingDescriptionMatcher = |
+ +620 + | ++ + + + + + | + MATCH_JAVADOC_ARG_MISSING_DESCRIPTION.matcher(lines[i]); |
+ +621 + | ++ + + + + + | + final Matcher javadocNoargMatcher = |
+ +622 + | ++ + + + + + | + MATCH_JAVADOC_NOARG.matcher(lines[i]); |
+ +623 + | ++ + + + + + | + final Matcher noargCurlyMatcher = |
+ +624 + | ++ + + + + + | + MATCH_JAVADOC_NOARG_CURLY.matcher(lines[i]); |
+ +625 + | ++ + + + + + | + final Matcher noargMultilineStart = |
+ +626 + | ++ + + + + + | + MATCH_JAVADOC_NOARG_MULTILINE_START.matcher(lines[i]); |
+ +627 + | ++ + + + + + | +|
+ +628 + | +
+
+1
+
+
+1. getMethodTags : negated conditional → KILLED + + + + |
+ if (javadocArgMatcher.find()) { |
+ +629 + | ++ + + + + + | + final int col = calculateTagColumn(javadocArgMatcher, i, startColumnNumber); |
+ +630 + | ++ + + + + + | + tags.add(new JavadocTag(currentLine, col, javadocArgMatcher.group(1), |
+ +631 + | +
+
+1
+
+
+1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED + + + + |
+ javadocArgMatcher.group(2))); |
+ +632 + | ++ + + + + + | + } |
+ +633 + | +
+
+1
+
+
+1. getMethodTags : negated conditional → KILLED + + + + |
+ else if (javadocArgMissingDescriptionMatcher.find()) { |
+ +634 + | ++ + + + + + | + final int col = calculateTagColumn(javadocArgMissingDescriptionMatcher, i, |
+ +635 + | ++ + + + + + | + startColumnNumber); |
+ +636 + | ++ + + + + + | + tags.add(new JavadocTag(currentLine, col, |
+ +637 + | ++ + + + + + | + javadocArgMissingDescriptionMatcher.group(1), |
+ +638 + | +
+
+1
+
+
+1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED + + + + |
+ javadocArgMissingDescriptionMatcher.group(2))); |
+ +639 + | ++ + + + + + | + } |
+ +640 + | +
+
+1
+
+
+1. getMethodTags : negated conditional → KILLED + + + + |
+ else if (javadocNoargMatcher.find()) { |
+ +641 + | ++ + + + + + | + final int col = calculateTagColumn(javadocNoargMatcher, i, startColumnNumber); |
+ +642 + | +
+
+1
+
+
+1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED + + + + |
+ tags.add(new JavadocTag(currentLine, col, javadocNoargMatcher.group(1))); |
+ +643 + | ++ + + + + + | + } |
+ +644 + | +
+
+1
+
+
+1. getMethodTags : negated conditional → KILLED + + + + |
+ else if (noargCurlyMatcher.find()) { |
+ +645 + | ++ + + + + + | + final int col = calculateTagColumn(noargCurlyMatcher, i, startColumnNumber); |
+ +646 + | +
+
+1
+
+
+1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED + + + + |
+ tags.add(new JavadocTag(currentLine, col, noargCurlyMatcher.group(1))); |
+ +647 + | ++ + + + + + | + } |
+ +648 + | +
+
+1
+
+
+1. getMethodTags : negated conditional → KILLED + + + + |
+ else if (noargMultilineStart.find()) { |
+ +649 + | ++ + + + + + | + tags.addAll(getMultilineNoArgTags(noargMultilineStart, lines, i, currentLine)); |
+ +650 + | ++ + + + + + | + } |
+ +651 + | ++ + + + + + | + } |
+ +652 + | +
+
+1
+
+
+1. getMethodTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getMethodTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags; |
+ +653 + | ++ + + + + + | + } |
+ +654 + | ++ + + + + + | +|
+ +655 + | ++ + + + + + | + /** |
+ +656 + | ++ + + + + + | + * Calculates column number using Javadoc tag matcher. |
+ +657 + | ++ + + + + + | + * |
+ +658 + | ++ + + + + + | + * @param javadocTagMatcher found javadoc tag matcher |
+ +659 + | ++ + + + + + | + * @param lineNumber line number of Javadoc tag in comment |
+ +660 + | ++ + + + + + | + * @param startColumnNumber column number of Javadoc comment beginning |
+ +661 + | ++ + + + + + | + * @return column number |
+ +662 + | ++ + + + + + | + */ |
+ +663 + | ++ + + + + + | + private static int calculateTagColumn(Matcher javadocTagMatcher, |
+ +664 + | ++ + + + + + | + int lineNumber, int startColumnNumber) { |
+ +665 + | +
+
+1
+
+
+1. calculateTagColumn : Replaced integer subtraction with addition → KILLED + + + + |
+ int col = javadocTagMatcher.start(1) - 1; |
+ +666 + | +
+
+1
+
+
+1. calculateTagColumn : negated conditional → KILLED + + + + |
+ if (lineNumber == 0) { |
+ +667 + | +
+
+1
+
+
+1. calculateTagColumn : Replaced integer addition with subtraction → KILLED + + + + |
+ col += startColumnNumber; |
+ +668 + | ++ + + + + + | + } |
+ +669 + | +
+
+1
+
+
+1. calculateTagColumn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return col; |
+ +670 + | ++ + + + + + | + } |
+ +671 + | ++ + + + + + | +|
+ +672 + | ++ + + + + + | + /** |
+ +673 + | ++ + + + + + | + * Gets multiline Javadoc tags with no arguments. |
+ +674 + | ++ + + + + + | + * |
+ +675 + | ++ + + + + + | + * @param noargMultilineStart javadoc tag Matcher |
+ +676 + | ++ + + + + + | + * @param lines comment text lines |
+ +677 + | ++ + + + + + | + * @param lineIndex line number that contains the javadoc tag |
+ +678 + | ++ + + + + + | + * @param tagLine javadoc tag line number in file |
+ +679 + | ++ + + + + + | + * @return javadoc tags with no arguments |
+ +680 + | ++ + + + + + | + */ |
+ +681 + | ++ + + + + + | + private static List<JavadocTag> getMultilineNoArgTags(final Matcher noargMultilineStart, |
+ +682 + | ++ + + + + + | + final String[] lines, final int lineIndex, final int tagLine) { |
+ +683 + | ++ + + + + + | + int remIndex = lineIndex; |
+ +684 + | ++ + + + + + | + Matcher multilineCont; |
+ +685 + | ++ + + + + + | +|
+ +686 + | ++ + + + + + | + do { |
+ +687 + | +
+
+1
+
+
+1. getMultilineNoArgTags : Changed increment from 1 to -1 → KILLED + + + + |
+ remIndex++; |
+ +688 + | ++ + + + + + | + multilineCont = MATCH_JAVADOC_MULTILINE_CONT.matcher(lines[remIndex]); |
+ +689 + | +
+
+1
+
+
+1. getMultilineNoArgTags : negated conditional → KILLED + + + + |
+ } while (!multilineCont.find()); |
+ +690 + | ++ + + + + + | +|
+ +691 + | +
+
+1
+
+
+1. getMultilineNoArgTags : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<JavadocTag> tags = new ArrayList<>(); |
+ +692 + | ++ + + + + + | + final String lFin = multilineCont.group(1); |
+ +693 + | +
+
+1
+
+
+1. getMultilineNoArgTags : negated conditional → KILLED + + + + |
+ if (!lFin.equals(NEXT_TAG) |
+ +694 + | +
+
+1
+
+
+1. getMultilineNoArgTags : negated conditional → KILLED + + + + |
+ && !lFin.equals(END_JAVADOC)) { |
+ +695 + | ++ + + + + + | + final String param1 = noargMultilineStart.group(1); |
+ +696 + | +
+
+1
+
+
+1. getMultilineNoArgTags : Replaced integer subtraction with addition → KILLED + + + + |
+ final int col = noargMultilineStart.start(1) - 1; |
+ +697 + | ++ + + + + + | +|
+ +698 + | +
+
+1
+
+
+1. getMultilineNoArgTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED + + + + |
+ tags.add(new JavadocTag(tagLine, col, param1)); |
+ +699 + | ++ + + + + + | + } |
+ +700 + | ++ + + + + + | +|
+ +701 + | +
+
+1
+
+
+1. getMultilineNoArgTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getMultilineNoArgTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags; |
+ +702 + | ++ + + + + + | + } |
+ +703 + | ++ + + + + + | +|
+ +704 + | ++ + + + + + | + /** |
+ +705 + | ++ + + + + + | + * Computes the parameter nodes for a method. |
+ +706 + | ++ + + + + + | + * |
+ +707 + | ++ + + + + + | + * @param ast the method node. |
+ +708 + | ++ + + + + + | + * @return the list of parameter nodes for ast. |
+ +709 + | ++ + + + + + | + */ |
+ +710 + | ++ + + + + + | + private static List<DetailAST> getParameters(DetailAST ast) { |
+ +711 + | ++ + + + + + | + final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS); |
+ +712 + | +
+
+1
+
+
+1. getParameters : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<DetailAST> returnValue = new ArrayList<>(); |
+ +713 + | ++ + + + + + | +|
+ +714 + | ++ + + + + + | + DetailAST child = params.getFirstChild(); |
+ +715 + | +
+
+1
+
+
+1. getParameters : negated conditional → KILLED + + + + |
+ while (child != null) { |
+ +716 + | +
+
+1
+
+
+1. getParameters : negated conditional → KILLED + + + + |
+ if (child.getType() == TokenTypes.PARAMETER_DEF) { |
+ +717 + | ++ + + + + + | + final DetailAST ident = child.findFirstToken(TokenTypes.IDENT); |
+ +718 + | +
+
+1
+
+
+1. getParameters : negated conditional → KILLED + + + + |
+ if (ident != null) { |
+ +719 + | ++ + + + + + | + returnValue.add(ident); |
+ +720 + | ++ + + + + + | + } |
+ +721 + | ++ + + + + + | + } |
+ +722 + | ++ + + + + + | + child = child.getNextSibling(); |
+ +723 + | ++ + + + + + | + } |
+ +724 + | +
+
+1
+
+
+1. getParameters : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getParameters to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return returnValue; |
+ +725 + | ++ + + + + + | + } |
+ +726 + | ++ + + + + + | +|
+ +727 + | ++ + + + + + | + /** |
+ +728 + | ++ + + + + + | + * Computes the exception nodes for a method. |
+ +729 + | ++ + + + + + | + * |
+ +730 + | ++ + + + + + | + * @param ast the method node. |
+ +731 + | ++ + + + + + | + * @return the list of exception nodes for ast. |
+ +732 + | ++ + + + + + | + */ |
+ +733 + | ++ + + + + + | + private List<ExceptionInfo> getThrows(DetailAST ast) { |
+ +734 + | +
+
+1
+
+
+1. getThrows : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<ExceptionInfo> returnValue = new ArrayList<>(); |
+ +735 + | ++ + + + + + | + final DetailAST throwsAST = ast |
+ +736 + | ++ + + + + + | + .findFirstToken(TokenTypes.LITERAL_THROWS); |
+ +737 + | +
+
+1
+
+
+1. getThrows : negated conditional → KILLED + + + + |
+ if (throwsAST != null) { |
+ +738 + | ++ + + + + + | + DetailAST child = throwsAST.getFirstChild(); |
+ +739 + | +
+
+1
+
+
+1. getThrows : negated conditional → KILLED + + + + |
+ while (child != null) { |
+ +740 + | +
+
+1
+
+
+1. getThrows : negated conditional → KILLED + + + + |
+ if (child.getType() == TokenTypes.IDENT |
+ +741 + | +
+
+1
+
+
+1. getThrows : negated conditional → KILLED + + + + |
+ || child.getType() == TokenTypes.DOT) { |
+ +742 + | ++ + + + + + | + final FullIdent ident = FullIdent.createFullIdent(child); |
+ +743 + | +
+
+1
+
+
+1. getThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED + + + + |
+ final ExceptionInfo exceptionInfo = new ExceptionInfo( |
+ +744 + | +
+
+1
+
+
+1. getThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::<init> → KILLED + + + + |
+ createClassInfo(new Token(ident), currentClassName)); |
+ +745 + | ++ + + + + + | + returnValue.add(exceptionInfo); |
+ +746 + | ++ + + + + + | + } |
+ +747 + | ++ + + + + + | + child = child.getNextSibling(); |
+ +748 + | ++ + + + + + | + } |
+ +749 + | ++ + + + + + | + } |
+ +750 + | +
+
+1
+
+
+1. getThrows : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getThrows to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return returnValue; |
+ +751 + | ++ + + + + + | + } |
+ +752 + | ++ + + + + + | +|
+ +753 + | ++ + + + + + | + /** |
+ +754 + | ++ + + + + + | + * Get ExceptionInfo for all exceptions that throws in method code by 'throw new'. |
+ +755 + | ++ + + + + + | + * |
+ +756 + | ++ + + + + + | + * @param methodAst method DetailAST object where to find exceptions |
+ +757 + | ++ + + + + + | + * @return list of ExceptionInfo |
+ +758 + | ++ + + + + + | + */ |
+ +759 + | ++ + + + + + | + private List<ExceptionInfo> getThrowed(DetailAST methodAst) { |
+ +760 + | +
+
+1
+
+
+1. getThrowed : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<ExceptionInfo> returnValue = new ArrayList<>(); |
+ +761 + | ++ + + + + + | + final DetailAST blockAst = methodAst.findFirstToken(TokenTypes.SLIST); |
+ +762 + | +
+
+1
+
+
+1. getThrowed : negated conditional → KILLED + + + + |
+ if (blockAst != null) { |
+ +763 + | ++ + + + + + | + final List<DetailAST> throwLiterals = findTokensInAstByType(blockAst, |
+ +764 + | ++ + + + + + | + TokenTypes.LITERAL_THROW); |
+ +765 + | ++ + + + + + | + for (DetailAST throwAst : throwLiterals) { |
+ +766 + | +
+
+1
+
+
+1. getThrowed : negated conditional → KILLED + + + + |
+ if (!isInIgnoreBlock(blockAst, throwAst)) { |
+ +767 + | ++ + + + + + | + final DetailAST newAst = throwAst.getFirstChild().getFirstChild(); |
+ +768 + | +
+
+1
+
+
+1. getThrowed : negated conditional → KILLED + + + + |
+ if (newAst.getType() == TokenTypes.LITERAL_NEW) { |
+ +769 + | ++ + + + + + | + final FullIdent ident = FullIdent.createFullIdent(newAst.getFirstChild()); |
+ +770 + | +
+
+1
+
+
+1. getThrowed : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED + + + + |
+ final ExceptionInfo exceptionInfo = new ExceptionInfo( |
+ +771 + | +
+
+1
+
+
+1. getThrowed : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::<init> → KILLED + + + + |
+ createClassInfo(new Token(ident), currentClassName)); |
+ +772 + | ++ + + + + + | + returnValue.add(exceptionInfo); |
+ +773 + | ++ + + + + + | + } |
+ +774 + | ++ + + + + + | + } |
+ +775 + | ++ + + + + + | + } |
+ +776 + | ++ + + + + + | + } |
+ +777 + | +
+
+1
+
+
+1. getThrowed : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::getThrowed to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return returnValue; |
+ +778 + | ++ + + + + + | + } |
+ +779 + | ++ + + + + + | +|
+ +780 + | ++ + + + + + | + /** |
+ +781 + | ++ + + + + + | + * Checks if a 'throw' usage is contained within a block that should be ignored. |
+ +782 + | ++ + + + + + | + * Such blocks consist of try (with catch) blocks, local classes, anonymous classes, |
+ +783 + | ++ + + + + + | + * and lambda expressions. Note that a try block without catch is not considered. |
+ +784 + | ++ + + + + + | + * @param methodBodyAst DetailAST node representing the method body |
+ +785 + | ++ + + + + + | + * @param throwAst DetailAST node representing the 'throw' literal |
+ +786 + | ++ + + + + + | + * @return true if throwAst is inside a block that should be ignored |
+ +787 + | ++ + + + + + | + */ |
+ +788 + | ++ + + + + + | + private static boolean isInIgnoreBlock(DetailAST methodBodyAst, DetailAST throwAst) { |
+ +789 + | ++ + + + + + | + DetailAST ancestor = throwAst.getParent(); |
+ +790 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ while (ancestor != methodBodyAst) { |
+ +791 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ if (ancestor.getType() == TokenTypes.LITERAL_TRY |
+ +792 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ && ancestor.findFirstToken(TokenTypes.LITERAL_CATCH) != null |
+ +793 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ || ancestor.getType() == TokenTypes.LAMBDA |
+ +794 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ || ancestor.getType() == TokenTypes.OBJBLOCK) { |
+ +795 + | ++ + + + + + | + // throw is inside a try block, and there is a catch block, |
+ +796 + | ++ + + + + + | + // or throw is inside a lambda expression/anonymous class/local class |
+ +797 + | ++ + + + + + | + break; |
+ +798 + | ++ + + + + + | + } |
+ +799 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ if (ancestor.getType() == TokenTypes.LITERAL_CATCH |
+ +800 + | +
+
+1
+
+
+1. isInIgnoreBlock : negated conditional → KILLED + + + + |
+ || ancestor.getType() == TokenTypes.LITERAL_FINALLY) { |
+ +801 + | ++ + + + + + | + // if the throw is inside a catch or finally block, |
+ +802 + | ++ + + + + + | + // skip the immediate ancestor (try token) |
+ +803 + | ++ + + + + + | + ancestor = ancestor.getParent(); |
+ +804 + | ++ + + + + + | + } |
+ +805 + | ++ + + + + + | + ancestor = ancestor.getParent(); |
+ +806 + | ++ + + + + + | + } |
+ +807 + | +
+
+3
+
+
+1. isInIgnoreBlock : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::isInIgnoreBlock → KILLED + +2. isInIgnoreBlock : negated conditional → KILLED + +3. isInIgnoreBlock : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return ancestor != methodBodyAst; |
+ +808 + | ++ + + + + + | + } |
+ +809 + | ++ + + + + + | +|
+ +810 + | ++ + + + + + | + /** |
+ +811 + | ++ + + + + + | + * Combine ExceptionInfo lists together by matching names. |
+ +812 + | ++ + + + + + | + * |
+ +813 + | ++ + + + + + | + * @param list1 list of ExceptionInfo |
+ +814 + | ++ + + + + + | + * @param list2 list of ExceptionInfo |
+ +815 + | ++ + + + + + | + * @return combined list of ExceptionInfo |
+ +816 + | ++ + + + + + | + */ |
+ +817 + | ++ + + + + + | + private static List<ExceptionInfo> combineExceptionInfo(List<ExceptionInfo> list1, |
+ +818 + | ++ + + + + + | + List<ExceptionInfo> list2) { |
+ +819 + | +
+
+1
+
+
+1. combineExceptionInfo : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<ExceptionInfo> result = new ArrayList<>(list1); |
+ +820 + | ++ + + + + + | + for (ExceptionInfo exceptionInfo : list2) { |
+ +821 + | +
+
+4
+
+
+1. combineExceptionInfo : negated conditional → KILLED + +2. lambda$combineExceptionInfo$2 : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::lambda$combineExceptionInfo$2 → KILLED + +3. lambda$combineExceptionInfo$2 : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::lambda$combineExceptionInfo$2 → KILLED + +4. lambda$combineExceptionInfo$2 : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ if (result.stream().noneMatch(item -> isExceptionInfoSame(item, exceptionInfo))) { |
+ +822 + | ++ + + + + + | + result.add(exceptionInfo); |
+ +823 + | ++ + + + + + | + } |
+ +824 + | ++ + + + + + | + } |
+ +825 + | +
+
+1
+
+
+1. combineExceptionInfo : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::combineExceptionInfo to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result; |
+ +826 + | ++ + + + + + | + } |
+ +827 + | ++ + + + + + | +|
+ +828 + | ++ + + + + + | + /** |
+ +829 + | ++ + + + + + | + * Finds node of specified type among root children, siblings, siblings children |
+ +830 + | ++ + + + + + | + * on any deep level. |
+ +831 + | ++ + + + + + | + * |
+ +832 + | ++ + + + + + | + * @param root DetailAST |
+ +833 + | ++ + + + + + | + * @param astType value of TokenType |
+ +834 + | ++ + + + + + | + * @return {@link List} of {@link DetailAST} nodes which matches the predicate. |
+ +835 + | ++ + + + + + | + */ |
+ +836 + | ++ + + + + + | + public static List<DetailAST> findTokensInAstByType(DetailAST root, int astType) { |
+ +837 + | +
+
+1
+
+
+1. findTokensInAstByType : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<DetailAST> result = new ArrayList<>(); |
+ +838 + | ++ + + + + + | + DetailAST curNode = root; |
+ +839 + | +
+
+1
+
+
+1. findTokensInAstByType : negated conditional → KILLED + + + + |
+ while (curNode != null) { |
+ +840 + | ++ + + + + + | + DetailAST toVisit = curNode.getFirstChild(); |
+ +841 + | +
+
+2
+
+
+1. findTokensInAstByType : negated conditional → KILLED + +2. findTokensInAstByType : negated conditional → KILLED + + + + |
+ while (curNode != null && toVisit == null) { |
+ +842 + | ++ + + + + + | + toVisit = curNode.getNextSibling(); |
+ +843 + | ++ + + + + + | + curNode = curNode.getParent(); |
+ +844 + | +
+
+1
+
+
+1. findTokensInAstByType : negated conditional → KILLED + + + + |
+ if (curNode == root) { |
+ +845 + | ++ + + + + + | + toVisit = null; |
+ +846 + | ++ + + + + + | + break; |
+ +847 + | ++ + + + + + | + } |
+ +848 + | ++ + + + + + | + } |
+ +849 + | ++ + + + + + | + curNode = toVisit; |
+ +850 + | +
+
+2
+
+
+1. findTokensInAstByType : negated conditional → KILLED + +2. findTokensInAstByType : negated conditional → KILLED + + + + |
+ if (curNode != null && curNode.getType() == astType) { |
+ +851 + | ++ + + + + + | + result.add(curNode); |
+ +852 + | ++ + + + + + | + } |
+ +853 + | ++ + + + + + | + } |
+ +854 + | +
+
+1
+
+
+1. findTokensInAstByType : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::findTokensInAstByType to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result; |
+ +855 + | ++ + + + + + | + } |
+ +856 + | ++ + + + + + | +|
+ +857 + | ++ + + + + + | + /** |
+ +858 + | ++ + + + + + | + * Checks a set of tags for matching parameters. |
+ +859 + | ++ + + + + + | + * |
+ +860 + | ++ + + + + + | + * @param tags the tags to check |
+ +861 + | ++ + + + + + | + * @param parent the node which takes the parameters |
+ +862 + | ++ + + + + + | + * @param reportExpectedTags whether we should report if do not find |
+ +863 + | ++ + + + + + | + * expected tag |
+ +864 + | ++ + + + + + | + */ |
+ +865 + | ++ + + + + + | + private void checkParamTags(final List<JavadocTag> tags, |
+ +866 + | ++ + + + + + | + final DetailAST parent, boolean reportExpectedTags) { |
+ +867 + | ++ + + + + + | + final List<DetailAST> params = getParameters(parent); |
+ +868 + | ++ + + + + + | + final List<DetailAST> typeParams = CheckUtil |
+ +869 + | ++ + + + + + | + .getTypeParameters(parent); |
+ +870 + | ++ + + + + + | +|
+ +871 + | ++ + + + + + | + // Loop over the tags, checking to see they exist in the params. |
+ +872 + | ++ + + + + + | + final ListIterator<JavadocTag> tagIt = tags.listIterator(); |
+ +873 + | +
+
+1
+
+
+1. checkParamTags : negated conditional → KILLED + + + + |
+ while (tagIt.hasNext()) { |
+ +874 + | ++ + + + + + | + final JavadocTag tag = tagIt.next(); |
+ +875 + | ++ + + + + + | +|
+ +876 + | +
+
+1
+
+
+1. checkParamTags : negated conditional → KILLED + + + + |
+ if (!tag.isParamTag()) { |
+ +877 + | ++ + + + + + | + continue; |
+ +878 + | ++ + + + + + | + } |
+ +879 + | ++ + + + + + | +|
+ +880 + | +
+
+1
+
+
+1. checkParamTags : removed call to java/util/ListIterator::remove → KILLED + + + + |
+ tagIt.remove(); |
+ +881 + | ++ + + + + + | +|
+ +882 + | ++ + + + + + | + final String arg1 = tag.getFirstArg(); |
+ +883 + | ++ + + + + + | + boolean found = removeMatchingParam(params, arg1); |
+ +884 + | ++ + + + + + | +|
+ +885 + | +
+
+2
+
+
+1. checkParamTags : negated conditional → KILLED + +2. checkParamTags : negated conditional → KILLED + + + + |
+ if (CommonUtil.startsWithChar(arg1, '<') && CommonUtil.endsWithChar(arg1, '>')) { |
+ +886 + | ++ + + + + + | + found = searchMatchingTypeParameter(typeParams, |
+ +887 + | +
+
+1
+
+
+1. checkParamTags : Replaced integer subtraction with addition → KILLED + + + + |
+ arg1.substring(1, arg1.length() - 1)); |
+ +888 + | ++ + + + + + | + } |
+ +889 + | ++ + + + + + | +|
+ +890 + | ++ + + + + + | + // Handle extra JavadocTag |
+ +891 + | +
+
+1
+
+
+1. checkParamTags : negated conditional → KILLED + + + + |
+ if (!found) { |
+ +892 + | +
+
+1
+
+
+1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(tag.getLineNo(), tag.getColumnNo(), MSG_UNUSED_TAG, |
+ +893 + | ++ + + + + + | + "@param", arg1); |
+ +894 + | ++ + + + + + | + } |
+ +895 + | ++ + + + + + | + } |
+ +896 + | ++ + + + + + | +|
+ +897 + | ++ + + + + + | + // Now dump out all type parameters/parameters without tags :- unless |
+ +898 + | ++ + + + + + | + // the user has chosen to suppress these problems |
+ +899 + | +
+
+2
+
+
+1. checkParamTags : negated conditional → KILLED + +2. checkParamTags : negated conditional → KILLED + + + + |
+ if (!allowMissingParamTags && reportExpectedTags) { |
+ +900 + | ++ + + + + + | + for (DetailAST param : params) { |
+ +901 + | +
+
+1
+
+
+1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(param, MSG_EXPECTED_TAG, |
+ +902 + | ++ + + + + + | + JavadocTagInfo.PARAM.getText(), param.getText()); |
+ +903 + | ++ + + + + + | + } |
+ +904 + | ++ + + + + + | +|
+ +905 + | ++ + + + + + | + for (DetailAST typeParam : typeParams) { |
+ +906 + | +
+
+1
+
+
+1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(typeParam, MSG_EXPECTED_TAG, |
+ +907 + | +
+
+1
+
+
+1. checkParamTags : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ JavadocTagInfo.PARAM.getText(), |
+ +908 + | ++ + + + + + | + "<" + typeParam.findFirstToken(TokenTypes.IDENT).getText() |
+ +909 + | ++ + + + + + | + + ">"); |
+ +910 + | ++ + + + + + | + } |
+ +911 + | ++ + + + + + | + } |
+ +912 + | ++ + + + + + | + } |
+ +913 + | ++ + + + + + | +|
+ +914 + | ++ + + + + + | + /** |
+ +915 + | ++ + + + + + | + * Returns true if required type found in type parameters. |
+ +916 + | ++ + + + + + | + * |
+ +917 + | ++ + + + + + | + * @param typeParams |
+ +918 + | ++ + + + + + | + * list of type parameters |
+ +919 + | ++ + + + + + | + * @param requiredTypeName |
+ +920 + | ++ + + + + + | + * name of required type |
+ +921 + | ++ + + + + + | + * @return true if required type found in type parameters. |
+ +922 + | ++ + + + + + | + */ |
+ +923 + | ++ + + + + + | + private static boolean searchMatchingTypeParameter(List<DetailAST> typeParams, |
+ +924 + | ++ + + + + + | + String requiredTypeName) { |
+ +925 + | ++ + + + + + | + // Loop looking for matching type param |
+ +926 + | ++ + + + + + | + final Iterator<DetailAST> typeParamsIt = typeParams.iterator(); |
+ +927 + | ++ + + + + + | + boolean found = false; |
+ +928 + | +
+
+1
+
+
+1. searchMatchingTypeParameter : negated conditional → KILLED + + + + |
+ while (typeParamsIt.hasNext()) { |
+ +929 + | ++ + + + + + | + final DetailAST typeParam = typeParamsIt.next(); |
+ +930 + | ++ + + + + + | + if (typeParam.findFirstToken(TokenTypes.IDENT).getText() |
+ +931 + | +
+
+1
+
+
+1. searchMatchingTypeParameter : negated conditional → KILLED + + + + |
+ .equals(requiredTypeName)) { |
+ +932 + | ++ + + + + + | + found = true; |
+ +933 + | +
+
+1
+
+
+1. searchMatchingTypeParameter : removed call to java/util/Iterator::remove → KILLED + + + + |
+ typeParamsIt.remove(); |
+ +934 + | ++ + + + + + | + break; |
+ +935 + | ++ + + + + + | + } |
+ +936 + | ++ + + + + + | + } |
+ +937 + | +
+
+3
+
+
+1. searchMatchingTypeParameter : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::searchMatchingTypeParameter → KILLED + +2. searchMatchingTypeParameter : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::searchMatchingTypeParameter → KILLED + +3. searchMatchingTypeParameter : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return found; |
+ +938 + | ++ + + + + + | + } |
+ +939 + | ++ + + + + + | +|
+ +940 + | ++ + + + + + | + /** |
+ +941 + | ++ + + + + + | + * Remove parameter from params collection by name. |
+ +942 + | ++ + + + + + | + * |
+ +943 + | ++ + + + + + | + * @param params collection of DetailAST parameters |
+ +944 + | ++ + + + + + | + * @param paramName name of parameter |
+ +945 + | ++ + + + + + | + * @return true if parameter found and removed |
+ +946 + | ++ + + + + + | + */ |
+ +947 + | ++ + + + + + | + private static boolean removeMatchingParam(List<DetailAST> params, String paramName) { |
+ +948 + | ++ + + + + + | + boolean found = false; |
+ +949 + | ++ + + + + + | + final Iterator<DetailAST> paramIt = params.iterator(); |
+ +950 + | +
+
+1
+
+
+1. removeMatchingParam : negated conditional → KILLED + + + + |
+ while (paramIt.hasNext()) { |
+ +951 + | ++ + + + + + | + final DetailAST param = paramIt.next(); |
+ +952 + | +
+
+1
+
+
+1. removeMatchingParam : negated conditional → KILLED + + + + |
+ if (param.getText().equals(paramName)) { |
+ +953 + | ++ + + + + + | + found = true; |
+ +954 + | +
+
+1
+
+
+1. removeMatchingParam : removed call to java/util/Iterator::remove → KILLED + + + + |
+ paramIt.remove(); |
+ +955 + | ++ + + + + + | + break; |
+ +956 + | ++ + + + + + | + } |
+ +957 + | ++ + + + + + | + } |
+ +958 + | +
+
+3
+
+
+1. removeMatchingParam : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::removeMatchingParam → KILLED + +2. removeMatchingParam : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::removeMatchingParam → KILLED + +3. removeMatchingParam : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return found; |
+ +959 + | ++ + + + + + | + } |
+ +960 + | ++ + + + + + | +|
+ +961 + | ++ + + + + + | + /** |
+ +962 + | ++ + + + + + | + * Checks for only one return tag. All return tags will be removed from the |
+ +963 + | ++ + + + + + | + * supplied list. |
+ +964 + | ++ + + + + + | + * |
+ +965 + | ++ + + + + + | + * @param tags the tags to check |
+ +966 + | ++ + + + + + | + * @param lineNo the line number of the expected tag |
+ +967 + | ++ + + + + + | + * @param reportExpectedTags whether we should report if do not find |
+ +968 + | ++ + + + + + | + * expected tag |
+ +969 + | ++ + + + + + | + */ |
+ +970 + | ++ + + + + + | + private void checkReturnTag(List<JavadocTag> tags, int lineNo, |
+ +971 + | ++ + + + + + | + boolean reportExpectedTags) { |
+ +972 + | ++ + + + + + | + // Loop over tags finding return tags. After the first one, report an |
+ +973 + | ++ + + + + + | + // violation. |
+ +974 + | ++ + + + + + | + boolean found = false; |
+ +975 + | ++ + + + + + | + final ListIterator<JavadocTag> it = tags.listIterator(); |
+ +976 + | +
+
+1
+
+
+1. checkReturnTag : negated conditional → KILLED + + + + |
+ while (it.hasNext()) { |
+ +977 + | ++ + + + + + | + final JavadocTag javadocTag = it.next(); |
+ +978 + | +
+
+1
+
+
+1. checkReturnTag : negated conditional → KILLED + + + + |
+ if (javadocTag.isReturnTag()) { |
+ +979 + | +
+
+1
+
+
+1. checkReturnTag : negated conditional → KILLED + + + + |
+ if (found) { |
+ +980 + | +
+
+1
+
+
+1. checkReturnTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(javadocTag.getLineNo(), javadocTag.getColumnNo(), |
+ +981 + | ++ + + + + + | + MSG_DUPLICATE_TAG, |
+ +982 + | ++ + + + + + | + JavadocTagInfo.RETURN.getText()); |
+ +983 + | ++ + + + + + | + } |
+ +984 + | ++ + + + + + | + found = true; |
+ +985 + | +
+
+1
+
+
+1. checkReturnTag : removed call to java/util/ListIterator::remove → KILLED + + + + |
+ it.remove(); |
+ +986 + | ++ + + + + + | + } |
+ +987 + | ++ + + + + + | + } |
+ +988 + | ++ + + + + + | +|
+ +989 + | ++ + + + + + | + // Handle there being no @return tags :- unless |
+ +990 + | ++ + + + + + | + // the user has chosen to suppress these problems |
+ +991 + | +
+
+3
+
+
+1. checkReturnTag : negated conditional → KILLED + +2. checkReturnTag : negated conditional → KILLED + +3. checkReturnTag : negated conditional → KILLED + + + + |
+ if (!found && !allowMissingReturnTag && reportExpectedTags) { |
+ +992 + | +
+
+1
+
+
+1. checkReturnTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(lineNo, MSG_RETURN_EXPECTED); |
+ +993 + | ++ + + + + + | + } |
+ +994 + | ++ + + + + + | + } |
+ +995 + | ++ + + + + + | +|
+ +996 + | ++ + + + + + | + /** |
+ +997 + | ++ + + + + + | + * Checks a set of tags for matching throws. |
+ +998 + | ++ + + + + + | + * |
+ +999 + | ++ + + + + + | + * @param tags the tags to check |
+ +1000 + | ++ + + + + + | + * @param throwsList the throws to check |
+ +1001 + | ++ + + + + + | + * @param reportExpectedTags whether we should report if do not find |
+ +1002 + | ++ + + + + + | + * expected tag |
+ +1003 + | ++ + + + + + | + */ |
+ +1004 + | ++ + + + + + | + private void checkThrowsTags(List<JavadocTag> tags, |
+ +1005 + | ++ + + + + + | + List<ExceptionInfo> throwsList, boolean reportExpectedTags) { |
+ +1006 + | ++ + + + + + | + // Loop over the tags, checking to see they exist in the throws. |
+ +1007 + | ++ + + + + + | + // The foundThrows used for performance only |
+ +1008 + | +
+
+1
+
+
+1. checkThrowsTags : removed call to java/util/HashSet::<init> → KILLED + + + + |
+ final Set<String> foundThrows = new HashSet<>(); |
+ +1009 + | ++ + + + + + | + final ListIterator<JavadocTag> tagIt = tags.listIterator(); |
+ +1010 + | +
+
+1
+
+
+1. checkThrowsTags : negated conditional → KILLED + + + + |
+ while (tagIt.hasNext()) { |
+ +1011 + | ++ + + + + + | + final JavadocTag tag = tagIt.next(); |
+ +1012 + | ++ + + + + + | +|
+ +1013 + | +
+
+1
+
+
+1. checkThrowsTags : negated conditional → KILLED + + + + |
+ if (!tag.isThrowsTag()) { |
+ +1014 + | ++ + + + + + | + continue; |
+ +1015 + | ++ + + + + + | + } |
+ +1016 + | +
+
+1
+
+
+1. checkThrowsTags : removed call to java/util/ListIterator::remove → KILLED + + + + |
+ tagIt.remove(); |
+ +1017 + | ++ + + + + + | +|
+ +1018 + | ++ + + + + + | + // Loop looking for matching throw |
+ +1019 + | ++ + + + + + | + final Token token = new Token(tag.getFirstArg(), tag.getLineNo(), tag |
+ +1020 + | +
+
+1
+
+
+1. checkThrowsTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED + + + + |
+ .getColumnNo()); |
+ +1021 + | ++ + + + + + | + final ClassInfo documentedClassInfo = createClassInfo(token, |
+ +1022 + | ++ + + + + + | + currentClassName); |
+ +1023 + | +
+
+1
+
+
+1. checkThrowsTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processThrows → KILLED + + + + |
+ processThrows(throwsList, documentedClassInfo, foundThrows); |
+ +1024 + | ++ + + + + + | + } |
+ +1025 + | ++ + + + + + | + // Now dump out all throws without tags :- unless |
+ +1026 + | ++ + + + + + | + // the user has chosen to suppress these problems |
+ +1027 + | +
+
+2
+
+
+1. checkThrowsTags : negated conditional → KILLED + +2. checkThrowsTags : negated conditional → KILLED + + + + |
+ if (validateThrows && reportExpectedTags) { |
+ +1028 + | +
+
+3
+
+
+1. lambda$checkThrowsTags$3 : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::lambda$checkThrowsTags$3 → KILLED + +2. lambda$checkThrowsTags$3 : negated conditional → KILLED + +3. lambda$checkThrowsTags$3 : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ throwsList.stream().filter(exceptionInfo -> !exceptionInfo.isFound()) |
+ +1029 + | +
+
+1
+
+
+1. checkThrowsTags : removed call to java/util/stream/Stream::forEach → KILLED + + + + |
+ .forEach(exceptionInfo -> { |
+ +1030 + | ++ + + + + + | + final Token token = exceptionInfo.getName(); |
+ +1031 + | +
+
+1
+
+
+1. lambda$checkThrowsTags$4 : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED + + + + |
+ log(token.getLineNo(), token.getColumnNo(), |
+ +1032 + | ++ + + + + + | + MSG_EXPECTED_TAG, |
+ +1033 + | ++ + + + + + | + JavadocTagInfo.THROWS.getText(), token.getText()); |
+ +1034 + | ++ + + + + + | + }); |
+ +1035 + | ++ + + + + + | + } |
+ +1036 + | ++ + + + + + | + } |
+ +1037 + | ++ + + + + + | +|
+ +1038 + | ++ + + + + + | + /** |
+ +1039 + | ++ + + + + + | + * Verifies that documented exception is in throws. |
+ +1040 + | ++ + + + + + | + * |
+ +1041 + | ++ + + + + + | + * @param throwsList list of throws |
+ +1042 + | ++ + + + + + | + * @param documentedClassInfo documented exception class info |
+ +1043 + | ++ + + + + + | + * @param foundThrows previously found throws |
+ +1044 + | ++ + + + + + | + */ |
+ +1045 + | ++ + + + + + | + private static void processThrows(List<ExceptionInfo> throwsList, |
+ +1046 + | ++ + + + + + | + ClassInfo documentedClassInfo, Set<String> foundThrows) { |
+ +1047 + | ++ + + + + + | + ExceptionInfo foundException = null; |
+ +1048 + | ++ + + + + + | +|
+ +1049 + | ++ + + + + + | + // First look for matches on the exception name |
+ +1050 + | ++ + + + + + | + for (ExceptionInfo exceptionInfo : throwsList) { |
+ +1051 + | +
+
+1
+
+
+1. processThrows : negated conditional → KILLED + + + + |
+ if (isClassNamesSame(exceptionInfo.getName().getText(), |
+ +1052 + | ++ + + + + + | + documentedClassInfo.getName().getText())) { |
+ +1053 + | ++ + + + + + | + foundException = exceptionInfo; |
+ +1054 + | ++ + + + + + | + break; |
+ +1055 + | ++ + + + + + | + } |
+ +1056 + | ++ + + + + + | + } |
+ +1057 + | ++ + + + + + | +|
+ +1058 + | +
+
+1
+
+
+1. processThrows : negated conditional → KILLED + + + + |
+ if (foundException != null) { |
+ +1059 + | +
+
+1
+
+
+1. processThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::access$100 → KILLED + + + + |
+ foundException.setFound(); |
+ +1060 + | ++ + + + + + | + foundThrows.add(documentedClassInfo.getName().getText()); |
+ +1061 + | ++ + + + + + | + } |
+ +1062 + | ++ + + + + + | + } |
+ +1063 + | ++ + + + + + | +|
+ +1064 + | ++ + + + + + | + /** |
+ +1065 + | ++ + + + + + | + * Check that ExceptionInfo objects are same by name. |
+ +1066 + | ++ + + + + + | + * |
+ +1067 + | ++ + + + + + | + * @param info1 ExceptionInfo object |
+ +1068 + | ++ + + + + + | + * @param info2 ExceptionInfo object |
+ +1069 + | ++ + + + + + | + * @return true is ExceptionInfo object have the same name |
+ +1070 + | ++ + + + + + | + */ |
+ +1071 + | ++ + + + + + | + private static boolean isExceptionInfoSame(ExceptionInfo info1, ExceptionInfo info2) { |
+ +1072 + | +
+
+3
+
+
+1. isExceptionInfoSame : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::isExceptionInfoSame → KILLED + +2. isExceptionInfoSame : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::isExceptionInfoSame → KILLED + +3. isExceptionInfoSame : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return isClassNamesSame(info1.getName().getText(), |
+ +1073 + | ++ + + + + + | + info2.getName().getText()); |
+ +1074 + | ++ + + + + + | + } |
+ +1075 + | ++ + + + + + | +|
+ +1076 + | ++ + + + + + | + /** |
+ +1077 + | ++ + + + + + | + * Check that class names are same by short name of class. If some class name is fully |
+ +1078 + | ++ + + + + + | + * qualified it is cut to short name. |
+ +1079 + | ++ + + + + + | + * |
+ +1080 + | ++ + + + + + | + * @param class1 class name |
+ +1081 + | ++ + + + + + | + * @param class2 class name |
+ +1082 + | ++ + + + + + | + * @return true is ExceptionInfo object have the same name |
+ +1083 + | ++ + + + + + | + */ |
+ +1084 + | ++ + + + + + | + private static boolean isClassNamesSame(String class1, String class2) { |
+ +1085 + | ++ + + + + + | + boolean result = false; |
+ +1086 + | +
+
+1
+
+
+1. isClassNamesSame : negated conditional → KILLED + + + + |
+ if (class1.equals(class2)) { |
+ +1087 + | ++ + + + + + | + result = true; |
+ +1088 + | ++ + + + + + | + } |
+ +1089 + | ++ + + + + + | + else { |
+ +1090 + | ++ + + + + + | + final String separator = "."; |
+ +1091 + | +
+
+2
+
+
+1. isClassNamesSame : negated conditional → KILLED + +2. isClassNamesSame : negated conditional → KILLED + + + + |
+ if (class1.contains(separator) || class2.contains(separator)) { |
+ +1092 + | ++ + + + + + | + final String class1ShortName = class1 |
+ +1093 + | +
+
+1
+
+
+1. isClassNamesSame : Replaced integer addition with subtraction → KILLED + + + + |
+ .substring(class1.lastIndexOf('.') + 1); |
+ +1094 + | ++ + + + + + | + final String class2ShortName = class2 |
+ +1095 + | +
+
+1
+
+
+1. isClassNamesSame : Replaced integer addition with subtraction → KILLED + + + + |
+ .substring(class2.lastIndexOf('.') + 1); |
+ +1096 + | ++ + + + + + | + result = class1ShortName.equals(class2ShortName); |
+ +1097 + | ++ + + + + + | + } |
+ +1098 + | ++ + + + + + | + } |
+ +1099 + | +
+
+3
+
+
+1. isClassNamesSame : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::isClassNamesSame → KILLED + +2. isClassNamesSame : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::isClassNamesSame → KILLED + +3. isClassNamesSame : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +1100 + | ++ + + + + + | + } |
+ +1101 + | ++ + + + + + | +|
+ +1102 + | ++ + + + + + | + /** |
+ +1103 + | ++ + + + + + | + * Process type params (if any) for given class, enum or method. |
+ +1104 + | ++ + + + + + | + * |
+ +1105 + | ++ + + + + + | + * @param ast class, enum or method to process. |
+ +1106 + | ++ + + + + + | + */ |
+ +1107 + | ++ + + + + + | + private void processTypeParams(DetailAST ast) { |
+ +1108 + | ++ + + + + + | + final DetailAST params = |
+ +1109 + | ++ + + + + + | + ast.findFirstToken(TokenTypes.TYPE_PARAMETERS); |
+ +1110 + | ++ + + + + + | +|
+ +1111 + | +
+
+1
+
+
+1. processTypeParams : removed call to java/util/HashMap::<init> → KILLED + + + + |
+ final Map<String, ClassInfo> paramsMap = new HashMap<>(); |
+ +1112 + | +
+
+1
+
+
+1. processTypeParams : removed call to java/util/Deque::push → KILLED + + + + |
+ currentTypeParams.push(paramsMap); |
+ +1113 + | ++ + + + + + | +|
+ +1114 + | +
+
+1
+
+
+1. processTypeParams : negated conditional → KILLED + + + + |
+ if (params != null) { |
+ +1115 + | ++ + + + + + | + for (DetailAST child = params.getFirstChild(); |
+ +1116 + | +
+
+1
+
+
+1. processTypeParams : negated conditional → SURVIVED + + + + |
+ child != null; |
+ +1117 + | ++ + + + + + | + child = child.getNextSibling()) { |
+ +1118 + | +
+
+1
+
+
+1. processTypeParams : negated conditional → SURVIVED + + + + |
+ if (child.getType() == TokenTypes.TYPE_PARAMETER) { |
+ +1119 + | ++ + + + + + | + final DetailAST bounds = |
+ +1120 + | ++ + + + + + | + child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS); |
+ +1121 + | +
+
+1
+
+
+1. processTypeParams : negated conditional → KILLED + + + + |
+ if (bounds != null) { |
+ +1122 + | ++ + + + + + | + final FullIdent name = |
+ +1123 + | ++ + + + + + | + FullIdent.createFullIdentBelow(bounds); |
+ +1124 + | +
+
+1
+
+
+1. processTypeParams : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED + + + + |
+ final ClassInfo classInfo = |
+ +1125 + | ++ + + + + + | + createClassInfo(new Token(name), currentClassName); |
+ +1126 + | ++ + + + + + | + final String alias = |
+ +1127 + | ++ + + + + + | + child.findFirstToken(TokenTypes.IDENT).getText(); |
+ +1128 + | ++ + + + + + | + paramsMap.put(alias, classInfo); |
+ +1129 + | ++ + + + + + | + } |
+ +1130 + | ++ + + + + + | + } |
+ +1131 + | ++ + + + + + | + } |
+ +1132 + | ++ + + + + + | + } |
+ +1133 + | ++ + + + + + | + } |
+ +1134 + | ++ + + + + + | +|
+ +1135 + | ++ + + + + + | + /** |
+ +1136 + | ++ + + + + + | + * Processes class definition. |
+ +1137 + | ++ + + + + + | + * |
+ +1138 + | ++ + + + + + | + * @param ast class definition to process. |
+ +1139 + | ++ + + + + + | + */ |
+ +1140 + | ++ + + + + + | + private void processClass(DetailAST ast) { |
+ +1141 + | ++ + + + + + | + final DetailAST ident = ast.findFirstToken(TokenTypes.IDENT); |
+ +1142 + | ++ + + + + + | + String innerClass = ident.getText(); |
+ +1143 + | ++ + + + + + | +|
+ +1144 + | +
+
+1
+
+
+1. processClass : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ innerClass = "$" + innerClass; |
+ +1145 + | +
+
+1
+
+
+1. processClass : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ currentClassName += innerClass; |
+ +1146 + | +
+
+1
+
+
+1. processClass : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processTypeParams → KILLED + + + + |
+ processTypeParams(ast); |
+ +1147 + | ++ + + + + + | + } |
+ +1148 + | ++ + + + + + | +|
+ +1149 + | ++ + + + + + | + /** |
+ +1150 + | ++ + + + + + | + * Creates class info for given name. |
+ +1151 + | ++ + + + + + | + * |
+ +1152 + | ++ + + + + + | + * @param name name of type. |
+ +1153 + | ++ + + + + + | + * @param surroundingClass name of surrounding class. |
+ +1154 + | ++ + + + + + | + * @return class info for given name. |
+ +1155 + | ++ + + + + + | + */ |
+ +1156 + | ++ + + + + + | + private ClassInfo createClassInfo(final Token name, |
+ +1157 + | ++ + + + + + | + final String surroundingClass) { |
+ +1158 + | ++ + + + + + | + final ClassInfo result; |
+ +1159 + | ++ + + + + + | + final ClassInfo classInfo = findClassAlias(name.getText()); |
+ +1160 + | +
+
+1
+
+
+1. createClassInfo : negated conditional → SURVIVED + + + + |
+ if (classInfo == null) { |
+ +1161 + | +
+
+1
+
+
+1. createClassInfo : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$RegularClass::<init> → KILLED + + + + |
+ result = new RegularClass(name, surroundingClass, this); |
+ +1162 + | ++ + + + + + | + } |
+ +1163 + | ++ + + + + + | + else { |
+ +1164 + | +
+
+1
+
+
+1. createClassInfo : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ClassAlias::<init> → KILLED + + + + |
+ result = new ClassAlias(name, classInfo); |
+ +1165 + | ++ + + + + + | + } |
+ +1166 + | +
+
+1
+
+
+1. createClassInfo : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::createClassInfo to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result; |
+ +1167 + | ++ + + + + + | + } |
+ +1168 + | ++ + + + + + | +|
+ +1169 + | ++ + + + + + | + /** |
+ +1170 + | ++ + + + + + | + * Looking if a given name is alias. |
+ +1171 + | ++ + + + + + | + * |
+ +1172 + | ++ + + + + + | + * @param name given name |
+ +1173 + | ++ + + + + + | + * @return ClassInfo for alias if it exists, null otherwise |
+ +1174 + | ++ + + + + + | + * @noinspection WeakerAccess |
+ +1175 + | ++ + + + + + | + */ |
+ +1176 + | ++ + + + + + | + private ClassInfo findClassAlias(final String name) { |
+ +1177 + | ++ + + + + + | + ClassInfo classInfo = null; |
+ +1178 + | ++ + + + + + | + final Iterator<Map<String, ClassInfo>> iterator = currentTypeParams |
+ +1179 + | ++ + + + + + | + .descendingIterator(); |
+ +1180 + | +
+
+1
+
+
+1. findClassAlias : negated conditional → SURVIVED + + + + |
+ while (iterator.hasNext()) { |
+ +1181 + | ++ + + + + + | + final Map<String, ClassInfo> paramMap = iterator.next(); |
+ +1182 + | ++ + + + + + | + classInfo = paramMap.get(name); |
+ +1183 + | +
+
+1
+
+
+1. findClassAlias : negated conditional → SURVIVED + + + + |
+ if (classInfo != null) { |
+ +1184 + | ++ + + + + + | + break; |
+ +1185 + | ++ + + + + + | + } |
+ +1186 + | ++ + + + + + | + } |
+ +1187 + | +
+
+1
+
+
+1. findClassAlias : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::findClassAlias to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return classInfo; |
+ +1188 + | ++ + + + + + | + } |
+ +1189 + | ++ + + + + + | +|
+ +1190 + | ++ + + + + + | + /** |
+ +1191 + | ++ + + + + + | + * Contains class's {@code Token}. |
+ +1192 + | ++ + + + + + | + */ |
+ +1193 + | ++ + + + + + | + private static class ClassInfo { |
+ +1194 + | ++ + + + + + | +|
+ +1195 + | ++ + + + + + | + /** {@code FullIdent} associated with this class. */ |
+ +1196 + | ++ + + + + + | + private final Token name; |
+ +1197 + | ++ + + + + + | +|
+ +1198 + | ++ + + + + + | + /** |
+ +1199 + | ++ + + + + + | + * Creates new instance of class information object. |
+ +1200 + | ++ + + + + + | + * |
+ +1201 + | ++ + + + + + | + * @param className token which represents class name. |
+ +1202 + | ++ + + + + + | + * @throws IllegalArgumentException when className is nulls |
+ +1203 + | ++ + + + + + | + */ |
+ +1204 + | ++ + + + + + | + protected ClassInfo(final Token className) { |
+ +1205 + | +
+
+1
+
+
+1. + + |
+ if (className == null) { |
+ +1206 + | +
+
+1
+
+
+1. + + |
+ throw new IllegalArgumentException( |
+ +1207 + | ++ + + + + + | + "ClassInfo's name should be non-null"); |
+ +1208 + | ++ + + + + + | + } |
+ +1209 + | ++ + + + + + | + name = className; |
+ +1210 + | ++ + + + + + | + } |
+ +1211 + | ++ + + + + + | +|
+ +1212 + | ++ + + + + + | + /** |
+ +1213 + | ++ + + + + + | + * Gets class name. |
+ +1214 + | ++ + + + + + | + * |
+ +1215 + | ++ + + + + + | + * @return class name |
+ +1216 + | ++ + + + + + | + */ |
+ +1217 + | ++ + + + + + | + public final Token getName() { |
+ +1218 + | +
+
+1
+
+
+1. getName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ClassInfo::getName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return name; |
+ +1219 + | ++ + + + + + | + } |
+ +1220 + | ++ + + + + + | +|
+ +1221 + | ++ + + + + + | + } |
+ +1222 + | ++ + + + + + | +|
+ +1223 + | ++ + + + + + | + /** Represents regular classes/enums. */ |
+ +1224 + | ++ + + + + + | + private static final class RegularClass extends ClassInfo { |
+ +1225 + | ++ + + + + + | +|
+ +1226 + | ++ + + + + + | + /** Name of surrounding class. */ |
+ +1227 + | ++ + + + + + | + private final String surroundingClass; |
+ +1228 + | ++ + + + + + | + /** The check we use to resolve classes. */ |
+ +1229 + | ++ + + + + + | + private final JavadocMethodCheck check; |
+ +1230 + | ++ + + + + + | +|
+ +1231 + | ++ + + + + + | + /** |
+ +1232 + | ++ + + + + + | + * Creates new instance of of class information object. |
+ +1233 + | ++ + + + + + | + * |
+ +1234 + | ++ + + + + + | + * @param name {@code FullIdent} associated with new object. |
+ +1235 + | ++ + + + + + | + * @param surroundingClass name of current surrounding class. |
+ +1236 + | ++ + + + + + | + * @param check the check we use to load class. |
+ +1237 + | ++ + + + + + | + */ |
+ +1238 + | ++ + + + + + | + /* package */ RegularClass(final Token name, |
+ +1239 + | ++ + + + + + | + final String surroundingClass, |
+ +1240 + | ++ + + + + + | + final JavadocMethodCheck check) { |
+ +1241 + | ++ + + + + + | + super(name); |
+ +1242 + | ++ + + + + + | + this.surroundingClass = surroundingClass; |
+ +1243 + | ++ + + + + + | + this.check = check; |
+ +1244 + | ++ + + + + + | + } |
+ +1245 + | ++ + + + + + | +|
+ +1246 + | ++ + + + + + | + @Override |
+ +1247 + | ++ + + + + + | + public String toString() { |
+ +1248 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$RegularClass::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "RegularClass[name=" + getName() |
+ +1249 + | ++ + + + + + | + + ", in class='" + surroundingClass + '\'' |
+ +1250 + | ++ + + + + + | + + ", check=" + check.hashCode() |
+ +1251 + | ++ + + + + + | + + ']'; |
+ +1252 + | ++ + + + + + | + } |
+ +1253 + | ++ + + + + + | +|
+ +1254 + | ++ + + + + + | + } |
+ +1255 + | ++ + + + + + | +|
+ +1256 + | ++ + + + + + | + /** Represents type param which is "alias" for real type. */ |
+ +1257 + | ++ + + + + + | + private static class ClassAlias extends ClassInfo { |
+ +1258 + | ++ + + + + + | +|
+ +1259 + | ++ + + + + + | + /** Class information associated with the alias. */ |
+ +1260 + | ++ + + + + + | + private final ClassInfo classInfo; |
+ +1261 + | ++ + + + + + | +|
+ +1262 + | ++ + + + + + | + /** |
+ +1263 + | ++ + + + + + | + * Creates new instance of the class. |
+ +1264 + | ++ + + + + + | + * |
+ +1265 + | ++ + + + + + | + * @param name token which represents name of class alias. |
+ +1266 + | ++ + + + + + | + * @param classInfo class information associated with the alias. |
+ +1267 + | ++ + + + + + | + */ |
+ +1268 + | ++ + + + + + | + /* package */ ClassAlias(final Token name, ClassInfo classInfo) { |
+ +1269 + | ++ + + + + + | + super(name); |
+ +1270 + | ++ + + + + + | + this.classInfo = classInfo; |
+ +1271 + | ++ + + + + + | + } |
+ +1272 + | ++ + + + + + | +|
+ +1273 + | ++ + + + + + | + @Override |
+ +1274 + | ++ + + + + + | + public String toString() { |
+ +1275 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ClassAlias::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "ClassAlias[alias " + getName() + " for " + classInfo.getName() + "]"; |
+ +1276 + | ++ + + + + + | + } |
+ +1277 + | ++ + + + + + | +|
+ +1278 + | ++ + + + + + | + } |
+ +1279 + | ++ + + + + + | +|
+ +1280 + | ++ + + + + + | + /** |
+ +1281 + | ++ + + + + + | + * Represents text element with location in the text. |
+ +1282 + | ++ + + + + + | + */ |
+ +1283 + | ++ + + + + + | + private static class Token { |
+ +1284 + | ++ + + + + + | +|
+ +1285 + | ++ + + + + + | + /** Token's column number. */ |
+ +1286 + | ++ + + + + + | + private final int columnNo; |
+ +1287 + | ++ + + + + + | + /** Token's line number. */ |
+ +1288 + | ++ + + + + + | + private final int lineNo; |
+ +1289 + | ++ + + + + + | + /** Token's text. */ |
+ +1290 + | ++ + + + + + | + private final String text; |
+ +1291 + | ++ + + + + + | +|
+ +1292 + | ++ + + + + + | + /** |
+ +1293 + | ++ + + + + + | + * Creates token. |
+ +1294 + | ++ + + + + + | + * |
+ +1295 + | ++ + + + + + | + * @param text token's text |
+ +1296 + | ++ + + + + + | + * @param lineNo token's line number |
+ +1297 + | ++ + + + + + | + * @param columnNo token's column number |
+ +1298 + | ++ + + + + + | + */ |
+ +1299 + | ++ + + + + + | + /* package */ Token(String text, int lineNo, int columnNo) { |
+ +1300 + | ++ + + + + + | + this.text = text; |
+ +1301 + | ++ + + + + + | + this.lineNo = lineNo; |
+ +1302 + | ++ + + + + + | + this.columnNo = columnNo; |
+ +1303 + | ++ + + + + + | + } |
+ +1304 + | ++ + + + + + | +|
+ +1305 + | ++ + + + + + | + /** |
+ +1306 + | ++ + + + + + | + * Converts FullIdent to Token. |
+ +1307 + | ++ + + + + + | + * |
+ +1308 + | ++ + + + + + | + * @param fullIdent full ident to convert. |
+ +1309 + | ++ + + + + + | + */ |
+ +1310 + | ++ + + + + + | + /* package */ Token(FullIdent fullIdent) { |
+ +1311 + | ++ + + + + + | + text = fullIdent.getText(); |
+ +1312 + | ++ + + + + + | + lineNo = fullIdent.getLineNo(); |
+ +1313 + | ++ + + + + + | + columnNo = fullIdent.getColumnNo(); |
+ +1314 + | ++ + + + + + | + } |
+ +1315 + | ++ + + + + + | +|
+ +1316 + | ++ + + + + + | + /** |
+ +1317 + | ++ + + + + + | + * Gets line number of the token. |
+ +1318 + | ++ + + + + + | + * |
+ +1319 + | ++ + + + + + | + * @return line number of the token |
+ +1320 + | ++ + + + + + | + */ |
+ +1321 + | ++ + + + + + | + public int getLineNo() { |
+ +1322 + | +
+
+1
+
+
+1. getLineNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNo; |
+ +1323 + | ++ + + + + + | + } |
+ +1324 + | ++ + + + + + | +|
+ +1325 + | ++ + + + + + | + /** |
+ +1326 + | ++ + + + + + | + * Gets column number of the token. |
+ +1327 + | ++ + + + + + | + * |
+ +1328 + | ++ + + + + + | + * @return column number of the token |
+ +1329 + | ++ + + + + + | + */ |
+ +1330 + | ++ + + + + + | + public int getColumnNo() { |
+ +1331 + | +
+
+1
+
+
+1. getColumnNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return columnNo; |
+ +1332 + | ++ + + + + + | + } |
+ +1333 + | ++ + + + + + | +|
+ +1334 + | ++ + + + + + | + /** |
+ +1335 + | ++ + + + + + | + * Gets text of the token. |
+ +1336 + | ++ + + + + + | + * |
+ +1337 + | ++ + + + + + | + * @return text of the token |
+ +1338 + | ++ + + + + + | + */ |
+ +1339 + | ++ + + + + + | + public String getText() { |
+ +1340 + | +
+
+1
+
+
+1. getText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::getText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return text; |
+ +1341 + | ++ + + + + + | + } |
+ +1342 + | ++ + + + + + | +|
+ +1343 + | ++ + + + + + | + @Override |
+ +1344 + | ++ + + + + + | + public String toString() { |
+ +1345 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "Token[" + text + "(" + lineNo |
+ +1346 + | ++ + + + + + | + + "x" + columnNo + ")]"; |
+ +1347 + | ++ + + + + + | + } |
+ +1348 + | ++ + + + + + | +|
+ +1349 + | ++ + + + + + | + } |
+ +1350 + | ++ + + + + + | +|
+ +1351 + | ++ + + + + + | + /** Stores useful information about declared exception. */ |
+ +1352 + | ++ + + + + + | + private static class ExceptionInfo { |
+ +1353 + | ++ + + + + + | +|
+ +1354 + | ++ + + + + + | + /** Class information associated with this exception. */ |
+ +1355 + | ++ + + + + + | + private final ClassInfo classInfo; |
+ +1356 + | ++ + + + + + | + /** Does the exception have throws tag associated with. */ |
+ +1357 + | ++ + + + + + | + private boolean found; |
+ +1358 + | ++ + + + + + | +|
+ +1359 + | ++ + + + + + | + /** |
+ +1360 + | ++ + + + + + | + * Creates new instance for {@code FullIdent}. |
+ +1361 + | ++ + + + + + | + * |
+ +1362 + | ++ + + + + + | + * @param classInfo class info |
+ +1363 + | ++ + + + + + | + */ |
+ +1364 + | ++ + + + + + | + /* package */ ExceptionInfo(ClassInfo classInfo) { |
+ +1365 + | ++ + + + + + | + this.classInfo = classInfo; |
+ +1366 + | ++ + + + + + | + } |
+ +1367 + | ++ + + + + + | +|
+ +1368 + | ++ + + + + + | + /** Mark that the exception has associated throws tag. */ |
+ +1369 + | ++ + + + + + | + private void setFound() { |
+ +1370 + | ++ + + + + + | + found = true; |
+ +1371 + | ++ + + + + + | + } |
+ +1372 + | ++ + + + + + | +|
+ +1373 + | ++ + + + + + | + /** |
+ +1374 + | ++ + + + + + | + * Checks that the exception has throws tag associated with it. |
+ +1375 + | ++ + + + + + | + * |
+ +1376 + | ++ + + + + + | + * @return whether the exception has throws tag associated with |
+ +1377 + | ++ + + + + + | + */ |
+ +1378 + | ++ + + + + + | + private boolean isFound() { |
+ +1379 + | +
+
+3
+
+
+1. isFound : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::isFound → KILLED + +2. isFound : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::isFound → KILLED + +3. isFound : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return found; |
+ +1380 + | ++ + + + + + | + } |
+ +1381 + | ++ + + + + + | +|
+ +1382 + | ++ + + + + + | + /** |
+ +1383 + | ++ + + + + + | + * Gets exception name. |
+ +1384 + | ++ + + + + + | + * |
+ +1385 + | ++ + + + + + | + * @return exception's name |
+ +1386 + | ++ + + + + + | + */ |
+ +1387 + | ++ + + + + + | + private Token getName() { |
+ +1388 + | +
+
+1
+
+
+1. getName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::getName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return classInfo.getName(); |
+ +1389 + | ++ + + + + + | + } |
+ +1390 + | ++ + + + + + | +|
+ +1391 + | ++ + + + + + | + } |
+ +1392 + | ++ + + + + + | +|
+ +1393 + | ++ + + + + + | +} |
Mutations | ||
336 | ++ |
+
+
+
+ 1.1 |
+
425 | ++ |
+
+
+
+ 1.1 |
+
434 | ++ |
+
+
+
+ 1.1 |
+
439 | ++ |
+
+
+
+ 1.1 |
+
456 | ++ |
+
+
+
+ 1.1 |
+
457 | ++ |
+
+
+
+ 1.1 |
+
458 | ++ |
+
+
+
+ 1.1 |
+
459 | ++ |
+
+
+
+ 1.1 |
+
462 | ++ |
+
+
+
+ 1.1 |
+
463 | ++ |
+
+
+
+ 1.1 |
+
465 | ++ |
+
+
+
+ 1.1 |
+
471 | ++ |
+
+
+
+ 1.1 |
+
472 | ++ |
+
+
+
+ 1.1 |
+
473 | ++ |
+
+
+
+ 1.1 |
+
479 | ++ |
+
+
+
+ 1.1 |
+
492 | ++ |
+
+
+
+ 1.1 |
+
496 | ++ |
+
+
+
+ 1.1 |
+
497 | ++ |
+
+
+
+ 1.1 |
+
512 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 |
+
515 | ++ |
+
+
+
+ 1.1 |
+
516 | ++ |
+
+
+
+ 1.1 |
+
528 | ++ |
+
+
+
+ 1.1 |
+
529 | ++ |
+
+
+
+ 1.1 |
+
530 | ++ |
+
+
+
+ 1.1 |
+
536 | ++ |
+
+
+
+ 1.1 2.2 |
+
539 | ++ |
+
+
+
+ 1.1 |
+
540 | ++ |
+
+
+
+ 1.1 |
+
542 | ++ |
+
+
+
+ 1.1 |
+
545 | ++ |
+
+
+
+ 1.1 |
+
546 | ++ |
+
+
+
+ 1.1 |
+
547 | ++ |
+
+
+
+ 1.1 |
+
552 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
553 | ++ |
+
+
+
+ 1.1 2.2 |
+
568 | ++ |
+
+
+
+ 1.1 |
+
569 | ++ |
+
+
+
+ 1.1 |
+
571 | ++ |
+
+
+
+ 1.1 |
+
572 | ++ |
+
+
+
+ 1.1 |
+
578 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
592 | ++ |
+
+
+
+ 1.1 |
+
599 | ++ |
+
+
+
+ 1.1 |
+
611 | ++ |
+
+
+
+ 1.1 |
+
612 | ++ |
+
+
+
+ 1.1 |
+
615 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
616 | ++ |
+
+
+
+ 1.1 |
+
628 | ++ |
+
+
+
+ 1.1 |
+
631 | ++ |
+
+
+
+ 1.1 |
+
633 | ++ |
+
+
+
+ 1.1 |
+
638 | ++ |
+
+
+
+ 1.1 |
+
640 | ++ |
+
+
+
+ 1.1 |
+
642 | ++ |
+
+
+
+ 1.1 |
+
644 | ++ |
+
+
+
+ 1.1 |
+
646 | ++ |
+
+
+
+ 1.1 |
+
648 | ++ |
+
+
+
+ 1.1 |
+
652 | ++ |
+
+
+
+ 1.1 |
+
665 | ++ |
+
+
+
+ 1.1 |
+
666 | ++ |
+
+
+
+ 1.1 |
+
667 | ++ |
+
+
+
+ 1.1 |
+
669 | ++ |
+
+
+
+ 1.1 |
+
687 | ++ |
+
+
+
+ 1.1 |
+
689 | ++ |
+
+
+
+ 1.1 |
+
691 | ++ |
+
+
+
+ 1.1 |
+
693 | ++ |
+
+
+
+ 1.1 |
+
694 | ++ |
+
+
+
+ 1.1 |
+
696 | ++ |
+
+
+
+ 1.1 |
+
698 | ++ |
+
+
+
+ 1.1 |
+
701 | ++ |
+
+
+
+ 1.1 |
+
712 | ++ |
+
+
+
+ 1.1 |
+
715 | ++ |
+
+
+
+ 1.1 |
+
716 | ++ |
+
+
+
+ 1.1 |
+
718 | ++ |
+
+
+
+ 1.1 |
+
724 | ++ |
+
+
+
+ 1.1 |
+
734 | ++ |
+
+
+
+ 1.1 |
+
737 | ++ |
+
+
+
+ 1.1 |
+
739 | ++ |
+
+
+
+ 1.1 |
+
740 | ++ |
+
+
+
+ 1.1 |
+
741 | ++ |
+
+
+
+ 1.1 |
+
743 | ++ |
+
+
+
+ 1.1 |
+
744 | ++ |
+
+
+
+ 1.1 |
+
750 | ++ |
+
+
+
+ 1.1 |
+
760 | ++ |
+
+
+
+ 1.1 |
+
762 | ++ |
+
+
+
+ 1.1 |
+
766 | ++ |
+
+
+
+ 1.1 |
+
768 | ++ |
+
+
+
+ 1.1 |
+
770 | ++ |
+
+
+
+ 1.1 |
+
771 | ++ |
+
+
+
+ 1.1 |
+
777 | ++ |
+
+
+
+ 1.1 |
+
790 | ++ |
+
+
+
+ 1.1 |
+
791 | ++ |
+
+
+
+ 1.1 |
+
792 | ++ |
+
+
+
+ 1.1 |
+
793 | ++ |
+
+
+
+ 1.1 |
+
794 | ++ |
+
+
+
+ 1.1 |
+
799 | ++ |
+
+
+
+ 1.1 |
+
800 | ++ |
+
+
+
+ 1.1 |
+
807 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
819 | ++ |
+
+
+
+ 1.1 |
+
821 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
825 | ++ |
+
+
+
+ 1.1 |
+
837 | ++ |
+
+
+
+ 1.1 |
+
839 | ++ |
+
+
+
+ 1.1 |
+
841 | ++ |
+
+
+
+ 1.1 2.2 |
+
844 | ++ |
+
+
+
+ 1.1 |
+
850 | ++ |
+
+
+
+ 1.1 2.2 |
+
854 | ++ |
+
+
+
+ 1.1 |
+
873 | ++ |
+
+
+
+ 1.1 |
+
876 | ++ |
+
+
+
+ 1.1 |
+
880 | ++ |
+
+
+
+ 1.1 |
+
885 | ++ |
+
+
+
+ 1.1 2.2 |
+
887 | ++ |
+
+
+
+ 1.1 |
+
891 | ++ |
+
+
+
+ 1.1 |
+
892 | ++ |
+
+
+
+ 1.1 |
+
899 | ++ |
+
+
+
+ 1.1 2.2 |
+
901 | ++ |
+
+
+
+ 1.1 |
+
906 | ++ |
+
+
+
+ 1.1 |
+
907 | ++ |
+
+
+
+ 1.1 |
+
928 | ++ |
+
+
+
+ 1.1 |
+
931 | ++ |
+
+
+
+ 1.1 |
+
933 | ++ |
+
+
+
+ 1.1 |
+
937 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
950 | ++ |
+
+
+
+ 1.1 |
+
952 | ++ |
+
+
+
+ 1.1 |
+
954 | ++ |
+
+
+
+ 1.1 |
+
958 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
976 | ++ |
+
+
+
+ 1.1 |
+
978 | ++ |
+
+
+
+ 1.1 |
+
979 | ++ |
+
+
+
+ 1.1 |
+
980 | ++ |
+
+
+
+ 1.1 |
+
985 | ++ |
+
+
+
+ 1.1 |
+
991 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
992 | ++ |
+
+
+
+ 1.1 |
+
1008 | ++ |
+
+
+
+ 1.1 |
+
1010 | ++ |
+
+
+
+ 1.1 |
+
1013 | ++ |
+
+
+
+ 1.1 |
+
1016 | ++ |
+
+
+
+ 1.1 |
+
1020 | ++ |
+
+
+
+ 1.1 |
+
1023 | ++ |
+
+
+
+ 1.1 |
+
1027 | ++ |
+
+
+
+ 1.1 2.2 |
+
1028 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
1029 | ++ |
+
+
+
+ 1.1 |
+
1031 | ++ |
+
+
+
+ 1.1 |
+
1051 | ++ |
+
+
+
+ 1.1 |
+
1058 | ++ |
+
+
+
+ 1.1 |
+
1059 | ++ |
+
+
+
+ 1.1 |
+
1072 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
1086 | ++ |
+
+
+
+ 1.1 |
+
1091 | ++ |
+
+
+
+ 1.1 2.2 |
+
1093 | ++ |
+
+
+
+ 1.1 |
+
1095 | ++ |
+
+
+
+ 1.1 |
+
1099 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
1111 | ++ |
+
+
+
+ 1.1 |
+
1112 | ++ |
+
+
+
+ 1.1 |
+
1114 | ++ |
+
+
+
+ 1.1 |
+
1116 | ++ |
+
+
+
+ 1.1 |
+
1118 | ++ |
+
+
+
+ 1.1 |
+
1121 | ++ |
+
+
+
+ 1.1 |
+
1124 | ++ |
+
+
+
+ 1.1 |
+
1144 | ++ |
+
+
+
+ 1.1 |
+
1145 | ++ |
+
+
+
+ 1.1 |
+
1146 | ++ |
+
+
+
+ 1.1 |
+
1160 | ++ |
+
+
+
+ 1.1 |
+
1161 | ++ |
+
+
+
+ 1.1 |
+
1164 | ++ |
+
+
+
+ 1.1 |
+
1166 | ++ |
+
+
+
+ 1.1 |
+
1180 | ++ |
+
+
+
+ 1.1 |
+
1183 | ++ |
+
+
+
+ 1.1 |
+
1187 | ++ |
+
+
+
+ 1.1 |
+
1205 | ++ |
+
+
+
+ 1.1 |
+
1206 | ++ |
+
+
+
+ 1.1 |
+
1218 | ++ |
+
+
+
+ 1.1 |
+
1248 | ++ |
+
+
+
+ 1.1 2.2 |
+
1275 | ++ |
+
+
+
+ 1.1 2.2 |
+
1322 | ++ |
+
+
+
+ 1.1 |
+
1331 | ++ |
+
+
+
+ 1.1 |
+
1340 | ++ |
+
+
+
+ 1.1 |
+
1345 | ++ |
+
+
+
+ 1.1 2.2 |
+
1379 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
1388 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +23 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +/** |
+ +28 + | ++ + + + + + | + * <p> |
+ +29 + | ++ + + + + + | + * Checks that there is at least one whitespace after the leading asterisk. |
+ +30 + | ++ + + + + + | + * Although spaces after asterisks are optional in the Javadoc comments, their absence |
+ +31 + | ++ + + + + + | + * makes the documentation difficult to read. It is the de facto standard to put at least |
+ +32 + | ++ + + + + + | + * one whitespace after the leading asterisk. |
+ +33 + | ++ + + + + + | + * </p> |
+ +34 + | ++ + + + + + | + * <ul> |
+ +35 + | ++ + + + + + | + * <li> |
+ +36 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +37 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +38 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +39 + | ++ + + + + + | + * Default value is {@code false}. |
+ +40 + | ++ + + + + + | + * </li> |
+ +41 + | ++ + + + + + | + * </ul> |
+ +42 + | ++ + + + + + | + * <p> |
+ +43 + | ++ + + + + + | + * To configure the default check: |
+ +44 + | ++ + + + + + | + * </p> |
+ +45 + | ++ + + + + + | + * <pre> |
+ +46 + | ++ + + + + + | + * <module name="JavadocMissingWhitespaceAfterAsterisk"/> |
+ +47 + | ++ + + + + + | + * </pre> |
+ +48 + | ++ + + + + + | + * <p> |
+ +49 + | ++ + + + + + | + * Code Example: |
+ +50 + | ++ + + + + + | + * </p> |
+ +51 + | ++ + + + + + | + * <pre> |
+ +52 + | ++ + + + + + | + * /** This is valid single-line Javadoc. */ |
+ +53 + | ++ + + + + + | + * class TestClass { |
+ +54 + | ++ + + + + + | + * /** |
+ +55 + | ++ + + + + + | + * *This is invalid Javadoc. |
+ +56 + | ++ + + + + + | + * */ |
+ +57 + | ++ + + + + + | + * int invalidJavaDoc; |
+ +58 + | ++ + + + + + | + * /** |
+ +59 + | ++ + + + + + | + * * This is valid Javadoc. |
+ +60 + | ++ + + + + + | + * */ |
+ +61 + | ++ + + + + + | + * void validJavaDocMethod() { |
+ +62 + | ++ + + + + + | + * } |
+ +63 + | ++ + + + + + | + * /**This is invalid single-line Javadoc. */ |
+ +64 + | ++ + + + + + | + * void invalidSingleLineJavaDocMethod() { |
+ +65 + | ++ + + + + + | + * } |
+ +66 + | ++ + + + + + | + * /** This is valid single-line Javadoc. */ |
+ +67 + | ++ + + + + + | + * void validSingleLineJavaDocMethod() { |
+ +68 + | ++ + + + + + | + * } |
+ +69 + | ++ + + + + + | + * } |
+ +70 + | ++ + + + + + | + * </pre> |
+ +71 + | ++ + + + + + | + * |
+ +72 + | ++ + + + + + | + * @since 8.32 |
+ +73 + | ++ + + + + + | + */ |
+ +74 + | ++ + + + + + | +@StatelessCheck |
+ +75 + | ++ + + + + + | +public class JavadocMissingWhitespaceAfterAsteriskCheck extends AbstractJavadocCheck { |
+ +76 + | ++ + + + + + | +|
+ +77 + | ++ + + + + + | + /** |
+ +78 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" file. |
+ +79 + | ++ + + + + + | + */ |
+ +80 + | ++ + + + + + | + public static final String MSG_KEY = "javadoc.missing.whitespace"; |
+ +81 + | ++ + + + + + | +|
+ +82 + | ++ + + + + + | + @Override |
+ +83 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +84 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +85 + | ++ + + + + + | + JavadocTokenTypes.JAVADOC, |
+ +86 + | ++ + + + + + | + JavadocTokenTypes.LEADING_ASTERISK, |
+ +87 + | ++ + + + + + | + }; |
+ +88 + | ++ + + + + + | + } |
+ +89 + | ++ + + + + + | +|
+ +90 + | ++ + + + + + | + @Override |
+ +91 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +92 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +93 + | ++ + + + + + | + } |
+ +94 + | ++ + + + + + | +|
+ +95 + | ++ + + + + + | + @Override |
+ +96 + | ++ + + + + + | + public void visitJavadocToken(DetailNode detailNode) { |
+ +97 + | ++ + + + + + | + final DetailNode textNode; |
+ +98 + | ++ + + + + + | +|
+ +99 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (detailNode.getType() == JavadocTokenTypes.JAVADOC) { |
+ +100 + | ++ + + + + + | + textNode = JavadocUtil.getFirstChild(detailNode); |
+ +101 + | ++ + + + + + | + } |
+ +102 + | ++ + + + + + | + else { |
+ +103 + | ++ + + + + + | + textNode = JavadocUtil.getNextSibling(detailNode); |
+ +104 + | ++ + + + + + | + } |
+ +105 + | ++ + + + + + | +|
+ +106 + | +
+
+2
+
+
+1. visitJavadocToken : negated conditional → KILLED + +2. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (textNode != null && textNode.getType() != JavadocTokenTypes.EOF) { |
+ +107 + | ++ + + + + + | + final String text = textNode.getText(); |
+ +108 + | ++ + + + + + | + final int lastAsteriskPosition = getLastLeadingAsteriskPosition(text); |
+ +109 + | ++ + + + + + | +|
+ +110 + | +
+
+2
+
+
+1. visitJavadocToken : Replaced integer addition with subtraction → KILLED + +2. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!isLast(lastAsteriskPosition, text) |
+ +111 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ && !Character.isWhitespace(text.charAt(lastAsteriskPosition + 1))) { |
+ +112 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheck::log → KILLED + + + + |
+ log(textNode.getLineNumber(), textNode.getColumnNumber(), MSG_KEY); |
+ +113 + | ++ + + + + + | + } |
+ +114 + | ++ + + + + + | + } |
+ +115 + | ++ + + + + + | + } |
+ +116 + | ++ + + + + + | +|
+ +117 + | ++ + + + + + | + /** |
+ +118 + | ++ + + + + + | + * Checks if the character position is the last one of the string. |
+ +119 + | ++ + + + + + | + * |
+ +120 + | ++ + + + + + | + * @param position the position of the character |
+ +121 + | ++ + + + + + | + * @param text String literal. |
+ +122 + | ++ + + + + + | + * @return true if the character position is the last one of the string. |
+ +123 + | ++ + + + + + | + * |
+ +124 + | ++ + + + + + | + */ |
+ +125 + | ++ + + + + + | + private static boolean isLast(int position, String text) { |
+ +126 + | +
+
+4
+
+
+1. isLast : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheck::isLast → KILLED + +2. isLast : Replaced integer subtraction with addition → KILLED + +3. isLast : negated conditional → KILLED + +4. isLast : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return position == text.length() - 1; |
+ +127 + | ++ + + + + + | + } |
+ +128 + | ++ + + + + + | +|
+ +129 + | ++ + + + + + | + /** |
+ +130 + | ++ + + + + + | + * Finds the position of the last leading asterisk in the string. |
+ +131 + | ++ + + + + + | + * If {@code text} contains no leading asterisk, -1 will be returned. |
+ +132 + | ++ + + + + + | + * |
+ +133 + | ++ + + + + + | + * @param text String literal. |
+ +134 + | ++ + + + + + | + * @return the index of the last leading asterisk. |
+ +135 + | ++ + + + + + | + * |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + private static int getLastLeadingAsteriskPosition(String text) { |
+ +138 + | ++ + + + + + | + int index = -1; |
+ +139 + | ++ + + + + + | +|
+ +140 + | +
+
+2
+
+
+1. getLastLeadingAsteriskPosition : changed conditional boundary → KILLED + +2. getLastLeadingAsteriskPosition : negated conditional → KILLED + + + + |
+ for (int i = 0; i < text.length(); i++) { |
+ +141 + | +
+
+1
+
+
+1. getLastLeadingAsteriskPosition : negated conditional → KILLED + + + + |
+ if (text.charAt(i) != '*') { |
+ +142 + | ++ + + + + + | + break; |
+ +143 + | ++ + + + + + | + } |
+ +144 + | +
+
+1
+
+
+1. getLastLeadingAsteriskPosition : Changed increment from 1 to -1 → KILLED + + + + |
+ index++; |
+ +145 + | ++ + + + + + | + } |
+ +146 + | ++ + + + + + | +|
+ +147 + | +
+
+1
+
+
+1. getLastLeadingAsteriskPosition : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return index; |
+ +148 + | ++ + + + + + | + } |
+ +149 + | ++ + + + + + | +|
+ +150 + | ++ + + + + + | +} |
Mutations | ||
84 | ++ |
+
+
+
+ 1.1 |
+
92 | ++ |
+
+
+
+ 1.1 |
+
99 | ++ |
+
+
+
+ 1.1 |
+
106 | ++ |
+
+
+
+ 1.1 2.2 |
+
110 | ++ |
+
+
+
+ 1.1 2.2 |
+
111 | ++ |
+
+
+
+ 1.1 |
+
112 | ++ |
+
+
+
+ 1.1 |
+
126 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
140 | ++ |
+
+
+
+ 1.1 2.2 |
+
141 | ++ |
+
+
+
+ 1.1 |
+
144 | ++ |
+
+
+
+ 1.1 |
+
147 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Objects; |
+ +24 + | ++ + + + + + | +|
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +/** |
+ +29 + | ++ + + + + + | + * Implementation of DetailNode interface that is mutable. |
+ +30 + | ++ + + + + + | + * |
+ +31 + | ++ + + + + + | + * |
+ +32 + | ++ + + + + + | + */ |
+ +33 + | ++ + + + + + | +public class JavadocNodeImpl implements DetailNode { |
+ +34 + | ++ + + + + + | +|
+ +35 + | ++ + + + + + | + /** |
+ +36 + | ++ + + + + + | + * Empty array of {@link DetailNode} type. |
+ +37 + | ++ + + + + + | + */ |
+ +38 + | ++ + + + + + | + public static final JavadocNodeImpl[] EMPTY_DETAIL_NODE_ARRAY = new JavadocNodeImpl[0]; |
+ +39 + | ++ + + + + + | +|
+ +40 + | ++ + + + + + | + /** |
+ +41 + | ++ + + + + + | + * Node index among parent's children. |
+ +42 + | ++ + + + + + | + */ |
+ +43 + | ++ + + + + + | + private int index; |
+ +44 + | ++ + + + + + | +|
+ +45 + | ++ + + + + + | + /** |
+ +46 + | ++ + + + + + | + * Node type. |
+ +47 + | ++ + + + + + | + */ |
+ +48 + | ++ + + + + + | + private int type; |
+ +49 + | ++ + + + + + | +|
+ +50 + | ++ + + + + + | + /** |
+ +51 + | ++ + + + + + | + * Node's text content. |
+ +52 + | ++ + + + + + | + */ |
+ +53 + | ++ + + + + + | + private String text; |
+ +54 + | ++ + + + + + | +|
+ +55 + | ++ + + + + + | + /** |
+ +56 + | ++ + + + + + | + * Line number. |
+ +57 + | ++ + + + + + | + */ |
+ +58 + | ++ + + + + + | + private int lineNumber; |
+ +59 + | ++ + + + + + | +|
+ +60 + | ++ + + + + + | + /** |
+ +61 + | ++ + + + + + | + * Column number. |
+ +62 + | ++ + + + + + | + */ |
+ +63 + | ++ + + + + + | + private int columnNumber; |
+ +64 + | ++ + + + + + | +|
+ +65 + | ++ + + + + + | + /** |
+ +66 + | ++ + + + + + | + * Array of child nodes. |
+ +67 + | ++ + + + + + | + */ |
+ +68 + | ++ + + + + + | + private DetailNode[] children; |
+ +69 + | ++ + + + + + | +|
+ +70 + | ++ + + + + + | + /** |
+ +71 + | ++ + + + + + | + * Parent node. |
+ +72 + | ++ + + + + + | + */ |
+ +73 + | ++ + + + + + | + private DetailNode parent; |
+ +74 + | ++ + + + + + | +|
+ +75 + | ++ + + + + + | + @Override |
+ +76 + | ++ + + + + + | + public int getType() { |
+ +77 + | +
+
+1
+
+
+1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return type; |
+ +78 + | ++ + + + + + | + } |
+ +79 + | ++ + + + + + | +|
+ +80 + | ++ + + + + + | + @Override |
+ +81 + | ++ + + + + + | + public String getText() { |
+ +82 + | +
+
+1
+
+
+1. getText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl::getText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return text; |
+ +83 + | ++ + + + + + | + } |
+ +84 + | ++ + + + + + | +|
+ +85 + | ++ + + + + + | + @Override |
+ +86 + | ++ + + + + + | + public int getLineNumber() { |
+ +87 + | +
+
+1
+
+
+1. getLineNumber : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNumber; |
+ +88 + | ++ + + + + + | + } |
+ +89 + | ++ + + + + + | +|
+ +90 + | ++ + + + + + | + @Override |
+ +91 + | ++ + + + + + | + public int getColumnNumber() { |
+ +92 + | +
+
+1
+
+
+1. getColumnNumber : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return columnNumber; |
+ +93 + | ++ + + + + + | + } |
+ +94 + | ++ + + + + + | +|
+ +95 + | ++ + + + + + | + @Override |
+ +96 + | ++ + + + + + | + public DetailNode[] getChildren() { |
+ +97 + | ++ + + + + + | + DetailNode[] nodeChildren = EMPTY_DETAIL_NODE_ARRAY; |
+ +98 + | +
+
+1
+
+
+1. getChildren : negated conditional → KILLED + + + + |
+ if (children != null) { |
+ +99 + | ++ + + + + + | + nodeChildren = Arrays.copyOf(children, children.length); |
+ +100 + | ++ + + + + + | + } |
+ +101 + | +
+
+1
+
+
+1. getChildren : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl::getChildren to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return nodeChildren; |
+ +102 + | ++ + + + + + | + } |
+ +103 + | ++ + + + + + | +|
+ +104 + | ++ + + + + + | + @Override |
+ +105 + | ++ + + + + + | + public DetailNode getParent() { |
+ +106 + | +
+
+1
+
+
+1. getParent : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl::getParent to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return parent; |
+ +107 + | ++ + + + + + | + } |
+ +108 + | ++ + + + + + | +|
+ +109 + | ++ + + + + + | + @Override |
+ +110 + | ++ + + + + + | + public int getIndex() { |
+ +111 + | +
+
+1
+
+
+1. getIndex : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return index; |
+ +112 + | ++ + + + + + | + } |
+ +113 + | ++ + + + + + | +|
+ +114 + | ++ + + + + + | + /** |
+ +115 + | ++ + + + + + | + * Sets node's type. |
+ +116 + | ++ + + + + + | + * |
+ +117 + | ++ + + + + + | + * @param type Node's type. |
+ +118 + | ++ + + + + + | + */ |
+ +119 + | ++ + + + + + | + public void setType(int type) { |
+ +120 + | ++ + + + + + | + this.type = type; |
+ +121 + | ++ + + + + + | + } |
+ +122 + | ++ + + + + + | +|
+ +123 + | ++ + + + + + | + /** |
+ +124 + | ++ + + + + + | + * Sets node's text content. |
+ +125 + | ++ + + + + + | + * |
+ +126 + | ++ + + + + + | + * @param text Node's text content. |
+ +127 + | ++ + + + + + | + */ |
+ +128 + | ++ + + + + + | + public void setText(String text) { |
+ +129 + | ++ + + + + + | + this.text = text; |
+ +130 + | ++ + + + + + | + } |
+ +131 + | ++ + + + + + | +|
+ +132 + | ++ + + + + + | + /** |
+ +133 + | ++ + + + + + | + * Sets line number. |
+ +134 + | ++ + + + + + | + * |
+ +135 + | ++ + + + + + | + * @param lineNumber Line number. |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + public void setLineNumber(int lineNumber) { |
+ +138 + | ++ + + + + + | + this.lineNumber = lineNumber; |
+ +139 + | ++ + + + + + | + } |
+ +140 + | ++ + + + + + | +|
+ +141 + | ++ + + + + + | + /** |
+ +142 + | ++ + + + + + | + * Sets column number. |
+ +143 + | ++ + + + + + | + * |
+ +144 + | ++ + + + + + | + * @param columnNumber Column number. |
+ +145 + | ++ + + + + + | + */ |
+ +146 + | ++ + + + + + | + public void setColumnNumber(int columnNumber) { |
+ +147 + | ++ + + + + + | + this.columnNumber = columnNumber; |
+ +148 + | ++ + + + + + | + } |
+ +149 + | ++ + + + + + | +|
+ +150 + | ++ + + + + + | + /** |
+ +151 + | ++ + + + + + | + * Sets array of child nodes. |
+ +152 + | ++ + + + + + | + * |
+ +153 + | ++ + + + + + | + * @param children Array of child nodes. |
+ +154 + | ++ + + + + + | + */ |
+ +155 + | ++ + + + + + | + public void setChildren(DetailNode... children) { |
+ +156 + | ++ + + + + + | + this.children = Arrays.copyOf(children, children.length); |
+ +157 + | ++ + + + + + | + } |
+ +158 + | ++ + + + + + | +|
+ +159 + | ++ + + + + + | + /** |
+ +160 + | ++ + + + + + | + * Sets parent node. |
+ +161 + | ++ + + + + + | + * |
+ +162 + | ++ + + + + + | + * @param parent Parent node. |
+ +163 + | ++ + + + + + | + */ |
+ +164 + | ++ + + + + + | + public void setParent(DetailNode parent) { |
+ +165 + | ++ + + + + + | + this.parent = parent; |
+ +166 + | ++ + + + + + | + } |
+ +167 + | ++ + + + + + | +|
+ +168 + | ++ + + + + + | + /** |
+ +169 + | ++ + + + + + | + * Sets node's index among parent's children. |
+ +170 + | ++ + + + + + | + * |
+ +171 + | ++ + + + + + | + * @param index Node's index among parent's children. |
+ +172 + | ++ + + + + + | + */ |
+ +173 + | ++ + + + + + | + public void setIndex(int index) { |
+ +174 + | ++ + + + + + | + this.index = index; |
+ +175 + | ++ + + + + + | + } |
+ +176 + | ++ + + + + + | +|
+ +177 + | ++ + + + + + | + @Override |
+ +178 + | ++ + + + + + | + public String toString() { |
+ +179 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImpl::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "JavadocNodeImpl[" |
+ +180 + | ++ + + + + + | + + "index=" + index |
+ +181 + | ++ + + + + + | + + ", type=" + JavadocUtil.getTokenName(type) |
+ +182 + | ++ + + + + + | + + ", text='" + text + '\'' |
+ +183 + | ++ + + + + + | + + ", lineNumber=" + lineNumber |
+ +184 + | ++ + + + + + | + + ", columnNumber=" + columnNumber |
+ +185 + | ++ + + + + + | + + ", children=" + Objects.hashCode(children) |
+ +186 + | ++ + + + + + | + + ", parent=" + parent + ']'; |
+ +187 + | ++ + + + + + | + } |
+ +188 + | ++ + + + + + | +|
+ +189 + | ++ + + + + + | +} |
Mutations | ||
77 | ++ |
+
+
+
+ 1.1 |
+
82 | ++ |
+
+
+
+ 1.1 |
+
87 | ++ |
+
+
+
+ 1.1 |
+
92 | ++ |
+
+
+
+ 1.1 |
+
98 | ++ |
+
+
+
+ 1.1 |
+
101 | ++ |
+
+
+
+ 1.1 |
+
106 | ++ |
+
+
+
+ 1.1 |
+
111 | ++ |
+
+
+
+ 1.1 |
+
179 | ++ |
+
+
+
+ 1.1 2.2 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.io.File; |
+ +23 + | ++ + + + + + | +import java.io.IOException; |
+ +24 + | ++ + + + + + | +import java.util.Set; |
+ +25 + | ++ + + + + + | +import java.util.concurrent.ConcurrentHashMap; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.GlobalStatefulCheck; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.CheckstyleException; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileText; |
+ +31 + | ++ + + + + + | +|
+ +32 + | ++ + + + + + | +/** |
+ +33 + | ++ + + + + + | + * <p> |
+ +34 + | ++ + + + + + | + * Checks that each Java package has a Javadoc file used for commenting. |
+ +35 + | ++ + + + + + | + * By default it only allows a {@code package-info.java} file, |
+ +36 + | ++ + + + + + | + * but can be configured to allow a {@code package.html} file. |
+ +37 + | ++ + + + + + | + * </p> |
+ +38 + | ++ + + + + + | + * <p> |
+ +39 + | ++ + + + + + | + * A violation will be reported if both files exist as this is not allowed by the Javadoc tool. |
+ +40 + | ++ + + + + + | + * </p> |
+ +41 + | ++ + + + + + | + * <ul> |
+ +42 + | ++ + + + + + | + * <li> |
+ +43 + | ++ + + + + + | + * Property {@code allowLegacy} - Allow legacy {@code package.html} file to be used. |
+ +44 + | ++ + + + + + | + * Default value is {@code false}. |
+ +45 + | ++ + + + + + | + * </li> |
+ +46 + | ++ + + + + + | + * <li> |
+ +47 + | ++ + + + + + | + * Property {@code fileExtensions} - Specify the file type extension of files to process. |
+ +48 + | ++ + + + + + | + * Default value is {@code .java}. |
+ +49 + | ++ + + + + + | + * </li> |
+ +50 + | ++ + + + + + | + * </ul> |
+ +51 + | ++ + + + + + | + * <p> |
+ +52 + | ++ + + + + + | + * To configure the check: |
+ +53 + | ++ + + + + + | + * </p> |
+ +54 + | ++ + + + + + | + * <pre> |
+ +55 + | ++ + + + + + | + * <module name="JavadocPackage"/> |
+ +56 + | ++ + + + + + | + * </pre> |
+ +57 + | ++ + + + + + | + * <p> |
+ +58 + | ++ + + + + + | + * To configure the check to use legacy {@code package.html} file |
+ +59 + | ++ + + + + + | + * when {@code package-info.java} file is absent: |
+ +60 + | ++ + + + + + | + * </p> |
+ +61 + | ++ + + + + + | + * <pre> |
+ +62 + | ++ + + + + + | + * <module name="JavadocPackage"> |
+ +63 + | ++ + + + + + | + * <property name="allowLegacy" value="true"/> |
+ +64 + | ++ + + + + + | + * </module> |
+ +65 + | ++ + + + + + | + * </pre> |
+ +66 + | ++ + + + + + | + * |
+ +67 + | ++ + + + + + | + * @since 5.0 |
+ +68 + | ++ + + + + + | + */ |
+ +69 + | ++ + + + + + | +@GlobalStatefulCheck |
+ +70 + | ++ + + + + + | +public class JavadocPackageCheck extends AbstractFileSetCheck { |
+ +71 + | ++ + + + + + | +|
+ +72 + | ++ + + + + + | + /** |
+ +73 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +74 + | ++ + + + + + | + * file. |
+ +75 + | ++ + + + + + | + */ |
+ +76 + | ++ + + + + + | + public static final String MSG_LEGACY_PACKAGE_HTML = "javadoc.legacyPackageHtml"; |
+ +77 + | ++ + + + + + | +|
+ +78 + | ++ + + + + + | + /** |
+ +79 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +80 + | ++ + + + + + | + * file. |
+ +81 + | ++ + + + + + | + */ |
+ +82 + | ++ + + + + + | + public static final String MSG_PACKAGE_INFO = "javadoc.packageInfo"; |
+ +83 + | ++ + + + + + | +|
+ +84 + | ++ + + + + + | + /** The directories checked. */ |
+ +85 + | ++ + + + + + | + private final Set<File> directoriesChecked = ConcurrentHashMap.newKeySet(); |
+ +86 + | ++ + + + + + | +|
+ +87 + | ++ + + + + + | + /** Allow legacy {@code package.html} file to be used. */ |
+ +88 + | ++ + + + + + | + private boolean allowLegacy; |
+ +89 + | ++ + + + + + | +|
+ +90 + | ++ + + + + + | + /** |
+ +91 + | ++ + + + + + | + * Creates a new instance. |
+ +92 + | ++ + + + + + | + */ |
+ +93 + | ++ + + + + + | + public JavadocPackageCheck() { |
+ +94 + | ++ + + + + + | + // java, not html! |
+ +95 + | ++ + + + + + | + // The rule is: Every JAVA file should have a package.html sibling |
+ +96 + | +
+
+1
+
+
+1. + + |
+ setFileExtensions("java"); |
+ +97 + | ++ + + + + + | + } |
+ +98 + | ++ + + + + + | +|
+ +99 + | ++ + + + + + | + @Override |
+ +100 + | ++ + + + + + | + protected void processFiltered(File file, FileText fileText) throws CheckstyleException { |
+ +101 + | ++ + + + + + | + // Check if already processed directory |
+ +102 + | ++ + + + + + | + final File dir; |
+ +103 + | ++ + + + + + | + try { |
+ +104 + | ++ + + + + + | + dir = file.getCanonicalFile().getParentFile(); |
+ +105 + | ++ + + + + + | + } |
+ +106 + | ++ + + + + + | + catch (IOException ex) { |
+ +107 + | +
+
+1
+
+
+1. processFiltered : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ throw new CheckstyleException( |
+ +108 + | +
+
+1
+
+
+1. processFiltered : removed call to com/puppycrawl/tools/checkstyle/api/CheckstyleException::<init> → KILLED + + + + |
+ "Exception while getting canonical path to file " + file.getPath(), ex); |
+ +109 + | ++ + + + + + | + } |
+ +110 + | +
+
+1
+
+
+1. processFiltered : negated conditional → KILLED + + + + |
+ final boolean isDirChecked = !directoriesChecked.add(dir); |
+ +111 + | +
+
+1
+
+
+1. processFiltered : negated conditional → KILLED + + + + |
+ if (!isDirChecked) { |
+ +112 + | ++ + + + + + | + // Check for the preferred file. |
+ +113 + | +
+
+1
+
+
+1. processFiltered : removed call to java/io/File::<init> → KILLED + + + + |
+ final File packageInfo = new File(dir, "package-info.java"); |
+ +114 + | +
+
+1
+
+
+1. processFiltered : removed call to java/io/File::<init> → KILLED + + + + |
+ final File packageHtml = new File(dir, "package.html"); |
+ +115 + | ++ + + + + + | +|
+ +116 + | +
+
+1
+
+
+1. processFiltered : negated conditional → KILLED + + + + |
+ if (packageInfo.exists()) { |
+ +117 + | +
+
+1
+
+
+1. processFiltered : negated conditional → KILLED + + + + |
+ if (packageHtml.exists()) { |
+ +118 + | +
+
+1
+
+
+1. processFiltered : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheck::log → KILLED + + + + |
+ log(1, MSG_LEGACY_PACKAGE_HTML); |
+ +119 + | ++ + + + + + | + } |
+ +120 + | ++ + + + + + | + } |
+ +121 + | +
+
+2
+
+
+1. processFiltered : negated conditional → KILLED + +2. processFiltered : negated conditional → KILLED + + + + |
+ else if (!allowLegacy || !packageHtml.exists()) { |
+ +122 + | +
+
+1
+
+
+1. processFiltered : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheck::log → KILLED + + + + |
+ log(1, MSG_PACKAGE_INFO); |
+ +123 + | ++ + + + + + | + } |
+ +124 + | ++ + + + + + | + } |
+ +125 + | ++ + + + + + | + } |
+ +126 + | ++ + + + + + | +|
+ +127 + | ++ + + + + + | + /** |
+ +128 + | ++ + + + + + | + * Setter to allow legacy {@code package.html} file to be used. |
+ +129 + | ++ + + + + + | + * |
+ +130 + | ++ + + + + + | + * @param allowLegacy whether to allow support. |
+ +131 + | ++ + + + + + | + */ |
+ +132 + | ++ + + + + + | + public void setAllowLegacy(boolean allowLegacy) { |
+ +133 + | ++ + + + + + | + this.allowLegacy = allowLegacy; |
+ +134 + | ++ + + + + + | + } |
+ +135 + | ++ + + + + + | +|
+ +136 + | ++ + + + + + | +} |
Mutations | ||
96 | ++ |
+
+
+
+ 1.1 |
+
107 | ++ |
+
+
+
+ 1.1 |
+
108 | ++ |
+
+
+
+ 1.1 |
+
110 | ++ |
+
+
+
+ 1.1 |
+
111 | ++ |
+
+
+
+ 1.1 |
+
113 | ++ |
+
+
+
+ 1.1 |
+
114 | ++ |
+
+
+
+ 1.1 |
+
116 | ++ |
+
+
+
+ 1.1 |
+
117 | ++ |
+
+
+
+ 1.1 |
+
118 | ++ |
+
+
+
+ 1.1 |
+
121 | ++ |
+
+
+
+ 1.1 2.2 |
+
122 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +23 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +/** |
+ +29 + | ++ + + + + + | + * <p> |
+ +30 + | ++ + + + + + | + * Checks the Javadoc paragraph. |
+ +31 + | ++ + + + + + | + * </p> |
+ +32 + | ++ + + + + + | + * <p> |
+ +33 + | ++ + + + + + | + * Checks that: |
+ +34 + | ++ + + + + + | + * </p> |
+ +35 + | ++ + + + + + | + * <ul> |
+ +36 + | ++ + + + + + | + * <li>There is one blank line between each of two paragraphs |
+ +37 + | ++ + + + + + | + * and one blank line before the at-clauses block if it is present.</li> |
+ +38 + | ++ + + + + + | + * <li>Each paragraph but the first has <p> immediately |
+ +39 + | ++ + + + + + | + * before the first word, with no space after.</li> |
+ +40 + | ++ + + + + + | + * </ul> |
+ +41 + | ++ + + + + + | + * <ul> |
+ +42 + | ++ + + + + + | + * <li> |
+ +43 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +44 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +45 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules"> |
+ +46 + | ++ + + + + + | + * Tight-HTML Rules</a>. |
+ +47 + | ++ + + + + + | + * Default value is {@code false}. |
+ +48 + | ++ + + + + + | + * </li> |
+ +49 + | ++ + + + + + | + * <li> |
+ +50 + | ++ + + + + + | + * Property {@code allowNewlineParagraph} - Control whether the <p> tag |
+ +51 + | ++ + + + + + | + * should be placed immediately before the first word. |
+ +52 + | ++ + + + + + | + * Default value is {@code true}. |
+ +53 + | ++ + + + + + | + * </li> |
+ +54 + | ++ + + + + + | + * </ul> |
+ +55 + | ++ + + + + + | + * <p> |
+ +56 + | ++ + + + + + | + * To configure the default check: |
+ +57 + | ++ + + + + + | + * </p> |
+ +58 + | ++ + + + + + | + * <pre> |
+ +59 + | ++ + + + + + | + * <module name="JavadocParagraph"/> |
+ +60 + | ++ + + + + + | + * </pre> |
+ +61 + | ++ + + + + + | + * <p> |
+ +62 + | ++ + + + + + | + * By default, the check will report a violation if there is a new line |
+ +63 + | ++ + + + + + | + * or whitespace after the <p> tag: |
+ +64 + | ++ + + + + + | + * </p> |
+ +65 + | ++ + + + + + | + * <pre> |
+ +66 + | ++ + + + + + | + * /** |
+ +67 + | ++ + + + + + | + * * No tag (ok). |
+ +68 + | ++ + + + + + | + * * |
+ +69 + | ++ + + + + + | + * * <p>Tag immediately before the text (ok). |
+ +70 + | ++ + + + + + | + * * <p>No blank line before the tag (violation). |
+ +71 + | ++ + + + + + | + * * |
+ +72 + | ++ + + + + + | + * * <p> |
+ +73 + | ++ + + + + + | + * * New line after tag (violation). |
+ +74 + | ++ + + + + + | + * * |
+ +75 + | ++ + + + + + | + * * <p> Whitespace after tag (violation). |
+ +76 + | ++ + + + + + | + * * |
+ +77 + | ++ + + + + + | + * */ |
+ +78 + | ++ + + + + + | + * public class TestClass { |
+ +79 + | ++ + + + + + | + * } |
+ +80 + | ++ + + + + + | + * </pre> |
+ +81 + | ++ + + + + + | + * <p> |
+ +82 + | ++ + + + + + | + * To allow newlines and spaces immediately after the <p> tag: |
+ +83 + | ++ + + + + + | + * </p> |
+ +84 + | ++ + + + + + | + * <pre> |
+ +85 + | ++ + + + + + | + * <module name="JavadocParagraph"> |
+ +86 + | ++ + + + + + | + * <property name="allowNewlineParagraph" value="false"/> |
+ +87 + | ++ + + + + + | + * </module> |
+ +88 + | ++ + + + + + | + * </pre> |
+ +89 + | ++ + + + + + | + * <p> |
+ +90 + | ++ + + + + + | + * In case of {@code allowNewlineParagraph} set to {@code false} |
+ +91 + | ++ + + + + + | + * the following example will not have any violations: |
+ +92 + | ++ + + + + + | + * </p> |
+ +93 + | ++ + + + + + | + * <pre> |
+ +94 + | ++ + + + + + | + * /** |
+ +95 + | ++ + + + + + | + * * No tag (ok). |
+ +96 + | ++ + + + + + | + * * |
+ +97 + | ++ + + + + + | + * * <p>Tag immediately before the text (ok). |
+ +98 + | ++ + + + + + | + * * <p>No blank line before the tag (violation). |
+ +99 + | ++ + + + + + | + * * |
+ +100 + | ++ + + + + + | + * * <p> |
+ +101 + | ++ + + + + + | + * * New line after tag (ok). |
+ +102 + | ++ + + + + + | + * * |
+ +103 + | ++ + + + + + | + * * <p> Whitespace after tag (ok). |
+ +104 + | ++ + + + + + | + * * |
+ +105 + | ++ + + + + + | + * */ |
+ +106 + | ++ + + + + + | + * public class TestClass { |
+ +107 + | ++ + + + + + | + * } |
+ +108 + | ++ + + + + + | + * </pre> |
+ +109 + | ++ + + + + + | + * |
+ +110 + | ++ + + + + + | + * @since 6.0 |
+ +111 + | ++ + + + + + | + */ |
+ +112 + | ++ + + + + + | +@StatelessCheck |
+ +113 + | ++ + + + + + | +public class JavadocParagraphCheck extends AbstractJavadocCheck { |
+ +114 + | ++ + + + + + | +|
+ +115 + | ++ + + + + + | + /** |
+ +116 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +117 + | ++ + + + + + | + * file. |
+ +118 + | ++ + + + + + | + */ |
+ +119 + | ++ + + + + + | + public static final String MSG_TAG_AFTER = "javadoc.paragraph.tag.after"; |
+ +120 + | ++ + + + + + | +|
+ +121 + | ++ + + + + + | + /** |
+ +122 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +123 + | ++ + + + + + | + * file. |
+ +124 + | ++ + + + + + | + */ |
+ +125 + | ++ + + + + + | + public static final String MSG_LINE_BEFORE = "javadoc.paragraph.line.before"; |
+ +126 + | ++ + + + + + | +|
+ +127 + | ++ + + + + + | + /** |
+ +128 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +129 + | ++ + + + + + | + * file. |
+ +130 + | ++ + + + + + | + */ |
+ +131 + | ++ + + + + + | + public static final String MSG_REDUNDANT_PARAGRAPH = "javadoc.paragraph.redundant.paragraph"; |
+ +132 + | ++ + + + + + | +|
+ +133 + | ++ + + + + + | + /** |
+ +134 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +135 + | ++ + + + + + | + * file. |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + public static final String MSG_MISPLACED_TAG = "javadoc.paragraph.misplaced.tag"; |
+ +138 + | ++ + + + + + | +|
+ +139 + | ++ + + + + + | + /** |
+ +140 + | ++ + + + + + | + * Control whether the <p> tag should be placed immediately before the first word. |
+ +141 + | ++ + + + + + | + */ |
+ +142 + | ++ + + + + + | + private boolean allowNewlineParagraph = true; |
+ +143 + | ++ + + + + + | +|
+ +144 + | ++ + + + + + | + /** |
+ +145 + | ++ + + + + + | + * Setter to control whether the <p> tag should be placed |
+ +146 + | ++ + + + + + | + * immediately before the first word. |
+ +147 + | ++ + + + + + | + * |
+ +148 + | ++ + + + + + | + * @param value value to set. |
+ +149 + | ++ + + + + + | + */ |
+ +150 + | ++ + + + + + | + public void setAllowNewlineParagraph(boolean value) { |
+ +151 + | ++ + + + + + | + allowNewlineParagraph = value; |
+ +152 + | ++ + + + + + | + } |
+ +153 + | ++ + + + + + | +|
+ +154 + | ++ + + + + + | + @Override |
+ +155 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +156 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +157 + | ++ + + + + + | + JavadocTokenTypes.NEWLINE, |
+ +158 + | ++ + + + + + | + JavadocTokenTypes.HTML_ELEMENT, |
+ +159 + | ++ + + + + + | + }; |
+ +160 + | ++ + + + + + | + } |
+ +161 + | ++ + + + + + | +|
+ +162 + | ++ + + + + + | + @Override |
+ +163 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +164 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +165 + | ++ + + + + + | + } |
+ +166 + | ++ + + + + + | +|
+ +167 + | ++ + + + + + | + @Override |
+ +168 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +169 + | +
+
+2
+
+
+1. visitJavadocToken : negated conditional → KILLED + +2. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (ast.getType() == JavadocTokenTypes.NEWLINE && isEmptyLine(ast)) { |
+ +170 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::checkEmptyLine → KILLED + + + + |
+ checkEmptyLine(ast); |
+ +171 + | ++ + + + + + | + } |
+ +172 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ else if (ast.getType() == JavadocTokenTypes.HTML_ELEMENT |
+ +173 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ && JavadocUtil.getFirstChild(ast).getType() == JavadocTokenTypes.P_TAG_START) { |
+ +174 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::checkParagraphTag → KILLED + + + + |
+ checkParagraphTag(ast); |
+ +175 + | ++ + + + + + | + } |
+ +176 + | ++ + + + + + | + } |
+ +177 + | ++ + + + + + | +|
+ +178 + | ++ + + + + + | + /** |
+ +179 + | ++ + + + + + | + * Determines whether or not the next line after empty line has paragraph tag in the beginning. |
+ +180 + | ++ + + + + + | + * @param newline NEWLINE node. |
+ +181 + | ++ + + + + + | + */ |
+ +182 + | ++ + + + + + | + private void checkEmptyLine(DetailNode newline) { |
+ +183 + | ++ + + + + + | + final DetailNode nearestToken = getNearestNode(newline); |
+ +184 + | +
+
+1
+
+
+1. checkEmptyLine : negated conditional → KILLED + + + + |
+ if (nearestToken.getType() == JavadocTokenTypes.TEXT |
+ +185 + | +
+
+1
+
+
+1. checkEmptyLine : negated conditional → KILLED + + + + |
+ && !CommonUtil.isBlank(nearestToken.getText())) { |
+ +186 + | +
+
+1
+
+
+1. checkEmptyLine : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::log → KILLED + + + + |
+ log(newline.getLineNumber(), MSG_TAG_AFTER); |
+ +187 + | ++ + + + + + | + } |
+ +188 + | ++ + + + + + | + } |
+ +189 + | ++ + + + + + | +|
+ +190 + | ++ + + + + + | + /** |
+ +191 + | ++ + + + + + | + * Determines whether or not the line with paragraph tag has previous empty line. |
+ +192 + | ++ + + + + + | + * @param tag html tag. |
+ +193 + | ++ + + + + + | + */ |
+ +194 + | ++ + + + + + | + private void checkParagraphTag(DetailNode tag) { |
+ +195 + | ++ + + + + + | + final DetailNode newLine = getNearestEmptyLine(tag); |
+ +196 + | +
+
+1
+
+
+1. checkParagraphTag : negated conditional → KILLED + + + + |
+ if (isFirstParagraph(tag)) { |
+ +197 + | +
+
+1
+
+
+1. checkParagraphTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::log → KILLED + + + + |
+ log(tag.getLineNumber(), MSG_REDUNDANT_PARAGRAPH); |
+ +198 + | ++ + + + + + | + } |
+ +199 + | +
+
+3
+
+
+1. checkParagraphTag : Replaced integer subtraction with addition → KILLED + +2. checkParagraphTag : negated conditional → KILLED + +3. checkParagraphTag : negated conditional → KILLED + + + + |
+ else if (newLine == null || tag.getLineNumber() - newLine.getLineNumber() != 1) { |
+ +200 + | +
+
+1
+
+
+1. checkParagraphTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::log → KILLED + + + + |
+ log(tag.getLineNumber(), MSG_LINE_BEFORE); |
+ +201 + | ++ + + + + + | + } |
+ +202 + | +
+
+2
+
+
+1. checkParagraphTag : negated conditional → KILLED + +2. checkParagraphTag : negated conditional → KILLED + + + + |
+ if (allowNewlineParagraph && isImmediatelyFollowedByText(tag)) { |
+ +203 + | +
+
+1
+
+
+1. checkParagraphTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::log → KILLED + + + + |
+ log(tag.getLineNumber(), MSG_MISPLACED_TAG); |
+ +204 + | ++ + + + + + | + } |
+ +205 + | ++ + + + + + | + } |
+ +206 + | ++ + + + + + | +|
+ +207 + | ++ + + + + + | + /** |
+ +208 + | ++ + + + + + | + * Returns nearest node. |
+ +209 + | ++ + + + + + | + * @param node DetailNode node. |
+ +210 + | ++ + + + + + | + * @return nearest node. |
+ +211 + | ++ + + + + + | + */ |
+ +212 + | ++ + + + + + | + private static DetailNode getNearestNode(DetailNode node) { |
+ +213 + | ++ + + + + + | + DetailNode tag = JavadocUtil.getNextSibling(node); |
+ +214 + | +
+
+1
+
+
+1. getNearestNode : negated conditional → KILLED + + + + |
+ while (tag.getType() == JavadocTokenTypes.LEADING_ASTERISK |
+ +215 + | +
+
+1
+
+
+1. getNearestNode : negated conditional → KILLED + + + + |
+ || tag.getType() == JavadocTokenTypes.NEWLINE) { |
+ +216 + | ++ + + + + + | + tag = JavadocUtil.getNextSibling(tag); |
+ +217 + | ++ + + + + + | + } |
+ +218 + | +
+
+1
+
+
+1. getNearestNode : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::getNearestNode to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tag; |
+ +219 + | ++ + + + + + | + } |
+ +220 + | ++ + + + + + | +|
+ +221 + | ++ + + + + + | + /** |
+ +222 + | ++ + + + + + | + * Determines whether or not the line is empty line. |
+ +223 + | ++ + + + + + | + * @param newLine NEWLINE node. |
+ +224 + | ++ + + + + + | + * @return true, if line is empty line. |
+ +225 + | ++ + + + + + | + */ |
+ +226 + | ++ + + + + + | + private static boolean isEmptyLine(DetailNode newLine) { |
+ +227 + | ++ + + + + + | + boolean result = false; |
+ +228 + | ++ + + + + + | + DetailNode previousSibling = JavadocUtil.getPreviousSibling(newLine); |
+ +229 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ if (previousSibling != null |
+ +230 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ && previousSibling.getParent().getType() == JavadocTokenTypes.JAVADOC) { |
+ +231 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ if (previousSibling.getType() == JavadocTokenTypes.TEXT |
+ +232 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ && CommonUtil.isBlank(previousSibling.getText())) { |
+ +233 + | ++ + + + + + | + previousSibling = JavadocUtil.getPreviousSibling(previousSibling); |
+ +234 + | ++ + + + + + | + } |
+ +235 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ result = previousSibling != null |
+ +236 + | +
+
+1
+
+
+1. isEmptyLine : negated conditional → KILLED + + + + |
+ && previousSibling.getType() == JavadocTokenTypes.LEADING_ASTERISK; |
+ +237 + | ++ + + + + + | + } |
+ +238 + | +
+
+3
+
+
+1. isEmptyLine : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::isEmptyLine → KILLED + +2. isEmptyLine : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::isEmptyLine → KILLED + +3. isEmptyLine : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +239 + | ++ + + + + + | + } |
+ +240 + | ++ + + + + + | +|
+ +241 + | ++ + + + + + | + /** |
+ +242 + | ++ + + + + + | + * Determines whether or not the line with paragraph tag is first line in javadoc. |
+ +243 + | ++ + + + + + | + * @param paragraphTag paragraph tag. |
+ +244 + | ++ + + + + + | + * @return true, if line with paragraph tag is first line in javadoc. |
+ +245 + | ++ + + + + + | + */ |
+ +246 + | ++ + + + + + | + private static boolean isFirstParagraph(DetailNode paragraphTag) { |
+ +247 + | ++ + + + + + | + boolean result = true; |
+ +248 + | ++ + + + + + | + DetailNode previousNode = JavadocUtil.getPreviousSibling(paragraphTag); |
+ +249 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ while (previousNode != null) { |
+ +250 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ if (previousNode.getType() == JavadocTokenTypes.TEXT |
+ +251 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ && !CommonUtil.isBlank(previousNode.getText()) |
+ +252 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ || previousNode.getType() != JavadocTokenTypes.LEADING_ASTERISK |
+ +253 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ && previousNode.getType() != JavadocTokenTypes.NEWLINE |
+ +254 + | +
+
+1
+
+
+1. isFirstParagraph : negated conditional → KILLED + + + + |
+ && previousNode.getType() != JavadocTokenTypes.TEXT) { |
+ +255 + | ++ + + + + + | + result = false; |
+ +256 + | ++ + + + + + | + break; |
+ +257 + | ++ + + + + + | + } |
+ +258 + | ++ + + + + + | + previousNode = JavadocUtil.getPreviousSibling(previousNode); |
+ +259 + | ++ + + + + + | + } |
+ +260 + | +
+
+3
+
+
+1. isFirstParagraph : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::isFirstParagraph → KILLED + +2. isFirstParagraph : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::isFirstParagraph → KILLED + +3. isFirstParagraph : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +261 + | ++ + + + + + | + } |
+ +262 + | ++ + + + + + | +|
+ +263 + | ++ + + + + + | + /** |
+ +264 + | ++ + + + + + | + * Finds and returns nearest empty line in javadoc. |
+ +265 + | ++ + + + + + | + * @param node DetailNode node. |
+ +266 + | ++ + + + + + | + * @return Some nearest empty line in javadoc. |
+ +267 + | ++ + + + + + | + */ |
+ +268 + | ++ + + + + + | + private static DetailNode getNearestEmptyLine(DetailNode node) { |
+ +269 + | ++ + + + + + | + DetailNode newLine = JavadocUtil.getPreviousSibling(node); |
+ +270 + | +
+
+1
+
+
+1. getNearestEmptyLine : negated conditional → KILLED + + + + |
+ while (newLine != null) { |
+ +271 + | ++ + + + + + | + final DetailNode previousSibling = JavadocUtil.getPreviousSibling(newLine); |
+ +272 + | +
+
+2
+
+
+1. getNearestEmptyLine : negated conditional → KILLED + +2. getNearestEmptyLine : negated conditional → KILLED + + + + |
+ if (newLine.getType() == JavadocTokenTypes.NEWLINE && isEmptyLine(newLine)) { |
+ +273 + | ++ + + + + + | + break; |
+ +274 + | ++ + + + + + | + } |
+ +275 + | ++ + + + + + | + newLine = previousSibling; |
+ +276 + | ++ + + + + + | + } |
+ +277 + | +
+
+1
+
+
+1. getNearestEmptyLine : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::getNearestEmptyLine to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return newLine; |
+ +278 + | ++ + + + + + | + } |
+ +279 + | ++ + + + + + | +|
+ +280 + | ++ + + + + + | + /** |
+ +281 + | ++ + + + + + | + * Tests whether the paragraph tag is immediately followed by the text. |
+ +282 + | ++ + + + + + | + * @param tag html tag. |
+ +283 + | ++ + + + + + | + * @return true, if the paragraph tag is immediately followed by the text. |
+ +284 + | ++ + + + + + | + */ |
+ +285 + | ++ + + + + + | + private static boolean isImmediatelyFollowedByText(DetailNode tag) { |
+ +286 + | ++ + + + + + | + final DetailNode nextSibling = JavadocUtil.getNextSibling(tag); |
+ +287 + | +
+
+3
+
+
+1. isImmediatelyFollowedByText : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheck::isImmediatelyFollowedByText → KILLED + +2. isImmediatelyFollowedByText : negated conditional → KILLED + +3. isImmediatelyFollowedByText : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return nextSibling.getType() == JavadocTokenTypes.NEWLINE |
+ +288 + | +
+
+1
+
+
+1. isImmediatelyFollowedByText : negated conditional → KILLED + + + + |
+ || nextSibling.getType() == JavadocTokenTypes.EOF |
+ +289 + | +
+
+1
+
+
+1. isImmediatelyFollowedByText : negated conditional → KILLED + + + + |
+ || CommonUtil.startsWithChar(nextSibling.getText(), ' '); |
+ +290 + | ++ + + + + + | + } |
+ +291 + | ++ + + + + + | +|
+ +292 + | ++ + + + + + | +} |
Mutations | ||
156 | ++ |
+
+
+
+ 1.1 |
+
164 | ++ |
+
+
+
+ 1.1 |
+
169 | ++ |
+
+
+
+ 1.1 2.2 |
+
170 | ++ |
+
+
+
+ 1.1 |
+
172 | ++ |
+
+
+
+ 1.1 |
+
173 | ++ |
+
+
+
+ 1.1 |
+
174 | ++ |
+
+
+
+ 1.1 |
+
184 | ++ |
+
+
+
+ 1.1 |
+
185 | ++ |
+
+
+
+ 1.1 |
+
186 | ++ |
+
+
+
+ 1.1 |
+
196 | ++ |
+
+
+
+ 1.1 |
+
197 | ++ |
+
+
+
+ 1.1 |
+
199 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
200 | ++ |
+
+
+
+ 1.1 |
+
202 | ++ |
+
+
+
+ 1.1 2.2 |
+
203 | ++ |
+
+
+
+ 1.1 |
+
214 | ++ |
+
+
+
+ 1.1 |
+
215 | ++ |
+
+
+
+ 1.1 |
+
218 | ++ |
+
+
+
+ 1.1 |
+
229 | ++ |
+
+
+
+ 1.1 |
+
230 | ++ |
+
+
+
+ 1.1 |
+
231 | ++ |
+
+
+
+ 1.1 |
+
232 | ++ |
+
+
+
+ 1.1 |
+
235 | ++ |
+
+
+
+ 1.1 |
+
236 | ++ |
+
+
+
+ 1.1 |
+
238 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
249 | ++ |
+
+
+
+ 1.1 |
+
250 | ++ |
+
+
+
+ 1.1 |
+
251 | ++ |
+
+
+
+ 1.1 |
+
252 | ++ |
+
+
+
+ 1.1 |
+
253 | ++ |
+
+
+
+ 1.1 |
+
254 | ++ |
+
+
+
+ 1.1 |
+
260 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
270 | ++ |
+
+
+
+ 1.1 |
+
272 | ++ |
+
+
+
+ 1.1 2.2 |
+
277 | ++ |
+
+
+
+ 1.1 |
+
287 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
288 | ++ |
+
+
+
+ 1.1 |
+
289 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayDeque; |
+ +23 + | ++ + + + + + | +import java.util.Arrays; |
+ +24 + | ++ + + + + + | +import java.util.Collections; |
+ +25 + | ++ + + + + + | +import java.util.Deque; |
+ +26 + | ++ + + + + + | +import java.util.List; |
+ +27 + | ++ + + + + + | +import java.util.Locale; |
+ +28 + | ++ + + + + + | +import java.util.Set; |
+ +29 + | ++ + + + + + | +import java.util.TreeSet; |
+ +30 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +31 + | ++ + + + + + | +import java.util.stream.Collectors; |
+ +32 + | ++ + + + + + | +|
+ +33 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser; |
+ +34 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +35 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +36 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +37 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +38 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +39 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +40 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +41 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CheckUtil; |
+ +42 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +43 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +44 + | ++ + + + + + | +|
+ +45 + | ++ + + + + + | +/** |
+ +46 + | ++ + + + + + | + * <p> |
+ +47 + | ++ + + + + + | + * Validates Javadoc comments to help ensure they are well formed. |
+ +48 + | ++ + + + + + | + * </p> |
+ +49 + | ++ + + + + + | + * <p> |
+ +50 + | ++ + + + + + | + * The following checks are performed: |
+ +51 + | ++ + + + + + | + * </p> |
+ +52 + | ++ + + + + + | + * <ul> |
+ +53 + | ++ + + + + + | + * <li> |
+ +54 + | ++ + + + + + | + * Ensures the first sentence ends with proper punctuation |
+ +55 + | ++ + + + + + | + * (That is a period, question mark, or exclamation mark, by default). |
+ +56 + | ++ + + + + + | + * Javadoc automatically places the first sentence in the method summary |
+ +57 + | ++ + + + + + | + * table and index. Without proper punctuation the Javadoc may be malformed. |
+ +58 + | ++ + + + + + | + * All items eligible for the {@code {@inheritDoc}} tag are exempt from this |
+ +59 + | ++ + + + + + | + * requirement. |
+ +60 + | ++ + + + + + | + * </li> |
+ +61 + | ++ + + + + + | + * <li> |
+ +62 + | ++ + + + + + | + * Check text for Javadoc statements that do not have any description. |
+ +63 + | ++ + + + + + | + * This includes both completely empty Javadoc, and Javadoc with only tags |
+ +64 + | ++ + + + + + | + * such as {@code @param} and {@code @return}. |
+ +65 + | ++ + + + + + | + * </li> |
+ +66 + | ++ + + + + + | + * <li> |
+ +67 + | ++ + + + + + | + * Check text for incomplete HTML tags. Verifies that HTML tags have |
+ +68 + | ++ + + + + + | + * corresponding end tags and issues an "Unclosed HTML tag found:" error if not. |
+ +69 + | ++ + + + + + | + * An "Extra HTML tag found:" error is issued if an end tag is found without |
+ +70 + | ++ + + + + + | + * a previous open tag. |
+ +71 + | ++ + + + + + | + * </li> |
+ +72 + | ++ + + + + + | + * <li> |
+ +73 + | ++ + + + + + | + * Check that a package Javadoc comment is well-formed (as described above) and |
+ +74 + | ++ + + + + + | + * NOT missing from any package-info.java files. |
+ +75 + | ++ + + + + + | + * </li> |
+ +76 + | ++ + + + + + | + * <li> |
+ +77 + | ++ + + + + + | + * Check for allowed HTML tags. The list of allowed HTML tags is |
+ +78 + | ++ + + + + + | + * "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote", |
+ +79 + | ++ + + + + + | + * "br", "caption", "cite", "code", "colgroup", "dd", "del", "dfn", "div", "dl", |
+ +80 + | ++ + + + + + | + * "dt", "em", "fieldset", "font", "h1", "h2", "h3", "h4", "h5", "h6", "hr", |
+ +81 + | ++ + + + + + | + * "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "samp", "small", |
+ +82 + | ++ + + + + + | + * "span", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", |
+ +83 + | ++ + + + + + | + * "thead", "tr", "tt", "u", "ul", "var". |
+ +84 + | ++ + + + + + | + * </li> |
+ +85 + | ++ + + + + + | + * </ul> |
+ +86 + | ++ + + + + + | + * <p> |
+ +87 + | ++ + + + + + | + * These checks were patterned after the checks made by the |
+ +88 + | ++ + + + + + | + * <a href="http://maven-doccheck.sourceforge.net/">DocCheck</a> doclet |
+ +89 + | ++ + + + + + | + * available from Sun. Note: Original Sun's DocCheck tool does not exist anymore. |
+ +90 + | ++ + + + + + | + * </p> |
+ +91 + | ++ + + + + + | + * <ul> |
+ +92 + | ++ + + + + + | + * <li> |
+ +93 + | ++ + + + + + | + * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. |
+ +94 + | ++ + + + + + | + * Default value is {@code private}. |
+ +95 + | ++ + + + + + | + * </li> |
+ +96 + | ++ + + + + + | + * <li> |
+ +97 + | ++ + + + + + | + * Property {@code excludeScope} - Specify the visibility scope where |
+ +98 + | ++ + + + + + | + * Javadoc comments are not checked. |
+ +99 + | ++ + + + + + | + * Default value is {@code null}. |
+ +100 + | ++ + + + + + | + * </li> |
+ +101 + | ++ + + + + + | + * <li> |
+ +102 + | ++ + + + + + | + * Property {@code checkFirstSentence} - Control whether to check the first |
+ +103 + | ++ + + + + + | + * sentence for proper end of sentence. |
+ +104 + | ++ + + + + + | + * Default value is {@code true}. |
+ +105 + | ++ + + + + + | + * </li> |
+ +106 + | ++ + + + + + | + * <li> |
+ +107 + | ++ + + + + + | + * Property {@code endOfSentenceFormat} - Specify the format for matching |
+ +108 + | ++ + + + + + | + * the end of a sentence. |
+ +109 + | ++ + + + + + | + * Default value is {@code "([.?!][ \t\n\r\f<])|([.?!]$)"}. |
+ +110 + | ++ + + + + + | + * </li> |
+ +111 + | ++ + + + + + | + * <li> |
+ +112 + | ++ + + + + + | + * Property {@code checkEmptyJavadoc} - Control whether to check if the Javadoc |
+ +113 + | ++ + + + + + | + * is missing a describing text. |
+ +114 + | ++ + + + + + | + * Default value is {@code false}. |
+ +115 + | ++ + + + + + | + * </li> |
+ +116 + | ++ + + + + + | + * <li> |
+ +117 + | ++ + + + + + | + * Property {@code checkHtml} - Control whether to check for incomplete HTML tags. |
+ +118 + | ++ + + + + + | + * Default value is {@code true}. |
+ +119 + | ++ + + + + + | + * </li> |
+ +120 + | ++ + + + + + | + * <li> |
+ +121 + | ++ + + + + + | + * Property {@code tokens} - tokens to check Default value is: |
+ +122 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF"> |
+ +123 + | ++ + + + + + | + * ANNOTATION_DEF</a>, |
+ +124 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF"> |
+ +125 + | ++ + + + + + | + * ANNOTATION_FIELD_DEF</a>, |
+ +126 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF"> |
+ +127 + | ++ + + + + + | + * CLASS_DEF</a>, |
+ +128 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF"> |
+ +129 + | ++ + + + + + | + * CTOR_DEF</a>, |
+ +130 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_CONSTANT_DEF"> |
+ +131 + | ++ + + + + + | + * ENUM_CONSTANT_DEF</a>, |
+ +132 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF"> |
+ +133 + | ++ + + + + + | + * ENUM_DEF</a>, |
+ +134 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF"> |
+ +135 + | ++ + + + + + | + * INTERFACE_DEF</a>, |
+ +136 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF"> |
+ +137 + | ++ + + + + + | + * METHOD_DEF</a>, |
+ +138 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#PACKAGE_DEF"> |
+ +139 + | ++ + + + + + | + * PACKAGE_DEF</a>, |
+ +140 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF"> |
+ +141 + | ++ + + + + + | + * VARIABLE_DEF</a>. |
+ +142 + | ++ + + + + + | + * </li> |
+ +143 + | ++ + + + + + | + * </ul> |
+ +144 + | ++ + + + + + | + * <p> |
+ +145 + | ++ + + + + + | + * To configure the default check: |
+ +146 + | ++ + + + + + | + * </p> |
+ +147 + | ++ + + + + + | + * <pre> |
+ +148 + | ++ + + + + + | + * <module name="JavadocStyle"/> |
+ +149 + | ++ + + + + + | + * </pre> |
+ +150 + | ++ + + + + + | + * <p>Example:</p> |
+ +151 + | ++ + + + + + | + * <pre> |
+ +152 + | ++ + + + + + | + * public class Test { |
+ +153 + | ++ + + + + + | + * /** |
+ +154 + | ++ + + + + + | + * * Some description here. // OK |
+ +155 + | ++ + + + + + | + * */ |
+ +156 + | ++ + + + + + | + * private void methodWithValidCommentStyle() {} |
+ +157 + | ++ + + + + + | + * |
+ +158 + | ++ + + + + + | + * /** |
+ +159 + | ++ + + + + + | + * * Some description here // violation, the sentence must end with a proper punctuation |
+ +160 + | ++ + + + + + | + * */ |
+ +161 + | ++ + + + + + | + * private void methodWithInvalidCommentStyle() {} |
+ +162 + | ++ + + + + + | + * } |
+ +163 + | ++ + + + + + | + * </pre> |
+ +164 + | ++ + + + + + | + * <p> |
+ +165 + | ++ + + + + + | + * To configure the check for {@code public} scope: |
+ +166 + | ++ + + + + + | + * </p> |
+ +167 + | ++ + + + + + | + * <pre> |
+ +168 + | ++ + + + + + | + * <module name="JavadocStyle"> |
+ +169 + | ++ + + + + + | + * <property name="scope" value="public"/> |
+ +170 + | ++ + + + + + | + * </module> |
+ +171 + | ++ + + + + + | + * </pre> |
+ +172 + | ++ + + + + + | + * <p>Example:</p> |
+ +173 + | ++ + + + + + | + * <pre> |
+ +174 + | ++ + + + + + | + * public class Test { |
+ +175 + | ++ + + + + + | + * /** |
+ +176 + | ++ + + + + + | + * * Some description here // violation, the sentence must end with a proper punctuation |
+ +177 + | ++ + + + + + | + * */ |
+ +178 + | ++ + + + + + | + * public void test1() {} |
+ +179 + | ++ + + + + + | + * |
+ +180 + | ++ + + + + + | + * /** |
+ +181 + | ++ + + + + + | + * * Some description here // OK |
+ +182 + | ++ + + + + + | + * */ |
+ +183 + | ++ + + + + + | + * private void test2() {} |
+ +184 + | ++ + + + + + | + * } |
+ +185 + | ++ + + + + + | + * </pre> |
+ +186 + | ++ + + + + + | + * <p> |
+ +187 + | ++ + + + + + | + * To configure the check for javadoc which is in {@code private}, but not in {@code package} scope: |
+ +188 + | ++ + + + + + | + * </p> |
+ +189 + | ++ + + + + + | + * <pre> |
+ +190 + | ++ + + + + + | + * <module name="JavadocStyle"> |
+ +191 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +192 + | ++ + + + + + | + * <property name="excludeScope" value="package"/> |
+ +193 + | ++ + + + + + | + * </module> |
+ +194 + | ++ + + + + + | + * </pre> |
+ +195 + | ++ + + + + + | + * <p>Example:</p> |
+ +196 + | ++ + + + + + | + * <pre> |
+ +197 + | ++ + + + + + | + * public class Test { |
+ +198 + | ++ + + + + + | + * /** |
+ +199 + | ++ + + + + + | + * * Some description here // violation, the sentence must end with a proper punctuation |
+ +200 + | ++ + + + + + | + * */ |
+ +201 + | ++ + + + + + | + * private void test1() {} |
+ +202 + | ++ + + + + + | + * |
+ +203 + | ++ + + + + + | + * /** |
+ +204 + | ++ + + + + + | + * * Some description here // OK |
+ +205 + | ++ + + + + + | + * */ |
+ +206 + | ++ + + + + + | + * void test2() {} |
+ +207 + | ++ + + + + + | + * } |
+ +208 + | ++ + + + + + | + * </pre> |
+ +209 + | ++ + + + + + | + * <p> |
+ +210 + | ++ + + + + + | + * To configure the check to turn off first sentence checking: |
+ +211 + | ++ + + + + + | + * </p> |
+ +212 + | ++ + + + + + | + * <pre> |
+ +213 + | ++ + + + + + | + * <module name="JavadocStyle"> |
+ +214 + | ++ + + + + + | + * <property name="checkFirstSentence" value="false"/> |
+ +215 + | ++ + + + + + | + * </module> |
+ +216 + | ++ + + + + + | + * </pre> |
+ +217 + | ++ + + + + + | + * <p>Example:</p> |
+ +218 + | ++ + + + + + | + * <pre> |
+ +219 + | ++ + + + + + | + * public class Test { |
+ +220 + | ++ + + + + + | + * /** |
+ +221 + | ++ + + + + + | + * * Some description here // OK |
+ +222 + | ++ + + + + + | + * * Second line of description // violation, the sentence must end with a proper punctuation |
+ +223 + | ++ + + + + + | + * */ |
+ +224 + | ++ + + + + + | + * private void test1() {} |
+ +225 + | ++ + + + + + | + * } |
+ +226 + | ++ + + + + + | + * </pre> |
+ +227 + | ++ + + + + + | + * <p> |
+ +228 + | ++ + + + + + | + * To configure the check to turn off validation of incomplete html tags: |
+ +229 + | ++ + + + + + | + * </p> |
+ +230 + | ++ + + + + + | + * <pre> |
+ +231 + | ++ + + + + + | + * <module name="JavadocStyle"> |
+ +232 + | ++ + + + + + | + * <property name="checkHtml" value="false"/> |
+ +233 + | ++ + + + + + | + * </module> |
+ +234 + | ++ + + + + + | + * </pre> |
+ +235 + | ++ + + + + + | + * <p>Example:</p> |
+ +236 + | ++ + + + + + | + * <pre> |
+ +237 + | ++ + + + + + | + * public class Test { |
+ +238 + | ++ + + + + + | + * /** |
+ +239 + | ++ + + + + + | + * * Some description here // violation, the sentence must end with a proper punctuation |
+ +240 + | ++ + + + + + | + * * <p // OK |
+ +241 + | ++ + + + + + | + * */ |
+ +242 + | ++ + + + + + | + * private void test1() {} |
+ +243 + | ++ + + + + + | + * } |
+ +244 + | ++ + + + + + | + * </pre> |
+ +245 + | ++ + + + + + | + * <p> |
+ +246 + | ++ + + + + + | + * To configure the check for only class definitions: |
+ +247 + | ++ + + + + + | + * </p> |
+ +248 + | ++ + + + + + | + * <pre> |
+ +249 + | ++ + + + + + | + * <module name="JavadocStyle"> |
+ +250 + | ++ + + + + + | + * <property name="tokens" value="CLASS_DEF"/> |
+ +251 + | ++ + + + + + | + * </module> |
+ +252 + | ++ + + + + + | + * </pre> |
+ +253 + | ++ + + + + + | + * <p>Example:</p> |
+ +254 + | ++ + + + + + | + * <pre> |
+ +255 + | ++ + + + + + | + * /** |
+ +256 + | ++ + + + + + | + * * Some description here // violation, the sentence must end with a proper punctuation |
+ +257 + | ++ + + + + + | + * */ |
+ +258 + | ++ + + + + + | + * public class Test { |
+ +259 + | ++ + + + + + | + * /** |
+ +260 + | ++ + + + + + | + * * Some description here // OK |
+ +261 + | ++ + + + + + | + * */ |
+ +262 + | ++ + + + + + | + * private void test1() {} |
+ +263 + | ++ + + + + + | + * } |
+ +264 + | ++ + + + + + | + * </pre> |
+ +265 + | ++ + + + + + | + * |
+ +266 + | ++ + + + + + | + * @since 3.2 |
+ +267 + | ++ + + + + + | + */ |
+ +268 + | ++ + + + + + | +@StatelessCheck |
+ +269 + | ++ + + + + + | +public class JavadocStyleCheck |
+ +270 + | ++ + + + + + | + extends AbstractCheck { |
+ +271 + | ++ + + + + + | +|
+ +272 + | ++ + + + + + | + /** Message property key for the Missing Javadoc message. */ |
+ +273 + | ++ + + + + + | + public static final String MSG_JAVADOC_MISSING = "javadoc.missing"; |
+ +274 + | ++ + + + + + | +|
+ +275 + | ++ + + + + + | + /** Message property key for the Empty Javadoc message. */ |
+ +276 + | ++ + + + + + | + public static final String MSG_EMPTY = "javadoc.empty"; |
+ +277 + | ++ + + + + + | +|
+ +278 + | ++ + + + + + | + /** Message property key for the No Javadoc end of Sentence Period message. */ |
+ +279 + | ++ + + + + + | + public static final String MSG_NO_PERIOD = "javadoc.noPeriod"; |
+ +280 + | ++ + + + + + | +|
+ +281 + | ++ + + + + + | + /** Message property key for the Incomplete Tag message. */ |
+ +282 + | ++ + + + + + | + public static final String MSG_INCOMPLETE_TAG = "javadoc.incompleteTag"; |
+ +283 + | ++ + + + + + | +|
+ +284 + | ++ + + + + + | + /** Message property key for the Unclosed HTML message. */ |
+ +285 + | ++ + + + + + | + public static final String MSG_UNCLOSED_HTML = JavadocDetailNodeParser.MSG_UNCLOSED_HTML_TAG; |
+ +286 + | ++ + + + + + | +|
+ +287 + | ++ + + + + + | + /** Message property key for the Extra HTML message. */ |
+ +288 + | ++ + + + + + | + public static final String MSG_EXTRA_HTML = "javadoc.extraHtml"; |
+ +289 + | ++ + + + + + | +|
+ +290 + | ++ + + + + + | + /** HTML tags that do not require a close tag. */ |
+ +291 + | ++ + + + + + | + private static final Set<String> SINGLE_TAGS = Collections.unmodifiableSortedSet( |
+ +292 + | ++ + + + + + | + Arrays.stream(new String[] {"br", "li", "dt", "dd", "hr", "img", "p", "td", "tr", "th", }) |
+ +293 + | ++ + + + + + | + .collect(Collectors.toCollection(TreeSet::new))); |
+ +294 + | ++ + + + + + | +|
+ +295 + | ++ + + + + + | + /** |
+ +296 + | ++ + + + + + | + * HTML tags that are allowed in java docs. |
+ +297 + | ++ + + + + + | + * From https://www.w3schools.com/tags/default.asp |
+ +298 + | ++ + + + + + | + * The forms and structure tags are not allowed |
+ +299 + | ++ + + + + + | + */ |
+ +300 + | ++ + + + + + | + private static final Set<String> ALLOWED_TAGS = Collections.unmodifiableSortedSet( |
+ +301 + | ++ + + + + + | + Arrays.stream(new String[] { |
+ +302 + | ++ + + + + + | + "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", |
+ +303 + | ++ + + + + + | + "blockquote", "br", "caption", "cite", "code", "colgroup", "dd", |
+ +304 + | ++ + + + + + | + "del", "dfn", "div", "dl", "dt", "em", "fieldset", "font", "h1", |
+ +305 + | ++ + + + + + | + "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "ins", "kbd", |
+ +306 + | ++ + + + + + | + "li", "ol", "p", "pre", "q", "samp", "small", "span", "strong", |
+ +307 + | ++ + + + + + | + "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", |
+ +308 + | ++ + + + + + | + "tr", "tt", "u", "ul", "var", }) |
+ +309 + | ++ + + + + + | + .collect(Collectors.toCollection(TreeSet::new))); |
+ +310 + | ++ + + + + + | +|
+ +311 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +312 + | ++ + + + + + | + private Scope scope = Scope.PRIVATE; |
+ +313 + | ++ + + + + + | +|
+ +314 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +315 + | ++ + + + + + | + private Scope excludeScope; |
+ +316 + | ++ + + + + + | +|
+ +317 + | ++ + + + + + | + /** Specify the format for matching the end of a sentence. */ |
+ +318 + | ++ + + + + + | + private Pattern endOfSentenceFormat = Pattern.compile("([.?!][ \t\n\r\f<])|([.?!]$)"); |
+ +319 + | ++ + + + + + | +|
+ +320 + | ++ + + + + + | + /** |
+ +321 + | ++ + + + + + | + * Control whether to check the first sentence for proper end of sentence. |
+ +322 + | ++ + + + + + | + */ |
+ +323 + | ++ + + + + + | + private boolean checkFirstSentence = true; |
+ +324 + | ++ + + + + + | +|
+ +325 + | ++ + + + + + | + /** |
+ +326 + | ++ + + + + + | + * Control whether to check for incomplete HTML tags. |
+ +327 + | ++ + + + + + | + */ |
+ +328 + | ++ + + + + + | + private boolean checkHtml = true; |
+ +329 + | ++ + + + + + | +|
+ +330 + | ++ + + + + + | + /** |
+ +331 + | ++ + + + + + | + * Control whether to check if the Javadoc is missing a describing text. |
+ +332 + | ++ + + + + + | + */ |
+ +333 + | ++ + + + + + | + private boolean checkEmptyJavadoc; |
+ +334 + | ++ + + + + + | +|
+ +335 + | ++ + + + + + | + @Override |
+ +336 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +337 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +338 + | ++ + + + + + | + } |
+ +339 + | ++ + + + + + | +|
+ +340 + | ++ + + + + + | + @Override |
+ +341 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +342 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +343 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +344 + | ++ + + + + + | + TokenTypes.ANNOTATION_FIELD_DEF, |
+ +345 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +346 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +347 + | ++ + + + + + | + TokenTypes.ENUM_CONSTANT_DEF, |
+ +348 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +349 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +350 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +351 + | ++ + + + + + | + TokenTypes.PACKAGE_DEF, |
+ +352 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF, |
+ +353 + | ++ + + + + + | + }; |
+ +354 + | ++ + + + + + | + } |
+ +355 + | ++ + + + + + | +|
+ +356 + | ++ + + + + + | + @Override |
+ +357 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +358 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +359 + | ++ + + + + + | + } |
+ +360 + | ++ + + + + + | +|
+ +361 + | ++ + + + + + | + @Override |
+ +362 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +363 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast)) { |
+ +364 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +365 + | ++ + + + + + | + // Need to start searching for the comment before the annotations |
+ +366 + | ++ + + + + + | + // that may exist. Even if annotations are not defined on the |
+ +367 + | ++ + + + + + | + // package, the ANNOTATIONS AST is defined. |
+ +368 + | ++ + + + + + | + final TextBlock textBlock = |
+ +369 + | ++ + + + + + | + contents.getJavadocBefore(ast.getFirstChild().getLineNo()); |
+ +370 + | ++ + + + + + | +|
+ +371 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::checkComment → KILLED + + + + |
+ checkComment(ast, textBlock); |
+ +372 + | ++ + + + + + | + } |
+ +373 + | ++ + + + + + | + } |
+ +374 + | ++ + + + + + | +|
+ +375 + | ++ + + + + + | + /** |
+ +376 + | ++ + + + + + | + * Whether we should check this node. |
+ +377 + | ++ + + + + + | + * |
+ +378 + | ++ + + + + + | + * @param ast a given node. |
+ +379 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +380 + | ++ + + + + + | + */ |
+ +381 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast) { |
+ +382 + | ++ + + + + + | + boolean check = false; |
+ +383 + | ++ + + + + + | +|
+ +384 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ if (ast.getType() == TokenTypes.PACKAGE_DEF) { |
+ +385 + | ++ + + + + + | + check = getFileContents().inPackageInfo(); |
+ +386 + | ++ + + + + + | + } |
+ +387 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ else if (!ScopeUtil.isInCodeBlock(ast)) { |
+ +388 + | ++ + + + + + | + final Scope customScope; |
+ +389 + | ++ + + + + + | +|
+ +390 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast) |
+ +391 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ || ast.getType() == TokenTypes.ENUM_CONSTANT_DEF) { |
+ +392 + | ++ + + + + + | + customScope = Scope.PUBLIC; |
+ +393 + | ++ + + + + + | + } |
+ +394 + | ++ + + + + + | + else { |
+ +395 + | ++ + + + + + | + customScope = ScopeUtil.getScopeFromMods(ast.findFirstToken(TokenTypes.MODIFIERS)); |
+ +396 + | ++ + + + + + | + } |
+ +397 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +398 + | ++ + + + + + | +|
+ +399 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ check = customScope.isIn(scope) |
+ +400 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ && (surroundingScope == null || surroundingScope.isIn(scope)) |
+ +401 + | ++ + + + + + | + && (excludeScope == null |
+ +402 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ || !customScope.isIn(excludeScope) |
+ +403 + | ++ + + + + + | + || surroundingScope != null |
+ +404 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !surroundingScope.isIn(excludeScope)); |
+ +405 + | ++ + + + + + | + } |
+ +406 + | +
+
+3
+
+
+1. shouldCheck : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::shouldCheck → KILLED + +2. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::shouldCheck → KILLED + +3. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return check; |
+ +407 + | ++ + + + + + | + } |
+ +408 + | ++ + + + + + | +|
+ +409 + | ++ + + + + + | + /** |
+ +410 + | ++ + + + + + | + * Performs the various checks against the Javadoc comment. |
+ +411 + | ++ + + + + + | + * |
+ +412 + | ++ + + + + + | + * @param ast the AST of the element being documented |
+ +413 + | ++ + + + + + | + * @param comment the source lines that make up the Javadoc comment. |
+ +414 + | ++ + + + + + | + * |
+ +415 + | ++ + + + + + | + * @see #checkFirstSentenceEnding(DetailAST, TextBlock) |
+ +416 + | ++ + + + + + | + * @see #checkHtmlTags(DetailAST, TextBlock) |
+ +417 + | ++ + + + + + | + */ |
+ +418 + | ++ + + + + + | + private void checkComment(final DetailAST ast, final TextBlock comment) { |
+ +419 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (comment == null) { |
+ +420 + | ++ + + + + + | + // checking for missing docs in JavadocStyleCheck is not consistent |
+ +421 + | ++ + + + + + | + // with the rest of CheckStyle... Even though, I didn't think it |
+ +422 + | ++ + + + + + | + // made sense to make another check just to ensure that the |
+ +423 + | ++ + + + + + | + // package-info.java file actually contains package Javadocs. |
+ +424 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (getFileContents().inPackageInfo()) { |
+ +425 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(ast, MSG_JAVADOC_MISSING); |
+ +426 + | ++ + + + + + | + } |
+ +427 + | ++ + + + + + | + } |
+ +428 + | ++ + + + + + | + else { |
+ +429 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (checkFirstSentence) { |
+ +430 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::checkFirstSentenceEnding → KILLED + + + + |
+ checkFirstSentenceEnding(ast, comment); |
+ +431 + | ++ + + + + + | + } |
+ +432 + | ++ + + + + + | +|
+ +433 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (checkHtml) { |
+ +434 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::checkHtmlTags → KILLED + + + + |
+ checkHtmlTags(ast, comment); |
+ +435 + | ++ + + + + + | + } |
+ +436 + | ++ + + + + + | +|
+ +437 + | +
+
+1
+
+
+1. checkComment : negated conditional → KILLED + + + + |
+ if (checkEmptyJavadoc) { |
+ +438 + | +
+
+1
+
+
+1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::checkJavadocIsNotEmpty → KILLED + + + + |
+ checkJavadocIsNotEmpty(comment); |
+ +439 + | ++ + + + + + | + } |
+ +440 + | ++ + + + + + | + } |
+ +441 + | ++ + + + + + | + } |
+ +442 + | ++ + + + + + | +|
+ +443 + | ++ + + + + + | + /** |
+ +444 + | ++ + + + + + | + * Checks that the first sentence ends with proper punctuation. This method |
+ +445 + | ++ + + + + + | + * uses a regular expression that checks for the presence of a period, |
+ +446 + | ++ + + + + + | + * question mark, or exclamation mark followed either by whitespace, an |
+ +447 + | ++ + + + + + | + * HTML element, or the end of string. This method ignores {_AT_inheritDoc} |
+ +448 + | ++ + + + + + | + * comments for TokenTypes that are valid for {_AT_inheritDoc}. |
+ +449 + | ++ + + + + + | + * |
+ +450 + | ++ + + + + + | + * @param ast the current node |
+ +451 + | ++ + + + + + | + * @param comment the source lines that make up the Javadoc comment. |
+ +452 + | ++ + + + + + | + */ |
+ +453 + | ++ + + + + + | + private void checkFirstSentenceEnding(final DetailAST ast, TextBlock comment) { |
+ +454 + | ++ + + + + + | + final String commentText = getCommentText(comment.getText()); |
+ +455 + | ++ + + + + + | +|
+ +456 + | +
+
+1
+
+
+1. checkFirstSentenceEnding : negated conditional → KILLED + + + + |
+ if (!commentText.isEmpty() |
+ +457 + | +
+
+1
+
+
+1. checkFirstSentenceEnding : negated conditional → KILLED + + + + |
+ && !endOfSentenceFormat.matcher(commentText).find() |
+ +458 + | +
+
+1
+
+
+1. checkFirstSentenceEnding : negated conditional → KILLED + + + + |
+ && !(commentText.startsWith("{@inheritDoc}") |
+ +459 + | +
+
+1
+
+
+1. checkFirstSentenceEnding : negated conditional → KILLED + + + + |
+ && JavadocTagInfo.INHERIT_DOC.isValidOn(ast))) { |
+ +460 + | +
+
+1
+
+
+1. checkFirstSentenceEnding : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(comment.getStartLineNo(), MSG_NO_PERIOD); |
+ +461 + | ++ + + + + + | + } |
+ +462 + | ++ + + + + + | + } |
+ +463 + | ++ + + + + + | +|
+ +464 + | ++ + + + + + | + /** |
+ +465 + | ++ + + + + + | + * Checks that the Javadoc is not empty. |
+ +466 + | ++ + + + + + | + * |
+ +467 + | ++ + + + + + | + * @param comment the source lines that make up the Javadoc comment. |
+ +468 + | ++ + + + + + | + */ |
+ +469 + | ++ + + + + + | + private void checkJavadocIsNotEmpty(TextBlock comment) { |
+ +470 + | ++ + + + + + | + final String commentText = getCommentText(comment.getText()); |
+ +471 + | ++ + + + + + | +|
+ +472 + | +
+
+1
+
+
+1. checkJavadocIsNotEmpty : negated conditional → KILLED + + + + |
+ if (commentText.isEmpty()) { |
+ +473 + | +
+
+1
+
+
+1. checkJavadocIsNotEmpty : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(comment.getStartLineNo(), MSG_EMPTY); |
+ +474 + | ++ + + + + + | + } |
+ +475 + | ++ + + + + + | + } |
+ +476 + | ++ + + + + + | +|
+ +477 + | ++ + + + + + | + /** |
+ +478 + | ++ + + + + + | + * Returns the comment text from the Javadoc. |
+ +479 + | ++ + + + + + | + * |
+ +480 + | ++ + + + + + | + * @param comments the lines of Javadoc. |
+ +481 + | ++ + + + + + | + * @return a comment text String. |
+ +482 + | ++ + + + + + | + */ |
+ +483 + | ++ + + + + + | + private static String getCommentText(String... comments) { |
+ +484 + | +
+
+1
+
+
+1. getCommentText : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder builder = new StringBuilder(1024); |
+ +485 + | ++ + + + + + | + for (final String line : comments) { |
+ +486 + | ++ + + + + + | + final int textStart = findTextStart(line); |
+ +487 + | ++ + + + + + | +|
+ +488 + | +
+
+1
+
+
+1. getCommentText : negated conditional → KILLED + + + + |
+ if (textStart != -1) { |
+ +489 + | +
+
+1
+
+
+1. getCommentText : negated conditional → KILLED + + + + |
+ if (line.charAt(textStart) == '@') { |
+ +490 + | ++ + + + + + | + // we have found the tag section |
+ +491 + | ++ + + + + + | + break; |
+ +492 + | ++ + + + + + | + } |
+ +493 + | ++ + + + + + | + builder.append(line.substring(textStart)); |
+ +494 + | +
+
+1
+
+
+1. getCommentText : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::trimTail → KILLED + + + + |
+ trimTail(builder); |
+ +495 + | ++ + + + + + | + builder.append('\n'); |
+ +496 + | ++ + + + + + | + } |
+ +497 + | ++ + + + + + | + } |
+ +498 + | ++ + + + + + | +|
+ +499 + | +
+
+1
+
+
+1. getCommentText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::getCommentText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return builder.toString().trim(); |
+ +500 + | ++ + + + + + | + } |
+ +501 + | ++ + + + + + | +|
+ +502 + | ++ + + + + + | + /** |
+ +503 + | ++ + + + + + | + * Finds the index of the first non-whitespace character ignoring the |
+ +504 + | ++ + + + + + | + * Javadoc comment start and end strings (/** and */) as well as any |
+ +505 + | ++ + + + + + | + * leading asterisk. |
+ +506 + | ++ + + + + + | + * |
+ +507 + | ++ + + + + + | + * @param line the Javadoc comment line of text to scan. |
+ +508 + | ++ + + + + + | + * @return the int index relative to 0 for the start of text |
+ +509 + | ++ + + + + + | + * or -1 if not found. |
+ +510 + | ++ + + + + + | + */ |
+ +511 + | ++ + + + + + | + private static int findTextStart(String line) { |
+ +512 + | ++ + + + + + | + int textStart = -1; |
+ +513 + | ++ + + + + + | + int index = 0; |
+ +514 + | +
+
+2
+
+
+1. findTextStart : changed conditional boundary → KILLED + +2. findTextStart : negated conditional → KILLED + + + + |
+ while (index < line.length()) { |
+ +515 + | +
+
+1
+
+
+1. findTextStart : negated conditional → KILLED + + + + |
+ if (!Character.isWhitespace(line.charAt(index))) { |
+ +516 + | +
+
+1
+
+
+1. findTextStart : negated conditional → KILLED + + + + |
+ if (line.regionMatches(index, "/**", 0, "/**".length())) { |
+ +517 + | +
+
+1
+
+
+1. findTextStart : Changed increment from 2 to -2 → KILLED + + + + |
+ index += 2; |
+ +518 + | ++ + + + + + | + } |
+ +519 + | +
+
+1
+
+
+1. findTextStart : negated conditional → KILLED + + + + |
+ else if (line.regionMatches(index, "*/", 0, 2)) { |
+ +520 + | +
+
+1
+
+
+1. findTextStart : Changed increment from 1 to -1 → TIMED_OUT + + + + |
+ index++; |
+ +521 + | ++ + + + + + | + } |
+ +522 + | +
+
+1
+
+
+1. findTextStart : negated conditional → KILLED + + + + |
+ else if (line.charAt(index) != '*') { |
+ +523 + | ++ + + + + + | + textStart = index; |
+ +524 + | ++ + + + + + | + break; |
+ +525 + | ++ + + + + + | + } |
+ +526 + | ++ + + + + + | + } |
+ +527 + | +
+
+1
+
+
+1. findTextStart : Changed increment from 1 to -1 → TIMED_OUT + + + + |
+ index++; |
+ +528 + | ++ + + + + + | + } |
+ +529 + | +
+
+1
+
+
+1. findTextStart : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return textStart; |
+ +530 + | ++ + + + + + | + } |
+ +531 + | ++ + + + + + | +|
+ +532 + | ++ + + + + + | + /** |
+ +533 + | ++ + + + + + | + * Trims any trailing whitespace or the end of Javadoc comment string. |
+ +534 + | ++ + + + + + | + * |
+ +535 + | ++ + + + + + | + * @param builder the StringBuilder to trim. |
+ +536 + | ++ + + + + + | + */ |
+ +537 + | ++ + + + + + | + private static void trimTail(StringBuilder builder) { |
+ +538 + | +
+
+1
+
+
+1. trimTail : Replaced integer subtraction with addition → KILLED + + + + |
+ int index = builder.length() - 1; |
+ +539 + | ++ + + + + + | + while (true) { |
+ +540 + | +
+
+1
+
+
+1. trimTail : negated conditional → KILLED + + + + |
+ if (Character.isWhitespace(builder.charAt(index))) { |
+ +541 + | ++ + + + + + | + builder.deleteCharAt(index); |
+ +542 + | ++ + + + + + | + } |
+ +543 + | +
+
+4
+
+
+1. trimTail : changed conditional boundary → KILLED + +2. trimTail : Replaced integer subtraction with addition → KILLED + +3. trimTail : negated conditional → KILLED + +4. trimTail : negated conditional → KILLED + + + + |
+ else if (index > 0 && builder.charAt(index) == '/' |
+ +544 + | +
+
+1
+
+
+1. trimTail : negated conditional → KILLED + + + + |
+ && builder.charAt(index - 1) == '*') { |
+ +545 + | ++ + + + + + | + builder.deleteCharAt(index); |
+ +546 + | +
+
+1
+
+
+1. trimTail : Replaced integer subtraction with addition → KILLED + + + + |
+ builder.deleteCharAt(index - 1); |
+ +547 + | +
+
+1
+
+
+1. trimTail : Changed increment from -1 to 1 → KILLED + + + + |
+ index--; |
+ +548 + | +
+
+2
+
+
+1. trimTail : Replaced integer subtraction with addition → KILLED + +2. trimTail : negated conditional → KILLED + + + + |
+ while (builder.charAt(index - 1) == '*') { |
+ +549 + | +
+
+1
+
+
+1. trimTail : Replaced integer subtraction with addition → KILLED + + + + |
+ builder.deleteCharAt(index - 1); |
+ +550 + | +
+
+1
+
+
+1. trimTail : Changed increment from -1 to 1 → KILLED + + + + |
+ index--; |
+ +551 + | ++ + + + + + | + } |
+ +552 + | ++ + + + + + | + } |
+ +553 + | ++ + + + + + | + else { |
+ +554 + | ++ + + + + + | + break; |
+ +555 + | ++ + + + + + | + } |
+ +556 + | +
+
+1
+
+
+1. trimTail : Changed increment from -1 to 1 → KILLED + + + + |
+ index--; |
+ +557 + | ++ + + + + + | + } |
+ +558 + | ++ + + + + + | + } |
+ +559 + | ++ + + + + + | +|
+ +560 + | ++ + + + + + | + /** |
+ +561 + | ++ + + + + + | + * Checks the comment for HTML tags that do not have a corresponding close |
+ +562 + | ++ + + + + + | + * tag or a close tag that has no previous open tag. This code was |
+ +563 + | ++ + + + + + | + * primarily copied from the DocCheck checkHtml method. |
+ +564 + | ++ + + + + + | + * |
+ +565 + | ++ + + + + + | + * @param ast the node with the Javadoc |
+ +566 + | ++ + + + + + | + * @param comment the {@code TextBlock} which represents |
+ +567 + | ++ + + + + + | + * the Javadoc comment. |
+ +568 + | ++ + + + + + | + * @noinspection MethodWithMultipleReturnPoints |
+ +569 + | ++ + + + + + | + */ |
+ +570 + | ++ + + + + + | + // -@cs[ReturnCount] Too complex to break apart. |
+ +571 + | ++ + + + + + | + private void checkHtmlTags(final DetailAST ast, final TextBlock comment) { |
+ +572 + | ++ + + + + + | + final int lineNo = comment.getStartLineNo(); |
+ +573 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to java/util/ArrayDeque::<init> → KILLED + + + + |
+ final Deque<HtmlTag> htmlStack = new ArrayDeque<>(); |
+ +574 + | ++ + + + + + | + final String[] text = comment.getText(); |
+ +575 + | ++ + + + + + | +|
+ +576 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::<init> → KILLED + + + + |
+ final TagParser parser = new TagParser(text, lineNo); |
+ +577 + | ++ + + + + + | +|
+ +578 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ while (parser.hasNextTag()) { |
+ +579 + | ++ + + + + + | + final HtmlTag tag = parser.nextTag(); |
+ +580 + | ++ + + + + + | +|
+ +581 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (tag.isIncompleteTag()) { |
+ +582 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(tag.getLineNo(), MSG_INCOMPLETE_TAG, |
+ +583 + | +
+
+1
+
+
+1. checkHtmlTags : Replaced integer subtraction with addition → KILLED + + + + |
+ text[tag.getLineNo() - lineNo]); |
+ +584 + | ++ + + + + + | + return; |
+ +585 + | ++ + + + + + | + } |
+ +586 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (tag.isClosedTag()) { |
+ +587 + | ++ + + + + + | + // do nothing |
+ +588 + | ++ + + + + + | + continue; |
+ +589 + | ++ + + + + + | + } |
+ +590 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (tag.isCloseTag()) { |
+ +591 + | ++ + + + + + | + // We have found a close tag. |
+ +592 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (isExtraHtml(tag.getId(), htmlStack)) { |
+ +593 + | ++ + + + + + | + // No corresponding open tag was found on the stack. |
+ +594 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(tag.getLineNo(), |
+ +595 + | ++ + + + + + | + tag.getPosition(), |
+ +596 + | ++ + + + + + | + MSG_EXTRA_HTML, |
+ +597 + | ++ + + + + + | + tag.getText()); |
+ +598 + | ++ + + + + + | + } |
+ +599 + | ++ + + + + + | + else { |
+ +600 + | ++ + + + + + | + // See if there are any unclosed tags that were opened |
+ +601 + | ++ + + + + + | + // after this one. |
+ +602 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::checkUnclosedTags → KILLED + + + + |
+ checkUnclosedTags(htmlStack, tag.getId()); |
+ +603 + | ++ + + + + + | + } |
+ +604 + | ++ + + + + + | + } |
+ +605 + | ++ + + + + + | + else { |
+ +606 + | ++ + + + + + | + // We only push html tags that are allowed |
+ +607 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (isAllowedTag(tag)) { |
+ +608 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to java/util/Deque::push → KILLED + + + + |
+ htmlStack.push(tag); |
+ +609 + | ++ + + + + + | + } |
+ +610 + | ++ + + + + + | + } |
+ +611 + | ++ + + + + + | + } |
+ +612 + | ++ + + + + + | +|
+ +613 + | ++ + + + + + | + // Identify any tags left on the stack. |
+ +614 + | ++ + + + + + | + // Skip multiples, like <b>...<b> |
+ +615 + | ++ + + + + + | + String lastFound = ""; |
+ +616 + | ++ + + + + + | + final List<String> typeParameters = CheckUtil.getTypeParameterNames(ast); |
+ +617 + | ++ + + + + + | + for (final HtmlTag htmlTag : htmlStack) { |
+ +618 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ if (!isSingleTag(htmlTag) |
+ +619 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ && !htmlTag.getId().equals(lastFound) |
+ +620 + | +
+
+1
+
+
+1. checkHtmlTags : negated conditional → KILLED + + + + |
+ && !typeParameters.contains(htmlTag.getId())) { |
+ +621 + | +
+
+1
+
+
+1. checkHtmlTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(htmlTag.getLineNo(), htmlTag.getPosition(), |
+ +622 + | ++ + + + + + | + MSG_UNCLOSED_HTML, htmlTag.getText()); |
+ +623 + | ++ + + + + + | + lastFound = htmlTag.getId(); |
+ +624 + | ++ + + + + + | + } |
+ +625 + | ++ + + + + + | + } |
+ +626 + | ++ + + + + + | + } |
+ +627 + | ++ + + + + + | +|
+ +628 + | ++ + + + + + | + /** |
+ +629 + | ++ + + + + + | + * Checks to see if there are any unclosed tags on the stack. The token |
+ +630 + | ++ + + + + + | + * represents a html tag that has been closed and has a corresponding open |
+ +631 + | ++ + + + + + | + * tag on the stack. Any tags, except single tags, that were opened |
+ +632 + | ++ + + + + + | + * (pushed on the stack) after the token are missing a close. |
+ +633 + | ++ + + + + + | + * |
+ +634 + | ++ + + + + + | + * @param htmlStack the stack of opened HTML tags. |
+ +635 + | ++ + + + + + | + * @param token the current HTML tag name that has been closed. |
+ +636 + | ++ + + + + + | + */ |
+ +637 + | ++ + + + + + | + private void checkUnclosedTags(Deque<HtmlTag> htmlStack, String token) { |
+ +638 + | +
+
+1
+
+
+1. checkUnclosedTags : removed call to java/util/ArrayDeque::<init> → KILLED + + + + |
+ final Deque<HtmlTag> unclosedTags = new ArrayDeque<>(); |
+ +639 + | ++ + + + + + | + HtmlTag lastOpenTag = htmlStack.pop(); |
+ +640 + | +
+
+1
+
+
+1. checkUnclosedTags : negated conditional → KILLED + + + + |
+ while (!token.equalsIgnoreCase(lastOpenTag.getId())) { |
+ +641 + | ++ + + + + + | + // Find unclosed elements. Put them on a stack so the |
+ +642 + | ++ + + + + + | + // output order won't be back-to-front. |
+ +643 + | +
+
+1
+
+
+1. checkUnclosedTags : negated conditional → KILLED + + + + |
+ if (isSingleTag(lastOpenTag)) { |
+ +644 + | ++ + + + + + | + lastOpenTag = htmlStack.pop(); |
+ +645 + | ++ + + + + + | + } |
+ +646 + | ++ + + + + + | + else { |
+ +647 + | +
+
+1
+
+
+1. checkUnclosedTags : removed call to java/util/Deque::push → KILLED + + + + |
+ unclosedTags.push(lastOpenTag); |
+ +648 + | ++ + + + + + | + lastOpenTag = htmlStack.pop(); |
+ +649 + | ++ + + + + + | + } |
+ +650 + | ++ + + + + + | + } |
+ +651 + | ++ + + + + + | +|
+ +652 + | ++ + + + + + | + // Output the unterminated tags, if any |
+ +653 + | ++ + + + + + | + // Skip multiples, like <b>..<b> |
+ +654 + | ++ + + + + + | + String lastFound = ""; |
+ +655 + | ++ + + + + + | + for (final HtmlTag htag : unclosedTags) { |
+ +656 + | ++ + + + + + | + lastOpenTag = htag; |
+ +657 + | +
+
+1
+
+
+1. checkUnclosedTags : negated conditional → KILLED + + + + |
+ if (lastOpenTag.getId().equals(lastFound)) { |
+ +658 + | ++ + + + + + | + continue; |
+ +659 + | ++ + + + + + | + } |
+ +660 + | ++ + + + + + | + lastFound = lastOpenTag.getId(); |
+ +661 + | +
+
+1
+
+
+1. checkUnclosedTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::log → KILLED + + + + |
+ log(lastOpenTag.getLineNo(), |
+ +662 + | ++ + + + + + | + lastOpenTag.getPosition(), |
+ +663 + | ++ + + + + + | + MSG_UNCLOSED_HTML, |
+ +664 + | ++ + + + + + | + lastOpenTag.getText()); |
+ +665 + | ++ + + + + + | + } |
+ +666 + | ++ + + + + + | + } |
+ +667 + | ++ + + + + + | +|
+ +668 + | ++ + + + + + | + /** |
+ +669 + | ++ + + + + + | + * Determines if the HtmlTag is one which does not require a close tag. |
+ +670 + | ++ + + + + + | + * |
+ +671 + | ++ + + + + + | + * @param tag the HtmlTag to check. |
+ +672 + | ++ + + + + + | + * @return {@code true} if the HtmlTag is a single tag. |
+ +673 + | ++ + + + + + | + */ |
+ +674 + | ++ + + + + + | + private static boolean isSingleTag(HtmlTag tag) { |
+ +675 + | ++ + + + + + | + // If its a singleton tag (<p>, <br>, etc.), ignore it |
+ +676 + | ++ + + + + + | + // Can't simply not put them on the stack, since singletons |
+ +677 + | ++ + + + + + | + // like <dt> and <dd> (unhappily) may either be terminated |
+ +678 + | ++ + + + + + | + // or not terminated. Both options are legal. |
+ +679 + | +
+
+3
+
+
+1. isSingleTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isSingleTag → KILLED + +2. isSingleTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isSingleTag → KILLED + +3. isSingleTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return SINGLE_TAGS.contains(tag.getId().toLowerCase(Locale.ENGLISH)); |
+ +680 + | ++ + + + + + | + } |
+ +681 + | ++ + + + + + | +|
+ +682 + | ++ + + + + + | + /** |
+ +683 + | ++ + + + + + | + * Determines if the HtmlTag is one which is allowed in a javadoc. |
+ +684 + | ++ + + + + + | + * |
+ +685 + | ++ + + + + + | + * @param tag the HtmlTag to check. |
+ +686 + | ++ + + + + + | + * @return {@code true} if the HtmlTag is an allowed html tag. |
+ +687 + | ++ + + + + + | + */ |
+ +688 + | ++ + + + + + | + private static boolean isAllowedTag(HtmlTag tag) { |
+ +689 + | +
+
+3
+
+
+1. isAllowedTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isAllowedTag → KILLED + +2. isAllowedTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isAllowedTag → KILLED + +3. isAllowedTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return ALLOWED_TAGS.contains(tag.getId().toLowerCase(Locale.ENGLISH)); |
+ +690 + | ++ + + + + + | + } |
+ +691 + | ++ + + + + + | +|
+ +692 + | ++ + + + + + | + /** |
+ +693 + | ++ + + + + + | + * Determines if the given token is an extra HTML tag. This indicates that |
+ +694 + | ++ + + + + + | + * a close tag was found that does not have a corresponding open tag. |
+ +695 + | ++ + + + + + | + * |
+ +696 + | ++ + + + + + | + * @param token an HTML tag id for which a close was found. |
+ +697 + | ++ + + + + + | + * @param htmlStack a Stack of previous open HTML tags. |
+ +698 + | ++ + + + + + | + * @return {@code false} if a previous open tag was found |
+ +699 + | ++ + + + + + | + * for the token. |
+ +700 + | ++ + + + + + | + */ |
+ +701 + | ++ + + + + + | + private static boolean isExtraHtml(String token, Deque<HtmlTag> htmlStack) { |
+ +702 + | ++ + + + + + | + boolean isExtra = true; |
+ +703 + | ++ + + + + + | + for (final HtmlTag tag : htmlStack) { |
+ +704 + | ++ + + + + + | + // Loop, looking for tags that are closed. |
+ +705 + | ++ + + + + + | + // The loop is needed in case there are unclosed |
+ +706 + | ++ + + + + + | + // tags on the stack. In that case, the stack would |
+ +707 + | ++ + + + + + | + // not be empty, but this tag would still be extra. |
+ +708 + | +
+
+1
+
+
+1. isExtraHtml : negated conditional → KILLED + + + + |
+ if (token.equalsIgnoreCase(tag.getId())) { |
+ +709 + | ++ + + + + + | + isExtra = false; |
+ +710 + | ++ + + + + + | + break; |
+ +711 + | ++ + + + + + | + } |
+ +712 + | ++ + + + + + | + } |
+ +713 + | ++ + + + + + | +|
+ +714 + | +
+
+3
+
+
+1. isExtraHtml : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isExtraHtml → KILLED + +2. isExtraHtml : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck::isExtraHtml → KILLED + +3. isExtraHtml : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return isExtra; |
+ +715 + | ++ + + + + + | + } |
+ +716 + | ++ + + + + + | +|
+ +717 + | ++ + + + + + | + /** |
+ +718 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +719 + | ++ + + + + + | + * |
+ +720 + | ++ + + + + + | + * @param scope a scope. |
+ +721 + | ++ + + + + + | + */ |
+ +722 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +723 + | ++ + + + + + | + this.scope = scope; |
+ +724 + | ++ + + + + + | + } |
+ +725 + | ++ + + + + + | +|
+ +726 + | ++ + + + + + | + /** |
+ +727 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +728 + | ++ + + + + + | + * |
+ +729 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +730 + | ++ + + + + + | + */ |
+ +731 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +732 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +733 + | ++ + + + + + | + } |
+ +734 + | ++ + + + + + | +|
+ +735 + | ++ + + + + + | + /** |
+ +736 + | ++ + + + + + | + * Setter to specify the format for matching the end of a sentence. |
+ +737 + | ++ + + + + + | + * |
+ +738 + | ++ + + + + + | + * @param pattern a pattern. |
+ +739 + | ++ + + + + + | + */ |
+ +740 + | ++ + + + + + | + public void setEndOfSentenceFormat(Pattern pattern) { |
+ +741 + | ++ + + + + + | + endOfSentenceFormat = pattern; |
+ +742 + | ++ + + + + + | + } |
+ +743 + | ++ + + + + + | +|
+ +744 + | ++ + + + + + | + /** |
+ +745 + | ++ + + + + + | + * Setter to control whether to check the first sentence for proper end of sentence. |
+ +746 + | ++ + + + + + | + * |
+ +747 + | ++ + + + + + | + * @param flag {@code true} if the first sentence is to be checked |
+ +748 + | ++ + + + + + | + */ |
+ +749 + | ++ + + + + + | + public void setCheckFirstSentence(boolean flag) { |
+ +750 + | ++ + + + + + | + checkFirstSentence = flag; |
+ +751 + | ++ + + + + + | + } |
+ +752 + | ++ + + + + + | +|
+ +753 + | ++ + + + + + | + /** |
+ +754 + | ++ + + + + + | + * Setter to control whether to check for incomplete HTML tags. |
+ +755 + | ++ + + + + + | + * |
+ +756 + | ++ + + + + + | + * @param flag {@code true} if HTML checking is to be performed. |
+ +757 + | ++ + + + + + | + */ |
+ +758 + | ++ + + + + + | + public void setCheckHtml(boolean flag) { |
+ +759 + | ++ + + + + + | + checkHtml = flag; |
+ +760 + | ++ + + + + + | + } |
+ +761 + | ++ + + + + + | +|
+ +762 + | ++ + + + + + | + /** |
+ +763 + | ++ + + + + + | + * Setter to control whether to check if the Javadoc is missing a describing text. |
+ +764 + | ++ + + + + + | + * |
+ +765 + | ++ + + + + + | + * @param flag {@code true} if empty Javadoc checking should be done. |
+ +766 + | ++ + + + + + | + */ |
+ +767 + | ++ + + + + + | + public void setCheckEmptyJavadoc(boolean flag) { |
+ +768 + | ++ + + + + + | + checkEmptyJavadoc = flag; |
+ +769 + | ++ + + + + + | + } |
+ +770 + | ++ + + + + + | +|
+ +771 + | ++ + + + + + | +} |
Mutations | ||
337 | ++ |
+
+
+
+ 1.1 |
+
342 | ++ |
+
+
+
+ 1.1 |
+
358 | ++ |
+
+
+
+ 1.1 |
+
363 | ++ |
+
+
+
+ 1.1 |
+
371 | ++ |
+
+
+
+ 1.1 |
+
384 | ++ |
+
+
+
+ 1.1 |
+
387 | ++ |
+
+
+
+ 1.1 |
+
390 | ++ |
+
+
+
+ 1.1 |
+
391 | ++ |
+
+
+
+ 1.1 |
+
399 | ++ |
+
+
+
+ 1.1 2.2 |
+
400 | ++ |
+
+
+
+ 1.1 2.2 |
+
402 | ++ |
+
+
+
+ 1.1 2.2 |
+
404 | ++ |
+
+
+
+ 1.1 |
+
406 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
419 | ++ |
+
+
+
+ 1.1 |
+
424 | ++ |
+
+
+
+ 1.1 |
+
425 | ++ |
+
+
+
+ 1.1 |
+
429 | ++ |
+
+
+
+ 1.1 |
+
430 | ++ |
+
+
+
+ 1.1 |
+
433 | ++ |
+
+
+
+ 1.1 |
+
434 | ++ |
+
+
+
+ 1.1 |
+
437 | ++ |
+
+
+
+ 1.1 |
+
438 | ++ |
+
+
+
+ 1.1 |
+
456 | ++ |
+
+
+
+ 1.1 |
+
457 | ++ |
+
+
+
+ 1.1 |
+
458 | ++ |
+
+
+
+ 1.1 |
+
459 | ++ |
+
+
+
+ 1.1 |
+
460 | ++ |
+
+
+
+ 1.1 |
+
472 | ++ |
+
+
+
+ 1.1 |
+
473 | ++ |
+
+
+
+ 1.1 |
+
484 | ++ |
+
+
+
+ 1.1 |
+
488 | ++ |
+
+
+
+ 1.1 |
+
489 | ++ |
+
+
+
+ 1.1 |
+
494 | ++ |
+
+
+
+ 1.1 |
+
499 | ++ |
+
+
+
+ 1.1 |
+
514 | ++ |
+
+
+
+ 1.1 2.2 |
+
515 | ++ |
+
+
+
+ 1.1 |
+
516 | ++ |
+
+
+
+ 1.1 |
+
517 | ++ |
+
+
+
+ 1.1 |
+
519 | ++ |
+
+
+
+ 1.1 |
+
520 | ++ |
+
+
+
+ 1.1 |
+
522 | ++ |
+
+
+
+ 1.1 |
+
527 | ++ |
+
+
+
+ 1.1 |
+
529 | ++ |
+
+
+
+ 1.1 |
+
538 | ++ |
+
+
+
+ 1.1 |
+
540 | ++ |
+
+
+
+ 1.1 |
+
543 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
544 | ++ |
+
+
+
+ 1.1 |
+
546 | ++ |
+
+
+
+ 1.1 |
+
547 | ++ |
+
+
+
+ 1.1 |
+
548 | ++ |
+
+
+
+ 1.1 2.2 |
+
549 | ++ |
+
+
+
+ 1.1 |
+
550 | ++ |
+
+
+
+ 1.1 |
+
556 | ++ |
+
+
+
+ 1.1 |
+
573 | ++ |
+
+
+
+ 1.1 |
+
576 | ++ |
+
+
+
+ 1.1 |
+
578 | ++ |
+
+
+
+ 1.1 |
+
581 | ++ |
+
+
+
+ 1.1 |
+
582 | ++ |
+
+
+
+ 1.1 |
+
583 | ++ |
+
+
+
+ 1.1 |
+
586 | ++ |
+
+
+
+ 1.1 |
+
590 | ++ |
+
+
+
+ 1.1 |
+
592 | ++ |
+
+
+
+ 1.1 |
+
594 | ++ |
+
+
+
+ 1.1 |
+
602 | ++ |
+
+
+
+ 1.1 |
+
607 | ++ |
+
+
+
+ 1.1 |
+
608 | ++ |
+
+
+
+ 1.1 |
+
618 | ++ |
+
+
+
+ 1.1 |
+
619 | ++ |
+
+
+
+ 1.1 |
+
620 | ++ |
+
+
+
+ 1.1 |
+
621 | ++ |
+
+
+
+ 1.1 |
+
638 | ++ |
+
+
+
+ 1.1 |
+
640 | ++ |
+
+
+
+ 1.1 |
+
643 | ++ |
+
+
+
+ 1.1 |
+
647 | ++ |
+
+
+
+ 1.1 |
+
657 | ++ |
+
+
+
+ 1.1 |
+
661 | ++ |
+
+
+
+ 1.1 |
+
679 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
689 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
708 | ++ |
+
+
+
+ 1.1 |
+
714 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +/** |
+ +23 + | ++ + + + + + | + * Represents a Javadoc tag. Provides methods to query what type of tag it is. |
+ +24 + | ++ + + + + + | + */ |
+ +25 + | ++ + + + + + | +public class JavadocTag { |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | + /** The line number of the tag. **/ |
+ +28 + | ++ + + + + + | + private final int lineNo; |
+ +29 + | ++ + + + + + | + /** The column number of the tag. **/ |
+ +30 + | ++ + + + + + | + private final int columnNo; |
+ +31 + | ++ + + + + + | + /** An optional first argument. For example the parameter name. **/ |
+ +32 + | ++ + + + + + | + private final String firstArg; |
+ +33 + | ++ + + + + + | + /** The JavadocTagInfo representing this tag. **/ |
+ +34 + | ++ + + + + + | + private final JavadocTagInfo tagInfo; |
+ +35 + | ++ + + + + + | +|
+ +36 + | ++ + + + + + | + /** |
+ +37 + | ++ + + + + + | + * Constructs the object. |
+ +38 + | ++ + + + + + | + * |
+ +39 + | ++ + + + + + | + * @param line the line number of the tag |
+ +40 + | ++ + + + + + | + * @param column the column number of the tag |
+ +41 + | ++ + + + + + | + * @param tag the tag string |
+ +42 + | ++ + + + + + | + * @param firstArg the tag argument |
+ +43 + | ++ + + + + + | + **/ |
+ +44 + | ++ + + + + + | + public JavadocTag(int line, int column, String tag, String firstArg) { |
+ +45 + | ++ + + + + + | + lineNo = line; |
+ +46 + | ++ + + + + + | + columnNo = column; |
+ +47 + | ++ + + + + + | + this.firstArg = firstArg; |
+ +48 + | ++ + + + + + | + tagInfo = JavadocTagInfo.fromName(tag); |
+ +49 + | ++ + + + + + | + } |
+ +50 + | ++ + + + + + | +|
+ +51 + | ++ + + + + + | + /** |
+ +52 + | ++ + + + + + | + * Constructs the object. |
+ +53 + | ++ + + + + + | + * |
+ +54 + | ++ + + + + + | + * @param line the line number of the tag |
+ +55 + | ++ + + + + + | + * @param column the column number of the tag |
+ +56 + | ++ + + + + + | + * @param tag the tag string |
+ +57 + | ++ + + + + + | + **/ |
+ +58 + | ++ + + + + + | + public JavadocTag(int line, int column, String tag) { |
+ +59 + | ++ + + + + + | + this(line, column, tag, null); |
+ +60 + | ++ + + + + + | + } |
+ +61 + | ++ + + + + + | +|
+ +62 + | ++ + + + + + | + /** |
+ +63 + | ++ + + + + + | + * Gets tag name. |
+ +64 + | ++ + + + + + | + * |
+ +65 + | ++ + + + + + | + * @return the tag string |
+ +66 + | ++ + + + + + | + */ |
+ +67 + | ++ + + + + + | + public String getTagName() { |
+ +68 + | +
+
+1
+
+
+1. getTagName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::getTagName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tagInfo.getName(); |
+ +69 + | ++ + + + + + | + } |
+ +70 + | ++ + + + + + | +|
+ +71 + | ++ + + + + + | + /** |
+ +72 + | ++ + + + + + | + * Returns first argument. |
+ +73 + | ++ + + + + + | + * |
+ +74 + | ++ + + + + + | + * @return the first argument. null if not set. |
+ +75 + | ++ + + + + + | + */ |
+ +76 + | ++ + + + + + | + public String getFirstArg() { |
+ +77 + | +
+
+1
+
+
+1. getFirstArg : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::getFirstArg to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return firstArg; |
+ +78 + | ++ + + + + + | + } |
+ +79 + | ++ + + + + + | +|
+ +80 + | ++ + + + + + | + /** |
+ +81 + | ++ + + + + + | + * Gets the line number. |
+ +82 + | ++ + + + + + | + * |
+ +83 + | ++ + + + + + | + * @return the line number |
+ +84 + | ++ + + + + + | + */ |
+ +85 + | ++ + + + + + | + public int getLineNo() { |
+ +86 + | +
+
+1
+
+
+1. getLineNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNo; |
+ +87 + | ++ + + + + + | + } |
+ +88 + | ++ + + + + + | +|
+ +89 + | ++ + + + + + | + /** |
+ +90 + | ++ + + + + + | + * Gets column number. |
+ +91 + | ++ + + + + + | + * |
+ +92 + | ++ + + + + + | + * @return the column number |
+ +93 + | ++ + + + + + | + */ |
+ +94 + | ++ + + + + + | + public int getColumnNo() { |
+ +95 + | +
+
+1
+
+
+1. getColumnNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return columnNo; |
+ +96 + | ++ + + + + + | + } |
+ +97 + | ++ + + + + + | +|
+ +98 + | ++ + + + + + | + @Override |
+ +99 + | ++ + + + + + | + public String toString() { |
+ +100 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "JavadocTag[tag='" + tagInfo.getName() |
+ +101 + | ++ + + + + + | + + "' lineNo=" + lineNo |
+ +102 + | ++ + + + + + | + + ", columnNo=" + columnNo |
+ +103 + | ++ + + + + + | + + ", firstArg='" + firstArg + "']"; |
+ +104 + | ++ + + + + + | + } |
+ +105 + | ++ + + + + + | +|
+ +106 + | ++ + + + + + | + /** |
+ +107 + | ++ + + + + + | + * Checks that the tag is an 'return' tag. |
+ +108 + | ++ + + + + + | + * |
+ +109 + | ++ + + + + + | + * @return whether the tag is an 'return' tag |
+ +110 + | ++ + + + + + | + */ |
+ +111 + | ++ + + + + + | + public boolean isReturnTag() { |
+ +112 + | +
+
+3
+
+
+1. isReturnTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::isReturnTag → KILLED + +2. isReturnTag : negated conditional → KILLED + +3. isReturnTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.RETURN; |
+ +113 + | ++ + + + + + | + } |
+ +114 + | ++ + + + + + | +|
+ +115 + | ++ + + + + + | + /** |
+ +116 + | ++ + + + + + | + * Checks that the tag is an 'param' tag. |
+ +117 + | ++ + + + + + | + * |
+ +118 + | ++ + + + + + | + * @return whether the tag is an 'param' tag |
+ +119 + | ++ + + + + + | + */ |
+ +120 + | ++ + + + + + | + public boolean isParamTag() { |
+ +121 + | +
+
+3
+
+
+1. isParamTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::isParamTag → KILLED + +2. isParamTag : negated conditional → KILLED + +3. isParamTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.PARAM; |
+ +122 + | ++ + + + + + | + } |
+ +123 + | ++ + + + + + | +|
+ +124 + | ++ + + + + + | + /** |
+ +125 + | ++ + + + + + | + * Checks that the tag is an 'throws' or 'exception' tag. |
+ +126 + | ++ + + + + + | + * |
+ +127 + | ++ + + + + + | + * @return whether the tag is an 'throws' or 'exception' tag |
+ +128 + | ++ + + + + + | + */ |
+ +129 + | ++ + + + + + | + public boolean isThrowsTag() { |
+ +130 + | +
+
+4
+
+
+1. isThrowsTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::isThrowsTag → KILLED + +2. isThrowsTag : negated conditional → KILLED + +3. isThrowsTag : negated conditional → KILLED + +4. isThrowsTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.THROWS |
+ +131 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.EXCEPTION; |
+ +132 + | ++ + + + + + | + } |
+ +133 + | ++ + + + + + | +|
+ +134 + | ++ + + + + + | + /** |
+ +135 + | ++ + + + + + | + * Checks that the tag is a 'see' or 'inheritDoc' tag. |
+ +136 + | ++ + + + + + | + * |
+ +137 + | ++ + + + + + | + * @return whether the tag is a 'see' or 'inheritDoc' tag |
+ +138 + | ++ + + + + + | + */ |
+ +139 + | ++ + + + + + | + public boolean isSeeOrInheritDocTag() { |
+ +140 + | +
+
+4
+
+
+1. isSeeOrInheritDocTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::isSeeOrInheritDocTag → KILLED + +2. isSeeOrInheritDocTag : negated conditional → KILLED + +3. isSeeOrInheritDocTag : negated conditional → KILLED + +4. isSeeOrInheritDocTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.SEE || isInheritDocTag(); |
+ +141 + | ++ + + + + + | + } |
+ +142 + | ++ + + + + + | +|
+ +143 + | ++ + + + + + | + /** |
+ +144 + | ++ + + + + + | + * Checks that the tag is a 'inheritDoc' tag. |
+ +145 + | ++ + + + + + | + * |
+ +146 + | ++ + + + + + | + * @return whether the tag is a 'inheritDoc' tag |
+ +147 + | ++ + + + + + | + */ |
+ +148 + | ++ + + + + + | + public boolean isInheritDocTag() { |
+ +149 + | +
+
+3
+
+
+1. isInheritDocTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::isInheritDocTag → KILLED + +2. isInheritDocTag : negated conditional → KILLED + +3. isInheritDocTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.INHERIT_DOC; |
+ +150 + | ++ + + + + + | + } |
+ +151 + | ++ + + + + + | +|
+ +152 + | ++ + + + + + | + /** |
+ +153 + | ++ + + + + + | + * Checks that the tag can contain references to imported classes. |
+ +154 + | ++ + + + + + | + * |
+ +155 + | ++ + + + + + | + * @return whether the tag can contain references to imported classes |
+ +156 + | ++ + + + + + | + */ |
+ +157 + | ++ + + + + + | + public boolean canReferenceImports() { |
+ +158 + | +
+
+8
+
+
+1. canReferenceImports : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::canReferenceImports → KILLED + +2. canReferenceImports : negated conditional → KILLED + +3. canReferenceImports : negated conditional → KILLED + +4. canReferenceImports : negated conditional → KILLED + +5. canReferenceImports : negated conditional → KILLED + +6. canReferenceImports : negated conditional → KILLED + +7. canReferenceImports : negated conditional → KILLED + +8. canReferenceImports : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagInfo == JavadocTagInfo.SEE |
+ +159 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.LINK |
+ +160 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.VALUE |
+ +161 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.LINKPLAIN |
+ +162 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.THROWS |
+ +163 + | ++ + + + + + | + || tagInfo == JavadocTagInfo.EXCEPTION; |
+ +164 + | ++ + + + + + | + } |
+ +165 + | ++ + + + + + | +|
+ +166 + | ++ + + + + + | +} |
Mutations | ||
68 | ++ |
+
+
+
+ 1.1 |
+
77 | ++ |
+
+
+
+ 1.1 |
+
86 | ++ |
+
+
+
+ 1.1 |
+
95 | ++ |
+
+
+
+ 1.1 |
+
100 | ++ |
+
+
+
+ 1.1 2.2 |
+
112 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
121 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
130 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
140 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
149 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
158 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.List; |
+ +24 + | ++ + + + + + | +|
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +30 + | ++ + + + + + | +|
+ +31 + | ++ + + + + + | +/** |
+ +32 + | ++ + + + + + | + * <p> |
+ +33 + | ++ + + + + + | + * Checks the indentation of the continuation lines in at-clauses. That is whether the continued |
+ +34 + | ++ + + + + + | + * description of at clauses should be indented or not. If the text is not properly indented it |
+ +35 + | ++ + + + + + | + * throws a violation. A continuation line is when the description starts/spans past the line with |
+ +36 + | ++ + + + + + | + * the tag. Default indentation required is at least 4, but this can be changed with the help of |
+ +37 + | ++ + + + + + | + * properties below. |
+ +38 + | ++ + + + + + | + * </p> |
+ +39 + | ++ + + + + + | + * <ul> |
+ +40 + | ++ + + + + + | + * <li> |
+ +41 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +42 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +43 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +44 + | ++ + + + + + | + * Default value is {@code false}. |
+ +45 + | ++ + + + + + | + * </li> |
+ +46 + | ++ + + + + + | + * <li> |
+ +47 + | ++ + + + + + | + * Property {@code offset} - Specify how many spaces to use for new indentation level. |
+ +48 + | ++ + + + + + | + * Default value is {@code 4}. |
+ +49 + | ++ + + + + + | + * </li> |
+ +50 + | ++ + + + + + | + * </ul> |
+ +51 + | ++ + + + + + | + * <p> |
+ +52 + | ++ + + + + + | + * To configure the default check: |
+ +53 + | ++ + + + + + | + * </p> |
+ +54 + | ++ + + + + + | + * <pre> |
+ +55 + | ++ + + + + + | + * <module name="JavadocTagContinuationIndentation"/> |
+ +56 + | ++ + + + + + | + * </pre> |
+ +57 + | ++ + + + + + | + * <p> |
+ +58 + | ++ + + + + + | + * Example: |
+ +59 + | ++ + + + + + | + * </p> |
+ +60 + | ++ + + + + + | + * <pre> |
+ +61 + | ++ + + + + + | + * /** |
+ +62 + | ++ + + + + + | + * * @tag comment |
+ +63 + | ++ + + + + + | + * * Indentation spacing is 1. Line with violation |
+ +64 + | ++ + + + + + | + * * Indentation spacing is 2. Line with violation |
+ +65 + | ++ + + + + + | + * * Indentation spacing is 4. OK |
+ +66 + | ++ + + + + + | + * */ |
+ +67 + | ++ + + + + + | + * public class Test { |
+ +68 + | ++ + + + + + | + * } |
+ +69 + | ++ + + + + + | + * </pre> |
+ +70 + | ++ + + + + + | + * <p> |
+ +71 + | ++ + + + + + | + * To configure the check with two spaces indentation: |
+ +72 + | ++ + + + + + | + * </p> |
+ +73 + | ++ + + + + + | + * <pre> |
+ +74 + | ++ + + + + + | + * <module name="JavadocTagContinuationIndentation"> |
+ +75 + | ++ + + + + + | + * <property name="offset" value="2"/> |
+ +76 + | ++ + + + + + | + * </module> |
+ +77 + | ++ + + + + + | + * </pre> |
+ +78 + | ++ + + + + + | + * <p> |
+ +79 + | ++ + + + + + | + * Example: |
+ +80 + | ++ + + + + + | + * </p> |
+ +81 + | ++ + + + + + | + * <pre> |
+ +82 + | ++ + + + + + | + * /** |
+ +83 + | ++ + + + + + | + * * @tag comment |
+ +84 + | ++ + + + + + | + * * Indentation spacing is 0. Line with violation |
+ +85 + | ++ + + + + + | + * * Indentation spacing is 2. OK |
+ +86 + | ++ + + + + + | + * * Indentation spacing is 1. Line with violation |
+ +87 + | ++ + + + + + | + * */ |
+ +88 + | ++ + + + + + | + * public class Test { |
+ +89 + | ++ + + + + + | + * } |
+ +90 + | ++ + + + + + | + * </pre> |
+ +91 + | ++ + + + + + | + * <p> |
+ +92 + | ++ + + + + + | + * To configure the check to show violations for Tight-HTML Rules: |
+ +93 + | ++ + + + + + | + * </p> |
+ +94 + | ++ + + + + + | + * <pre> |
+ +95 + | ++ + + + + + | + * <module name="JavadocTagContinuationIndentation"> |
+ +96 + | ++ + + + + + | + * <property name="violateExecutionOnNonTightHtml" value="true"/> |
+ +97 + | ++ + + + + + | + * </module> |
+ +98 + | ++ + + + + + | + * </pre> |
+ +99 + | ++ + + + + + | + * <p> |
+ +100 + | ++ + + + + + | + * Example: |
+ +101 + | ++ + + + + + | + * </p> |
+ +102 + | ++ + + + + + | + * <pre> |
+ +103 + | ++ + + + + + | + * /** |
+ +104 + | ++ + + + + + | + * * <p> 'p' tag is unclosed. Line with violation, this html tag needs closing tag. |
+ +105 + | ++ + + + + + | + * * <p> 'p' tag is closed</p>. OK |
+ +106 + | ++ + + + + + | + * */ |
+ +107 + | ++ + + + + + | + * public class Test { |
+ +108 + | ++ + + + + + | + * } |
+ +109 + | ++ + + + + + | + * </pre> |
+ +110 + | ++ + + + + + | + * |
+ +111 + | ++ + + + + + | + * @since 6.0 |
+ +112 + | ++ + + + + + | + * |
+ +113 + | ++ + + + + + | + */ |
+ +114 + | ++ + + + + + | +@StatelessCheck |
+ +115 + | ++ + + + + + | +public class JavadocTagContinuationIndentationCheck extends AbstractJavadocCheck { |
+ +116 + | ++ + + + + + | +|
+ +117 + | ++ + + + + + | + /** |
+ +118 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +119 + | ++ + + + + + | + * file. |
+ +120 + | ++ + + + + + | + */ |
+ +121 + | ++ + + + + + | + public static final String MSG_KEY = "tag.continuation.indent"; |
+ +122 + | ++ + + + + + | +|
+ +123 + | ++ + + + + + | + /** Default tag continuation indentation. */ |
+ +124 + | ++ + + + + + | + private static final int DEFAULT_INDENTATION = 4; |
+ +125 + | ++ + + + + + | +|
+ +126 + | ++ + + + + + | + /** |
+ +127 + | ++ + + + + + | + * Specify how many spaces to use for new indentation level. |
+ +128 + | ++ + + + + + | + */ |
+ +129 + | ++ + + + + + | + private int offset = DEFAULT_INDENTATION; |
+ +130 + | ++ + + + + + | +|
+ +131 + | ++ + + + + + | + /** |
+ +132 + | ++ + + + + + | + * Setter to specify how many spaces to use for new indentation level. |
+ +133 + | ++ + + + + + | + * |
+ +134 + | ++ + + + + + | + * @param offset custom value. |
+ +135 + | ++ + + + + + | + */ |
+ +136 + | ++ + + + + + | + public void setOffset(int offset) { |
+ +137 + | ++ + + + + + | + this.offset = offset; |
+ +138 + | ++ + + + + + | + } |
+ +139 + | ++ + + + + + | +|
+ +140 + | ++ + + + + + | + @Override |
+ +141 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +142 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] {JavadocTokenTypes.DESCRIPTION }; |
+ +143 + | ++ + + + + + | + } |
+ +144 + | ++ + + + + + | +|
+ +145 + | ++ + + + + + | + @Override |
+ +146 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +147 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +148 + | ++ + + + + + | + } |
+ +149 + | ++ + + + + + | +|
+ +150 + | ++ + + + + + | + @Override |
+ +151 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +152 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!isInlineDescription(ast)) { |
+ +153 + | ++ + + + + + | + final List<DetailNode> textNodes = getAllNewlineNodes(ast); |
+ +154 + | ++ + + + + + | + for (DetailNode newlineNode : textNodes) { |
+ +155 + | ++ + + + + + | + final DetailNode textNode = JavadocUtil.getNextSibling(newlineNode); |
+ +156 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (textNode.getType() == JavadocTokenTypes.TEXT) { |
+ +157 + | ++ + + + + + | + final String text = textNode.getText(); |
+ +158 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!CommonUtil.isBlank(text.trim()) |
+ +159 + | +
+
+3
+
+
+1. visitJavadocToken : changed conditional boundary → KILLED + +2. visitJavadocToken : Replaced integer addition with subtraction → KILLED + +3. visitJavadocToken : negated conditional → KILLED + + + + |
+ && (text.length() <= offset |
+ +160 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ || !text.substring(1, offset + 1).trim().isEmpty())) { |
+ +161 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::log → KILLED + + + + |
+ log(textNode.getLineNumber(), MSG_KEY, offset); |
+ +162 + | ++ + + + + + | + } |
+ +163 + | ++ + + + + + | + } |
+ +164 + | ++ + + + + + | + } |
+ +165 + | ++ + + + + + | + } |
+ +166 + | ++ + + + + + | + } |
+ +167 + | ++ + + + + + | +|
+ +168 + | ++ + + + + + | + /** |
+ +169 + | ++ + + + + + | + * Finds and collects all NEWLINE nodes inside DESCRIPTION node. |
+ +170 + | ++ + + + + + | + * |
+ +171 + | ++ + + + + + | + * @param descriptionNode DESCRIPTION node. |
+ +172 + | ++ + + + + + | + * @return List with NEWLINE nodes. |
+ +173 + | ++ + + + + + | + */ |
+ +174 + | ++ + + + + + | + private static List<DetailNode> getAllNewlineNodes(DetailNode descriptionNode) { |
+ +175 + | +
+
+1
+
+
+1. getAllNewlineNodes : removed call to java/util/ArrayList::<init> → KILLED + + + + |
+ final List<DetailNode> textNodes = new ArrayList<>(); |
+ +176 + | ++ + + + + + | + DetailNode node = JavadocUtil.getFirstChild(descriptionNode); |
+ +177 + | +
+
+1
+
+
+1. getAllNewlineNodes : negated conditional → KILLED + + + + |
+ while (JavadocUtil.getNextSibling(node) != null) { |
+ +178 + | +
+
+1
+
+
+1. getAllNewlineNodes : negated conditional → KILLED + + + + |
+ if (node.getType() == JavadocTokenTypes.LEADING_ASTERISK) { |
+ +179 + | ++ + + + + + | + textNodes.add(node); |
+ +180 + | ++ + + + + + | + } |
+ +181 + | ++ + + + + + | + node = JavadocUtil.getNextSibling(node); |
+ +182 + | ++ + + + + + | + } |
+ +183 + | +
+
+1
+
+
+1. getAllNewlineNodes : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::getAllNewlineNodes to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return textNodes; |
+ +184 + | ++ + + + + + | + } |
+ +185 + | ++ + + + + + | +|
+ +186 + | ++ + + + + + | + /** |
+ +187 + | ++ + + + + + | + * Checks, if description node is a description of in-line tag. |
+ +188 + | ++ + + + + + | + * |
+ +189 + | ++ + + + + + | + * @param description DESCRIPTION node. |
+ +190 + | ++ + + + + + | + * @return true, if description node is a description of in-line tag. |
+ +191 + | ++ + + + + + | + */ |
+ +192 + | ++ + + + + + | + private static boolean isInlineDescription(DetailNode description) { |
+ +193 + | ++ + + + + + | + boolean isInline = false; |
+ +194 + | ++ + + + + + | + DetailNode inlineTag = description.getParent(); |
+ +195 + | +
+
+1
+
+
+1. isInlineDescription : negated conditional → KILLED + + + + |
+ while (inlineTag != null) { |
+ +196 + | +
+
+1
+
+
+1. isInlineDescription : negated conditional → KILLED + + + + |
+ if (inlineTag.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG) { |
+ +197 + | ++ + + + + + | + isInline = true; |
+ +198 + | ++ + + + + + | + break; |
+ +199 + | ++ + + + + + | + } |
+ +200 + | ++ + + + + + | + inlineTag = inlineTag.getParent(); |
+ +201 + | ++ + + + + + | + } |
+ +202 + | +
+
+3
+
+
+1. isInlineDescription : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::isInlineDescription → KILLED + +2. isInlineDescription : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheck::isInlineDescription → KILLED + +3. isInlineDescription : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return isInline; |
+ +203 + | ++ + + + + + | + } |
+ +204 + | ++ + + + + + | +|
+ +205 + | ++ + + + + + | +} |
Mutations | ||
142 | ++ |
+
+
+
+ 1.1 |
+
147 | ++ |
+
+
+
+ 1.1 |
+
152 | ++ |
+
+
+
+ 1.1 |
+
156 | ++ |
+
+
+
+ 1.1 |
+
158 | ++ |
+
+
+
+ 1.1 |
+
159 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
160 | ++ |
+
+
+
+ 1.1 |
+
161 | ++ |
+
+
+
+ 1.1 |
+
175 | ++ |
+
+
+
+ 1.1 |
+
177 | ++ |
+
+
+
+ 1.1 |
+
178 | ++ |
+
+
+
+ 1.1 |
+
183 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 |
+
196 | ++ |
+
+
+
+ 1.1 |
+
202 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.Map; |
+ +25 + | ++ + + + + + | +import java.util.stream.Collectors; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +31 + | ++ + + + + + | +|
+ +32 + | ++ + + + + + | +/** |
+ +33 + | ++ + + + + + | + * This enum defines the various Javadoc tags and there properties. |
+ +34 + | ++ + + + + + | + * |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * This class was modeled after documentation located at |
+ +37 + | ++ + + + + + | + * <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html"> |
+ +38 + | ++ + + + + + | + * javadoc</a> |
+ +39 + | ++ + + + + + | + * |
+ +40 + | ++ + + + + + | + * and |
+ +41 + | ++ + + + + + | + * |
+ +42 + | ++ + + + + + | + * <a href="https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html"> |
+ +43 + | ++ + + + + + | + * how to write</a>. |
+ +44 + | ++ + + + + + | + * </p> |
+ +45 + | ++ + + + + + | + * |
+ +46 + | ++ + + + + + | + * <p> |
+ +47 + | ++ + + + + + | + * Some of this documentation was a little incomplete (ex: valid placement of |
+ +48 + | ++ + + + + + | + * code, value, and literal tags). |
+ +49 + | ++ + + + + + | + * </p> |
+ +50 + | ++ + + + + + | + * |
+ +51 + | ++ + + + + + | + * <p> |
+ +52 + | ++ + + + + + | + * Whenever an inconsistency was found the author's judgment was used. |
+ +53 + | ++ + + + + + | + * </p> |
+ +54 + | ++ + + + + + | + * |
+ +55 + | ++ + + + + + | + * <p> |
+ +56 + | ++ + + + + + | + * For now, the number of required/optional tag arguments are not included |
+ +57 + | ++ + + + + + | + * because some Javadoc tags have very complex rules for determining this |
+ +58 + | ++ + + + + + | + * (ex: {@code {@value}} tag). |
+ +59 + | ++ + + + + + | + * </p> |
+ +60 + | ++ + + + + + | + * |
+ +61 + | ++ + + + + + | + * <p> |
+ +62 + | ++ + + + + + | + * Also, the {@link #isValidOn(DetailAST) isValidOn} method does not consider |
+ +63 + | ++ + + + + + | + * classes defined in a local code block (method, init block, etc.). |
+ +64 + | ++ + + + + + | + * </p> |
+ +65 + | ++ + + + + + | + * |
+ +66 + | ++ + + + + + | + */ |
+ +67 + | ++ + + + + + | +public enum JavadocTagInfo { |
+ +68 + | ++ + + + + + | +|
+ +69 + | ++ + + + + + | + /** |
+ +70 + | ++ + + + + + | + * {@code @author}. |
+ +71 + | ++ + + + + + | + */ |
+ +72 + | ++ + + + + + | + AUTHOR("@author", "author", Type.BLOCK) { |
+ +73 + | ++ + + + + + | +|
+ +74 + | ++ + + + + + | + @Override |
+ +75 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +76 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +77 + | +
+
+7
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$1::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : negated conditional → KILLED + +5. isValidOn : negated conditional → KILLED + +6. isValidOn : negated conditional → KILLED + +7. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.PACKAGE_DEF |
+ +78 + | ++ + + + + + | + || astType == TokenTypes.CLASS_DEF |
+ +79 + | ++ + + + + + | + || astType == TokenTypes.INTERFACE_DEF |
+ +80 + | ++ + + + + + | + || astType == TokenTypes.ENUM_DEF |
+ +81 + | ++ + + + + + | + || astType == TokenTypes.ANNOTATION_DEF; |
+ +82 + | ++ + + + + + | + } |
+ +83 + | ++ + + + + + | +|
+ +84 + | ++ + + + + + | + }, |
+ +85 + | ++ + + + + + | +|
+ +86 + | ++ + + + + + | + /** |
+ +87 + | ++ + + + + + | + * {@code {@code}}. |
+ +88 + | ++ + + + + + | + */ |
+ +89 + | ++ + + + + + | + CODE("{@code}", "code", Type.INLINE) { |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + @Override |
+ +92 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +93 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +94 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$2::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +95 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +96 + | ++ + + + + + | + } |
+ +97 + | ++ + + + + + | +|
+ +98 + | ++ + + + + + | + }, |
+ +99 + | ++ + + + + + | +|
+ +100 + | ++ + + + + + | + /** |
+ +101 + | ++ + + + + + | + * {@code {@docRoot}}. |
+ +102 + | ++ + + + + + | + */ |
+ +103 + | ++ + + + + + | + DOC_ROOT("{@docRoot}", "docRoot", Type.INLINE) { |
+ +104 + | ++ + + + + + | +|
+ +105 + | ++ + + + + + | + @Override |
+ +106 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +107 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +108 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$3::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +109 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +110 + | ++ + + + + + | + } |
+ +111 + | ++ + + + + + | +|
+ +112 + | ++ + + + + + | + }, |
+ +113 + | ++ + + + + + | +|
+ +114 + | ++ + + + + + | + /** |
+ +115 + | ++ + + + + + | + * {@code @deprecated}. |
+ +116 + | ++ + + + + + | + */ |
+ +117 + | ++ + + + + + | + DEPRECATED("@deprecated", "deprecated", Type.BLOCK) { |
+ +118 + | ++ + + + + + | +|
+ +119 + | ++ + + + + + | + @Override |
+ +120 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +121 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +122 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$4::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES_DEPRECATED, astType) >= 0 |
+ +123 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +124 + | ++ + + + + + | + } |
+ +125 + | ++ + + + + + | +|
+ +126 + | ++ + + + + + | + }, |
+ +127 + | ++ + + + + + | +|
+ +128 + | ++ + + + + + | + /** |
+ +129 + | ++ + + + + + | + * {@code @exception}. |
+ +130 + | ++ + + + + + | + */ |
+ +131 + | ++ + + + + + | + EXCEPTION("@exception", "exception", Type.BLOCK) { |
+ +132 + | ++ + + + + + | +|
+ +133 + | ++ + + + + + | + @Override |
+ +134 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +135 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +136 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$5::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.METHOD_DEF || astType == TokenTypes.CTOR_DEF; |
+ +137 + | ++ + + + + + | + } |
+ +138 + | ++ + + + + + | +|
+ +139 + | ++ + + + + + | + }, |
+ +140 + | ++ + + + + + | +|
+ +141 + | ++ + + + + + | + /** |
+ +142 + | ++ + + + + + | + * {@code {@inheritDoc}}. |
+ +143 + | ++ + + + + + | + */ |
+ +144 + | ++ + + + + + | + INHERIT_DOC("{@inheritDoc}", "inheritDoc", Type.INLINE) { |
+ +145 + | ++ + + + + + | +|
+ +146 + | ++ + + + + + | + @Override |
+ +147 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +148 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +149 + | ++ + + + + + | +|
+ +150 + | +
+
+3
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$6::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.METHOD_DEF |
+ +151 + | ++ + + + + + | + && ast.findFirstToken(TokenTypes.MODIFIERS) |
+ +152 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ .findFirstToken(TokenTypes.LITERAL_STATIC) == null |
+ +153 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && ScopeUtil.getScopeFromMods(ast |
+ +154 + | ++ + + + + + | + .findFirstToken(TokenTypes.MODIFIERS)) != Scope.PRIVATE; |
+ +155 + | ++ + + + + + | + } |
+ +156 + | ++ + + + + + | +|
+ +157 + | ++ + + + + + | + }, |
+ +158 + | ++ + + + + + | +|
+ +159 + | ++ + + + + + | + /** |
+ +160 + | ++ + + + + + | + * {@code {@link}}. |
+ +161 + | ++ + + + + + | + */ |
+ +162 + | ++ + + + + + | + LINK("{@link}", "link", Type.INLINE) { |
+ +163 + | ++ + + + + + | +|
+ +164 + | ++ + + + + + | + @Override |
+ +165 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +166 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +167 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$7::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +168 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +169 + | ++ + + + + + | + } |
+ +170 + | ++ + + + + + | +|
+ +171 + | ++ + + + + + | + }, |
+ +172 + | ++ + + + + + | +|
+ +173 + | ++ + + + + + | + /** |
+ +174 + | ++ + + + + + | + * {@code {@linkplain}}. |
+ +175 + | ++ + + + + + | + */ |
+ +176 + | ++ + + + + + | + LINKPLAIN("{@linkplain}", "linkplain", Type.INLINE) { |
+ +177 + | ++ + + + + + | +|
+ +178 + | ++ + + + + + | + @Override |
+ +179 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +180 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +181 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$8::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +182 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +183 + | ++ + + + + + | + } |
+ +184 + | ++ + + + + + | +|
+ +185 + | ++ + + + + + | + }, |
+ +186 + | ++ + + + + + | +|
+ +187 + | ++ + + + + + | + /** |
+ +188 + | ++ + + + + + | + * {@code {@literal}}. |
+ +189 + | ++ + + + + + | + */ |
+ +190 + | ++ + + + + + | + LITERAL("{@literal}", "literal", Type.INLINE) { |
+ +191 + | ++ + + + + + | +|
+ +192 + | ++ + + + + + | + @Override |
+ +193 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +194 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +195 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$9::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +196 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +197 + | ++ + + + + + | + } |
+ +198 + | ++ + + + + + | +|
+ +199 + | ++ + + + + + | + }, |
+ +200 + | ++ + + + + + | +|
+ +201 + | ++ + + + + + | + /** |
+ +202 + | ++ + + + + + | + * {@code @param}. |
+ +203 + | ++ + + + + + | + */ |
+ +204 + | ++ + + + + + | + PARAM("@param", "param", Type.BLOCK) { |
+ +205 + | ++ + + + + + | +|
+ +206 + | ++ + + + + + | + @Override |
+ +207 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +208 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +209 + | +
+
+6
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$10::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : negated conditional → KILLED + +5. isValidOn : negated conditional → KILLED + +6. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.CLASS_DEF |
+ +210 + | ++ + + + + + | + || astType == TokenTypes.INTERFACE_DEF |
+ +211 + | ++ + + + + + | + || astType == TokenTypes.METHOD_DEF |
+ +212 + | ++ + + + + + | + || astType == TokenTypes.CTOR_DEF; |
+ +213 + | ++ + + + + + | + } |
+ +214 + | ++ + + + + + | +|
+ +215 + | ++ + + + + + | + }, |
+ +216 + | ++ + + + + + | +|
+ +217 + | ++ + + + + + | + /** |
+ +218 + | ++ + + + + + | + * {@code @return}. |
+ +219 + | ++ + + + + + | + */ |
+ +220 + | ++ + + + + + | + RETURN("@return", "return", Type.BLOCK) { |
+ +221 + | ++ + + + + + | +|
+ +222 + | ++ + + + + + | + @Override |
+ +223 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +224 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +225 + | ++ + + + + + | + final DetailAST returnType = ast.findFirstToken(TokenTypes.TYPE); |
+ +226 + | ++ + + + + + | +|
+ +227 + | +
+
+3
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$11::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.METHOD_DEF |
+ +228 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && returnType.getFirstChild().getType() != TokenTypes.LITERAL_VOID; |
+ +229 + | ++ + + + + + | + } |
+ +230 + | ++ + + + + + | +|
+ +231 + | ++ + + + + + | + }, |
+ +232 + | ++ + + + + + | +|
+ +233 + | ++ + + + + + | + /** |
+ +234 + | ++ + + + + + | + * {@code @see}. |
+ +235 + | ++ + + + + + | + */ |
+ +236 + | ++ + + + + + | + SEE("@see", "see", Type.BLOCK) { |
+ +237 + | ++ + + + + + | +|
+ +238 + | ++ + + + + + | + @Override |
+ +239 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +240 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +241 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$12::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +242 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +243 + | ++ + + + + + | + } |
+ +244 + | ++ + + + + + | +|
+ +245 + | ++ + + + + + | + }, |
+ +246 + | ++ + + + + + | +|
+ +247 + | ++ + + + + + | + /** |
+ +248 + | ++ + + + + + | + * {@code @serial}. |
+ +249 + | ++ + + + + + | + */ |
+ +250 + | ++ + + + + + | + SERIAL("@serial", "serial", Type.BLOCK) { |
+ +251 + | ++ + + + + + | +|
+ +252 + | ++ + + + + + | + @Override |
+ +253 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +254 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +255 + | ++ + + + + + | +|
+ +256 + | +
+
+3
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$13::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.VARIABLE_DEF |
+ +257 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +258 + | ++ + + + + + | + } |
+ +259 + | ++ + + + + + | +|
+ +260 + | ++ + + + + + | + }, |
+ +261 + | ++ + + + + + | +|
+ +262 + | ++ + + + + + | + /** |
+ +263 + | ++ + + + + + | + * {@code @serialData}. |
+ +264 + | ++ + + + + + | + */ |
+ +265 + | ++ + + + + + | + SERIAL_DATA("@serialData", "serialData", Type.BLOCK) { |
+ +266 + | ++ + + + + + | +|
+ +267 + | ++ + + + + + | + @Override |
+ +268 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +269 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +270 + | ++ + + + + + | + final DetailAST methodNameAst = ast.findFirstToken(TokenTypes.IDENT); |
+ +271 + | ++ + + + + + | + final String methodName = methodNameAst.getText(); |
+ +272 + | ++ + + + + + | +|
+ +273 + | +
+
+3
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$14::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.METHOD_DEF |
+ +274 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && ("writeObject".equals(methodName) |
+ +275 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ || "readObject".equals(methodName) |
+ +276 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ || "writeExternal".equals(methodName) |
+ +277 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ || "readExternal".equals(methodName) |
+ +278 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ || "writeReplace".equals(methodName) |
+ +279 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ || "readResolve".equals(methodName)); |
+ +280 + | ++ + + + + + | + } |
+ +281 + | ++ + + + + + | +|
+ +282 + | ++ + + + + + | + }, |
+ +283 + | ++ + + + + + | +|
+ +284 + | ++ + + + + + | + /** |
+ +285 + | ++ + + + + + | + * {@code @serialField}. |
+ +286 + | ++ + + + + + | + */ |
+ +287 + | ++ + + + + + | + SERIAL_FIELD("@serialField", "serialField", Type.BLOCK) { |
+ +288 + | ++ + + + + + | +|
+ +289 + | ++ + + + + + | + @Override |
+ +290 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +291 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +292 + | ++ + + + + + | + final DetailAST varType = ast.findFirstToken(TokenTypes.TYPE); |
+ +293 + | ++ + + + + + | +|
+ +294 + | +
+
+3
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$15::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.VARIABLE_DEF |
+ +295 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && varType.getFirstChild().getType() == TokenTypes.ARRAY_DECLARATOR |
+ +296 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && "ObjectStreamField".equals(varType.getFirstChild().getText()); |
+ +297 + | ++ + + + + + | + } |
+ +298 + | ++ + + + + + | +|
+ +299 + | ++ + + + + + | + }, |
+ +300 + | ++ + + + + + | +|
+ +301 + | ++ + + + + + | + /** |
+ +302 + | ++ + + + + + | + * {@code @since}. |
+ +303 + | ++ + + + + + | + */ |
+ +304 + | ++ + + + + + | + SINCE("@since", "since", Type.BLOCK) { |
+ +305 + | ++ + + + + + | +|
+ +306 + | ++ + + + + + | + @Override |
+ +307 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +308 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +309 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$16::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +310 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +311 + | ++ + + + + + | + } |
+ +312 + | ++ + + + + + | +|
+ +313 + | ++ + + + + + | + }, |
+ +314 + | ++ + + + + + | +|
+ +315 + | ++ + + + + + | + /** |
+ +316 + | ++ + + + + + | + * {@code @throws}. |
+ +317 + | ++ + + + + + | + */ |
+ +318 + | ++ + + + + + | + THROWS("@throws", "throws", Type.BLOCK) { |
+ +319 + | ++ + + + + + | +|
+ +320 + | ++ + + + + + | + @Override |
+ +321 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +322 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +323 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$17::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.METHOD_DEF |
+ +324 + | ++ + + + + + | + || astType == TokenTypes.CTOR_DEF; |
+ +325 + | ++ + + + + + | + } |
+ +326 + | ++ + + + + + | +|
+ +327 + | ++ + + + + + | + }, |
+ +328 + | ++ + + + + + | +|
+ +329 + | ++ + + + + + | + /** |
+ +330 + | ++ + + + + + | + * {@code {@value}}. |
+ +331 + | ++ + + + + + | + */ |
+ +332 + | ++ + + + + + | + VALUE("{@value}", "value", Type.INLINE) { |
+ +333 + | ++ + + + + + | +|
+ +334 + | ++ + + + + + | + @Override |
+ +335 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +336 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +337 + | +
+
+4
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$18::isValidOn → KILLED + +2. isValidOn : changed conditional boundary → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return Arrays.binarySearch(DEF_TOKEN_TYPES, astType) >= 0 |
+ +338 + | +
+
+1
+
+
+1. isValidOn : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isLocalVariableDef(ast); |
+ +339 + | ++ + + + + + | + } |
+ +340 + | ++ + + + + + | +|
+ +341 + | ++ + + + + + | + }, |
+ +342 + | ++ + + + + + | +|
+ +343 + | ++ + + + + + | + /** |
+ +344 + | ++ + + + + + | + * {@code @version}. |
+ +345 + | ++ + + + + + | + */ |
+ +346 + | ++ + + + + + | + VERSION("@version", "version", Type.BLOCK) { |
+ +347 + | ++ + + + + + | +|
+ +348 + | ++ + + + + + | + @Override |
+ +349 + | ++ + + + + + | + public boolean isValidOn(final DetailAST ast) { |
+ +350 + | ++ + + + + + | + final int astType = ast.getType(); |
+ +351 + | +
+
+7
+
+
+1. isValidOn : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo$19::isValidOn → KILLED + +2. isValidOn : negated conditional → KILLED + +3. isValidOn : negated conditional → KILLED + +4. isValidOn : negated conditional → KILLED + +5. isValidOn : negated conditional → KILLED + +6. isValidOn : negated conditional → KILLED + +7. isValidOn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return astType == TokenTypes.PACKAGE_DEF |
+ +352 + | ++ + + + + + | + || astType == TokenTypes.CLASS_DEF |
+ +353 + | ++ + + + + + | + || astType == TokenTypes.INTERFACE_DEF |
+ +354 + | ++ + + + + + | + || astType == TokenTypes.ENUM_DEF |
+ +355 + | ++ + + + + + | + || astType == TokenTypes.ANNOTATION_DEF; |
+ +356 + | ++ + + + + + | + } |
+ +357 + | ++ + + + + + | +|
+ +358 + | ++ + + + + + | + }; |
+ +359 + | ++ + + + + + | +|
+ +360 + | ++ + + + + + | + /** Default token types for DEPRECATED Javadoc tag.*/ |
+ +361 + | ++ + + + + + | + private static final int[] DEF_TOKEN_TYPES_DEPRECATED = { |
+ +362 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +363 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +364 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF, |
+ +365 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +366 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +367 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +368 + | ++ + + + + + | + TokenTypes.ENUM_CONSTANT_DEF, |
+ +369 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +370 + | ++ + + + + + | + TokenTypes.ANNOTATION_FIELD_DEF, |
+ +371 + | ++ + + + + + | + }; |
+ +372 + | ++ + + + + + | +|
+ +373 + | ++ + + + + + | + /** Default token types.*/ |
+ +374 + | ++ + + + + + | + private static final int[] DEF_TOKEN_TYPES = { |
+ +375 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +376 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +377 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF, |
+ +378 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +379 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +380 + | ++ + + + + + | + TokenTypes.PACKAGE_DEF, |
+ +381 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +382 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +383 + | ++ + + + + + | + }; |
+ +384 + | ++ + + + + + | +|
+ +385 + | ++ + + + + + | + /** Holds tag text to tag enum mappings. **/ |
+ +386 + | ++ + + + + + | + private static final Map<String, JavadocTagInfo> TEXT_TO_TAG; |
+ +387 + | ++ + + + + + | + /** Holds tag name to tag enum mappings. **/ |
+ +388 + | ++ + + + + + | + private static final Map<String, JavadocTagInfo> NAME_TO_TAG; |
+ +389 + | ++ + + + + + | +|
+ +390 + | ++ + + + + + | + static { |
+ +391 + | ++ + + + + + | + TEXT_TO_TAG = Collections.unmodifiableMap(Arrays.stream(JavadocTagInfo.values()) |
+ +392 + | +
+
+1
+
+
+1. lambda$static$0 : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::lambda$static$0 to ( if (x != null) null else throw new RuntimeException ) → SURVIVED + + + + |
+ .collect(Collectors.toMap(JavadocTagInfo::getText, tagText -> tagText))); |
+ +393 + | ++ + + + + + | + NAME_TO_TAG = Collections.unmodifiableMap(Arrays.stream(JavadocTagInfo.values()) |
+ +394 + | +
+
+1
+
+
+1. lambda$static$1 : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::lambda$static$1 to ( if (x != null) null else throw new RuntimeException ) → SURVIVED + + + + |
+ .collect(Collectors.toMap(JavadocTagInfo::getName, tagName -> tagName))); |
+ +395 + | ++ + + + + + | +|
+ +396 + | ++ + + + + + | + // Arrays sorting for binary search |
+ +397 + | ++ + + + + + | + Arrays.sort(DEF_TOKEN_TYPES); |
+ +398 + | ++ + + + + + | + Arrays.sort(DEF_TOKEN_TYPES_DEPRECATED); |
+ +399 + | ++ + + + + + | + } |
+ +400 + | ++ + + + + + | +|
+ +401 + | ++ + + + + + | + /** The tag text. **/ |
+ +402 + | ++ + + + + + | + private final String text; |
+ +403 + | ++ + + + + + | + /** The tag name. **/ |
+ +404 + | ++ + + + + + | + private final String name; |
+ +405 + | ++ + + + + + | + /** The tag type. **/ |
+ +406 + | ++ + + + + + | + private final Type type; |
+ +407 + | ++ + + + + + | +|
+ +408 + | ++ + + + + + | + /** |
+ +409 + | ++ + + + + + | + * Sets the various properties of a Javadoc tag. |
+ +410 + | ++ + + + + + | + * |
+ +411 + | ++ + + + + + | + * @param text the tag text |
+ +412 + | ++ + + + + + | + * @param name the tag name |
+ +413 + | ++ + + + + + | + * @param type the type of tag |
+ +414 + | ++ + + + + + | + */ |
+ +415 + | ++ + + + + + | + JavadocTagInfo(final String text, final String name, |
+ +416 + | ++ + + + + + | + final Type type) { |
+ +417 + | ++ + + + + + | + this.text = text; |
+ +418 + | ++ + + + + + | + this.name = name; |
+ +419 + | ++ + + + + + | + this.type = type; |
+ +420 + | ++ + + + + + | + } |
+ +421 + | ++ + + + + + | +|
+ +422 + | ++ + + + + + | + /** |
+ +423 + | ++ + + + + + | + * Checks if a particular Javadoc tag is valid within a Javadoc block of a |
+ +424 + | ++ + + + + + | + * given AST. |
+ +425 + | ++ + + + + + | + * |
+ +426 + | ++ + + + + + | + * <p> |
+ +427 + | ++ + + + + + | + * If passing in a DetailAST representing a non-void METHOD_DEF |
+ +428 + | ++ + + + + + | + * {@code true } would be returned. If passing in a DetailAST |
+ +429 + | ++ + + + + + | + * representing a CLASS_DEF {@code false } would be returned because |
+ +430 + | ++ + + + + + | + * CLASS_DEF's cannot return a value. |
+ +431 + | ++ + + + + + | + * </p> |
+ +432 + | ++ + + + + + | + * |
+ +433 + | ++ + + + + + | + * @param ast the AST representing a type that can be Javadoc'd |
+ +434 + | ++ + + + + + | + * @return true if tag is valid. |
+ +435 + | ++ + + + + + | + */ |
+ +436 + | ++ + + + + + | + public abstract boolean isValidOn(DetailAST ast); |
+ +437 + | ++ + + + + + | +|
+ +438 + | ++ + + + + + | + /** |
+ +439 + | ++ + + + + + | + * Gets the tag text. |
+ +440 + | ++ + + + + + | + * |
+ +441 + | ++ + + + + + | + * @return the tag text |
+ +442 + | ++ + + + + + | + */ |
+ +443 + | ++ + + + + + | + public String getText() { |
+ +444 + | +
+
+1
+
+
+1. getText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::getText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return text; |
+ +445 + | ++ + + + + + | + } |
+ +446 + | ++ + + + + + | +|
+ +447 + | ++ + + + + + | + /** |
+ +448 + | ++ + + + + + | + * Gets the tag name. |
+ +449 + | ++ + + + + + | + * |
+ +450 + | ++ + + + + + | + * @return the tag name |
+ +451 + | ++ + + + + + | + */ |
+ +452 + | ++ + + + + + | + public String getName() { |
+ +453 + | +
+
+1
+
+
+1. getName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::getName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return name; |
+ +454 + | ++ + + + + + | + } |
+ +455 + | ++ + + + + + | +|
+ +456 + | ++ + + + + + | + /** |
+ +457 + | ++ + + + + + | + * Gets the Tag type defined by {@link Type Type}. |
+ +458 + | ++ + + + + + | + * |
+ +459 + | ++ + + + + + | + * @return the Tag type |
+ +460 + | ++ + + + + + | + */ |
+ +461 + | ++ + + + + + | + public Type getType() { |
+ +462 + | +
+
+1
+
+
+1. getType : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::getType to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return type; |
+ +463 + | ++ + + + + + | + } |
+ +464 + | ++ + + + + + | +|
+ +465 + | ++ + + + + + | + /** |
+ +466 + | ++ + + + + + | + * Returns a JavadocTag from the tag text. |
+ +467 + | ++ + + + + + | + * |
+ +468 + | ++ + + + + + | + * @param text String representing the tag text |
+ +469 + | ++ + + + + + | + * @return Returns a JavadocTag type from a String representing the tag |
+ +470 + | ++ + + + + + | + * @throws NullPointerException if the text is null |
+ +471 + | ++ + + + + + | + * @throws IllegalArgumentException if the text is not a valid tag |
+ +472 + | ++ + + + + + | + */ |
+ +473 + | ++ + + + + + | + public static JavadocTagInfo fromText(final String text) { |
+ +474 + | +
+
+1
+
+
+1. fromText : negated conditional → KILLED + + + + |
+ if (text == null) { |
+ +475 + | +
+
+1
+
+
+1. fromText : removed call to java/lang/IllegalArgumentException::<init> → KILLED + + + + |
+ throw new IllegalArgumentException("the text is null"); |
+ +476 + | ++ + + + + + | + } |
+ +477 + | ++ + + + + + | +|
+ +478 + | ++ + + + + + | + final JavadocTagInfo tag = TEXT_TO_TAG.get(text); |
+ +479 + | ++ + + + + + | +|
+ +480 + | +
+
+1
+
+
+1. fromText : negated conditional → KILLED + + + + |
+ if (tag == null) { |
+ +481 + | +
+
+2
+
+
+1. fromText : removed call to java/lang/StringBuilder::<init> → KILLED + +2. fromText : removed call to java/lang/IllegalArgumentException::<init> → KILLED + + + + |
+ throw new IllegalArgumentException("the text [" + text |
+ +482 + | ++ + + + + + | + + "] is not a valid Javadoc tag text"); |
+ +483 + | ++ + + + + + | + } |
+ +484 + | ++ + + + + + | +|
+ +485 + | +
+
+1
+
+
+1. fromText : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::fromText to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tag; |
+ +486 + | ++ + + + + + | + } |
+ +487 + | ++ + + + + + | +|
+ +488 + | ++ + + + + + | + /** |
+ +489 + | ++ + + + + + | + * Returns a JavadocTag from the tag name. |
+ +490 + | ++ + + + + + | + * |
+ +491 + | ++ + + + + + | + * @param name String name of the tag |
+ +492 + | ++ + + + + + | + * @return Returns a JavadocTag type from a String representing the tag |
+ +493 + | ++ + + + + + | + * @throws NullPointerException if the text is null |
+ +494 + | ++ + + + + + | + * @throws IllegalArgumentException if the text is not a valid tag. The name |
+ +495 + | ++ + + + + + | + * can be checked using {@link JavadocTagInfo#isValidName(String)} |
+ +496 + | ++ + + + + + | + */ |
+ +497 + | ++ + + + + + | + public static JavadocTagInfo fromName(final String name) { |
+ +498 + | +
+
+1
+
+
+1. fromName : negated conditional → KILLED + + + + |
+ if (name == null) { |
+ +499 + | +
+
+1
+
+
+1. fromName : removed call to java/lang/IllegalArgumentException::<init> → KILLED + + + + |
+ throw new IllegalArgumentException("the name is null"); |
+ +500 + | ++ + + + + + | + } |
+ +501 + | ++ + + + + + | +|
+ +502 + | ++ + + + + + | + final JavadocTagInfo tag = NAME_TO_TAG.get(name); |
+ +503 + | ++ + + + + + | +|
+ +504 + | +
+
+1
+
+
+1. fromName : negated conditional → KILLED + + + + |
+ if (tag == null) { |
+ +505 + | +
+
+2
+
+
+1. fromName : removed call to java/lang/StringBuilder::<init> → KILLED + +2. fromName : removed call to java/lang/IllegalArgumentException::<init> → KILLED + + + + |
+ throw new IllegalArgumentException("the name [" + name |
+ +506 + | ++ + + + + + | + + "] is not a valid Javadoc tag name"); |
+ +507 + | ++ + + + + + | + } |
+ +508 + | ++ + + + + + | +|
+ +509 + | +
+
+1
+
+
+1. fromName : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::fromName to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tag; |
+ +510 + | ++ + + + + + | + } |
+ +511 + | ++ + + + + + | +|
+ +512 + | ++ + + + + + | + /** |
+ +513 + | ++ + + + + + | + * Returns whether the provided name is for a valid tag. |
+ +514 + | ++ + + + + + | + * |
+ +515 + | ++ + + + + + | + * @param name the tag name to check. |
+ +516 + | ++ + + + + + | + * @return whether the provided name is for a valid tag. |
+ +517 + | ++ + + + + + | + */ |
+ +518 + | ++ + + + + + | + public static boolean isValidName(final String name) { |
+ +519 + | +
+
+3
+
+
+1. isValidName : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::isValidName → KILLED + +2. isValidName : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::isValidName → KILLED + +3. isValidName : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return NAME_TO_TAG.containsKey(name); |
+ +520 + | ++ + + + + + | + } |
+ +521 + | ++ + + + + + | +|
+ +522 + | ++ + + + + + | + @Override |
+ +523 + | ++ + + + + + | + public String toString() { |
+ +524 + | +
+
+2
+
+
+1. toString : removed call to java/lang/StringBuilder::<init> → KILLED + +2. toString : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo::toString to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return "text [" + text + "] name [" + name |
+ +525 + | ++ + + + + + | + + "] type [" + type + "]"; |
+ +526 + | ++ + + + + + | + } |
+ +527 + | ++ + + + + + | +|
+ +528 + | ++ + + + + + | + /** |
+ +529 + | ++ + + + + + | + * The Javadoc Type. |
+ +530 + | ++ + + + + + | + * |
+ +531 + | ++ + + + + + | + * <p>For example a {@code @param} tag is a block tag while a |
+ +532 + | ++ + + + + + | + * {@code {@link}} tag is a inline tag. |
+ +533 + | ++ + + + + + | + * |
+ +534 + | ++ + + + + + | + */ |
+ +535 + | ++ + + + + + | + public enum Type { |
+ +536 + | ++ + + + + + | +|
+ +537 + | ++ + + + + + | + /** Block type. **/ |
+ +538 + | ++ + + + + + | + BLOCK, |
+ +539 + | ++ + + + + + | +|
+ +540 + | ++ + + + + + | + /** Inline type. **/ |
+ +541 + | ++ + + + + + | + INLINE |
+ +542 + | ++ + + + + + | +|
+ +543 + | ++ + + + + + | + } |
+ +544 + | ++ + + + + + | +|
+ +545 + | ++ + + + + + | +} |
Mutations | ||
77 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
+
94 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
95 | ++ |
+
+
+
+ 1.1 |
+
108 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
109 | ++ |
+
+
+
+ 1.1 |
+
122 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
123 | ++ |
+
+
+
+ 1.1 |
+
136 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
150 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
152 | ++ |
+
+
+
+ 1.1 |
+
153 | ++ |
+
+
+
+ 1.1 |
+
167 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
168 | ++ |
+
+
+
+ 1.1 |
+
181 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
182 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
196 | ++ |
+
+
+
+ 1.1 |
+
209 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 6.6 |
+
227 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
228 | ++ |
+
+
+
+ 1.1 |
+
241 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
242 | ++ |
+
+
+
+ 1.1 |
+
256 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
257 | ++ |
+
+
+
+ 1.1 |
+
273 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
274 | ++ |
+
+
+
+ 1.1 |
+
275 | ++ |
+
+
+
+ 1.1 |
+
276 | ++ |
+
+
+
+ 1.1 |
+
277 | ++ |
+
+
+
+ 1.1 |
+
278 | ++ |
+
+
+
+ 1.1 |
+
279 | ++ |
+
+
+
+ 1.1 |
+
294 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
295 | ++ |
+
+
+
+ 1.1 |
+
296 | ++ |
+
+
+
+ 1.1 |
+
309 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
310 | ++ |
+
+
+
+ 1.1 |
+
323 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
337 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
338 | ++ |
+
+
+
+ 1.1 |
+
351 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
+
392 | ++ |
+
+
+
+ 1.1 |
+
394 | ++ |
+
+
+
+ 1.1 |
+
444 | ++ |
+
+
+
+ 1.1 |
+
453 | ++ |
+
+
+
+ 1.1 |
+
462 | ++ |
+
+
+
+ 1.1 |
+
474 | ++ |
+
+
+
+ 1.1 |
+
475 | ++ |
+
+
+
+ 1.1 |
+
480 | ++ |
+
+
+
+ 1.1 |
+
481 | ++ |
+
+
+
+ 1.1 2.2 |
+
485 | ++ |
+
+
+
+ 1.1 |
+
498 | ++ |
+
+
+
+ 1.1 |
+
499 | ++ |
+
+
+
+ 1.1 |
+
504 | ++ |
+
+
+
+ 1.1 |
+
505 | ++ |
+
+
+
+ 1.1 2.2 |
+
509 | ++ |
+
+
+
+ 1.1 |
+
519 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
524 | ++ |
+
+
+
+ 1.1 2.2 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +|
+ +26 + | ++ + + + + + | +/** |
+ +27 + | ++ + + + + + | + * Value object for combining the list of valid validTags with information |
+ +28 + | ++ + + + + + | + * about invalid validTags encountered in a certain Javadoc comment. |
+ +29 + | ++ + + + + + | + */ |
+ +30 + | ++ + + + + + | +public final class JavadocTags { |
+ +31 + | ++ + + + + + | +|
+ +32 + | ++ + + + + + | + /** Valid validTags. */ |
+ +33 + | ++ + + + + + | + private final List<JavadocTag> validTags; |
+ +34 + | ++ + + + + + | + /** Invalid validTags. */ |
+ +35 + | ++ + + + + + | + private final List<InvalidJavadocTag> invalidTags; |
+ +36 + | ++ + + + + + | +|
+ +37 + | ++ + + + + + | + /** |
+ +38 + | ++ + + + + + | + * Creates an instance. |
+ +39 + | ++ + + + + + | + * |
+ +40 + | ++ + + + + + | + * @param tags the list of valid tags |
+ +41 + | ++ + + + + + | + * @param invalidTags the list of invalid tags |
+ +42 + | ++ + + + + + | + */ |
+ +43 + | ++ + + + + + | + public JavadocTags(List<JavadocTag> tags, List<InvalidJavadocTag> invalidTags) { |
+ +44 + | +
+
+1
+
+
+1. + + |
+ final List<JavadocTag> validTagsCopy = new ArrayList<>(tags); |
+ +45 + | ++ + + + + + | + validTags = Collections.unmodifiableList(validTagsCopy); |
+ +46 + | +
+
+1
+
+
+1. + + |
+ final List<InvalidJavadocTag> invalidTagsCopy = new ArrayList<>(invalidTags); |
+ +47 + | ++ + + + + + | + this.invalidTags = Collections.unmodifiableList(invalidTagsCopy); |
+ +48 + | ++ + + + + + | + } |
+ +49 + | ++ + + + + + | +|
+ +50 + | ++ + + + + + | + /** |
+ +51 + | ++ + + + + + | + * Getter for validTags field. |
+ +52 + | ++ + + + + + | + * |
+ +53 + | ++ + + + + + | + * @return validTags field |
+ +54 + | ++ + + + + + | + */ |
+ +55 + | ++ + + + + + | + public List<JavadocTag> getValidTags() { |
+ +56 + | +
+
+1
+
+
+1. getValidTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTags::getValidTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return Collections.unmodifiableList(validTags); |
+ +57 + | ++ + + + + + | + } |
+ +58 + | ++ + + + + + | +|
+ +59 + | ++ + + + + + | + /** |
+ +60 + | ++ + + + + + | + * Getter for invalidTags field. |
+ +61 + | ++ + + + + + | + * |
+ +62 + | ++ + + + + + | + * @return invalidTags field |
+ +63 + | ++ + + + + + | + */ |
+ +64 + | ++ + + + + + | + public List<InvalidJavadocTag> getInvalidTags() { |
+ +65 + | +
+
+1
+
+
+1. getInvalidTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTags::getInvalidTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return Collections.unmodifiableList(invalidTags); |
+ +66 + | ++ + + + + + | + } |
+ +67 + | ++ + + + + + | +|
+ +68 + | ++ + + + + + | +} |
Mutations | ||
44 | ++ |
+
+
+
+ 1.1 |
+
46 | ++ |
+
+
+
+ 1.1 |
+
56 | ++ |
+
+
+
+ 1.1 |
+
65 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +26 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +33 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +34 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +35 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil; |
+ +36 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CheckUtil; |
+ +37 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +38 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +39 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +40 + | ++ + + + + + | +|
+ +41 + | ++ + + + + + | +/** |
+ +42 + | ++ + + + + + | + * <p> |
+ +43 + | ++ + + + + + | + * Checks the Javadoc comments for annotation/enum/class/interface definitions. By default, does |
+ +44 + | ++ + + + + + | + * not check for author or version tags. The scope to verify is specified using the {@code Scope} |
+ +45 + | ++ + + + + + | + * class and defaults to {@code Scope.PRIVATE}. To verify another scope, set property |
+ +46 + | ++ + + + + + | + * scope to one of the {@code Scope} constants. To define the format for an author |
+ +47 + | ++ + + + + + | + * tag or a version tag, set property authorFormat or versionFormat respectively to a |
+ +48 + | ++ + + + + + | + * <a href="https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html"> |
+ +49 + | ++ + + + + + | + * regular expression</a>. |
+ +50 + | ++ + + + + + | + * </p> |
+ +51 + | ++ + + + + + | + * <p> |
+ +52 + | ++ + + + + + | + * Does not perform checks for author and version tags for inner classes, |
+ +53 + | ++ + + + + + | + * as they should be redundant because of outer class. |
+ +54 + | ++ + + + + + | + * </p> |
+ +55 + | ++ + + + + + | + * <p> |
+ +56 + | ++ + + + + + | + * Error messages about type parameters for which no param tags are present |
+ +57 + | ++ + + + + + | + * can be suppressed by defining property {@code allowMissingParamTags}. |
+ +58 + | ++ + + + + + | + * </p> |
+ +59 + | ++ + + + + + | + * <ul> |
+ +60 + | ++ + + + + + | + * <li> |
+ +61 + | ++ + + + + + | + * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. |
+ +62 + | ++ + + + + + | + * Default value is {@code private}. |
+ +63 + | ++ + + + + + | + * </li> |
+ +64 + | ++ + + + + + | + * <li> |
+ +65 + | ++ + + + + + | + * Property {@code excludeScope} - Specify the visibility scope where Javadoc |
+ +66 + | ++ + + + + + | + * comments are not checked. |
+ +67 + | ++ + + + + + | + * Default value is {@code null}. |
+ +68 + | ++ + + + + + | + * </li> |
+ +69 + | ++ + + + + + | + * <li> |
+ +70 + | ++ + + + + + | + * Property {@code authorFormat} - Specify the pattern for {@code @author} tag. |
+ +71 + | ++ + + + + + | + * Default value is {@code null}. |
+ +72 + | ++ + + + + + | + * </li> |
+ +73 + | ++ + + + + + | + * <li> |
+ +74 + | ++ + + + + + | + * Property {@code versionFormat} - Specify the pattern for {@code @version} tag. |
+ +75 + | ++ + + + + + | + * Default value is {@code null}. |
+ +76 + | ++ + + + + + | + * </li> |
+ +77 + | ++ + + + + + | + * <li> |
+ +78 + | ++ + + + + + | + * Property {@code allowMissingParamTags} - Control whether to ignore violations |
+ +79 + | ++ + + + + + | + * when a class has type parameters but does not have matching param tags in the Javadoc. |
+ +80 + | ++ + + + + + | + * Default value is {@code false}. |
+ +81 + | ++ + + + + + | + * </li> |
+ +82 + | ++ + + + + + | + * <li> |
+ +83 + | ++ + + + + + | + * Property {@code allowUnknownTags} - Control whether to ignore violations when |
+ +84 + | ++ + + + + + | + * a Javadoc tag is not recognised. |
+ +85 + | ++ + + + + + | + * Default value is {@code false}. |
+ +86 + | ++ + + + + + | + * </li> |
+ +87 + | ++ + + + + + | + * <li> |
+ +88 + | ++ + + + + + | + * Property {@code allowedAnnotations} - Specify the list of annotations that allow |
+ +89 + | ++ + + + + + | + * missed documentation. Only short names are allowed, e.g. {@code Generated}. |
+ +90 + | ++ + + + + + | + * Default value is {@code Generated}. |
+ +91 + | ++ + + + + + | + * </li> |
+ +92 + | ++ + + + + + | + * <li> |
+ +93 + | ++ + + + + + | + * Property {@code tokens} - tokens to check |
+ +94 + | ++ + + + + + | + * Default value is: |
+ +95 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF"> |
+ +96 + | ++ + + + + + | + * INTERFACE_DEF</a>, |
+ +97 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF"> |
+ +98 + | ++ + + + + + | + * CLASS_DEF</a>, |
+ +99 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF"> |
+ +100 + | ++ + + + + + | + * ENUM_DEF</a>, |
+ +101 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF"> |
+ +102 + | ++ + + + + + | + * ANNOTATION_DEF</a>. |
+ +103 + | ++ + + + + + | + * </li> |
+ +104 + | ++ + + + + + | + * </ul> |
+ +105 + | ++ + + + + + | + * <p> |
+ +106 + | ++ + + + + + | + * To configure the default check: |
+ +107 + | ++ + + + + + | + * </p> |
+ +108 + | ++ + + + + + | + * <pre> |
+ +109 + | ++ + + + + + | + * <module name="JavadocType"/> |
+ +110 + | ++ + + + + + | + * </pre> |
+ +111 + | ++ + + + + + | + * <p> |
+ +112 + | ++ + + + + + | + * To configure the check for {@code public} scope: |
+ +113 + | ++ + + + + + | + * </p> |
+ +114 + | ++ + + + + + | + * <pre> |
+ +115 + | ++ + + + + + | + * <module name="JavadocType"> |
+ +116 + | ++ + + + + + | + * <property name="scope" value="public"/> |
+ +117 + | ++ + + + + + | + * </module> |
+ +118 + | ++ + + + + + | + * </pre> |
+ +119 + | ++ + + + + + | + * <p> |
+ +120 + | ++ + + + + + | + * To configure the check for an {@code @author} tag: |
+ +121 + | ++ + + + + + | + * </p> |
+ +122 + | ++ + + + + + | + * <pre> |
+ +123 + | ++ + + + + + | + * <module name="JavadocType"> |
+ +124 + | ++ + + + + + | + * <property name="authorFormat" value="\S"/> |
+ +125 + | ++ + + + + + | + * </module> |
+ +126 + | ++ + + + + + | + * </pre> |
+ +127 + | ++ + + + + + | + * <p> |
+ +128 + | ++ + + + + + | + * To configure the check for a CVS revision version tag: |
+ +129 + | ++ + + + + + | + * </p> |
+ +130 + | ++ + + + + + | + * <pre> |
+ +131 + | ++ + + + + + | + * <module name="JavadocType"> |
+ +132 + | ++ + + + + + | + * <property name="versionFormat" value="\$Revision.*\$"/> |
+ +133 + | ++ + + + + + | + * </module> |
+ +134 + | ++ + + + + + | + * </pre> |
+ +135 + | ++ + + + + + | + * <p> |
+ +136 + | ++ + + + + + | + * To configure the check for {@code private} classes only: |
+ +137 + | ++ + + + + + | + * </p> |
+ +138 + | ++ + + + + + | + * <pre> |
+ +139 + | ++ + + + + + | + * <module name="JavadocType"> |
+ +140 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +141 + | ++ + + + + + | + * <property name="excludeScope" value="package"/> |
+ +142 + | ++ + + + + + | + * </module> |
+ +143 + | ++ + + + + + | + * </pre> |
+ +144 + | ++ + + + + + | + * <p> |
+ +145 + | ++ + + + + + | + * Example that allows missing comments for classes annotated with |
+ +146 + | ++ + + + + + | + * {@code @SpringBootApplication} and {@code @Configuration}: |
+ +147 + | ++ + + + + + | + * </p> |
+ +148 + | ++ + + + + + | + * <pre> |
+ +149 + | ++ + + + + + | + * @SpringBootApplication // no violations about missing comment on class |
+ +150 + | ++ + + + + + | + * public class Application {} |
+ +151 + | ++ + + + + + | + * |
+ +152 + | ++ + + + + + | + * @Configuration // no violations about missing comment on class |
+ +153 + | ++ + + + + + | + * class DatabaseConfiguration {} |
+ +154 + | ++ + + + + + | + * </pre> |
+ +155 + | ++ + + + + + | + * <p> |
+ +156 + | ++ + + + + + | + * Use following configuration: |
+ +157 + | ++ + + + + + | + * </p> |
+ +158 + | ++ + + + + + | + * <pre> |
+ +159 + | ++ + + + + + | + * <module name="JavadocType"> |
+ +160 + | ++ + + + + + | + * <property name="allowedAnnotations" value="SpringBootApplication,Configuration"/> |
+ +161 + | ++ + + + + + | + * </module> |
+ +162 + | ++ + + + + + | + * </pre> |
+ +163 + | ++ + + + + + | + * |
+ +164 + | ++ + + + + + | + * @since 3.0 |
+ +165 + | ++ + + + + + | + * |
+ +166 + | ++ + + + + + | + */ |
+ +167 + | ++ + + + + + | +@StatelessCheck |
+ +168 + | ++ + + + + + | +public class JavadocTypeCheck |
+ +169 + | ++ + + + + + | + extends AbstractCheck { |
+ +170 + | ++ + + + + + | +|
+ +171 + | ++ + + + + + | + /** |
+ +172 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +173 + | ++ + + + + + | + * file. |
+ +174 + | ++ + + + + + | + */ |
+ +175 + | ++ + + + + + | + public static final String MSG_UNKNOWN_TAG = "javadoc.unknownTag"; |
+ +176 + | ++ + + + + + | +|
+ +177 + | ++ + + + + + | + /** |
+ +178 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +179 + | ++ + + + + + | + * file. |
+ +180 + | ++ + + + + + | + */ |
+ +181 + | ++ + + + + + | + public static final String MSG_TAG_FORMAT = "type.tagFormat"; |
+ +182 + | ++ + + + + + | +|
+ +183 + | ++ + + + + + | + /** |
+ +184 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +185 + | ++ + + + + + | + * file. |
+ +186 + | ++ + + + + + | + */ |
+ +187 + | ++ + + + + + | + public static final String MSG_MISSING_TAG = "type.missingTag"; |
+ +188 + | ++ + + + + + | +|
+ +189 + | ++ + + + + + | + /** |
+ +190 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +191 + | ++ + + + + + | + * file. |
+ +192 + | ++ + + + + + | + */ |
+ +193 + | ++ + + + + + | + public static final String MSG_UNUSED_TAG = "javadoc.unusedTag"; |
+ +194 + | ++ + + + + + | +|
+ +195 + | ++ + + + + + | + /** |
+ +196 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +197 + | ++ + + + + + | + * file. |
+ +198 + | ++ + + + + + | + */ |
+ +199 + | ++ + + + + + | + public static final String MSG_UNUSED_TAG_GENERAL = "javadoc.unusedTagGeneral"; |
+ +200 + | ++ + + + + + | +|
+ +201 + | ++ + + + + + | + /** Open angle bracket literal. */ |
+ +202 + | ++ + + + + + | + private static final String OPEN_ANGLE_BRACKET = "<"; |
+ +203 + | ++ + + + + + | +|
+ +204 + | ++ + + + + + | + /** Close angle bracket literal. */ |
+ +205 + | ++ + + + + + | + private static final String CLOSE_ANGLE_BRACKET = ">"; |
+ +206 + | ++ + + + + + | +|
+ +207 + | ++ + + + + + | + /** Pattern to match type name within angle brackets in javadoc param tag. */ |
+ +208 + | ++ + + + + + | + private static final Pattern TYPE_NAME_IN_JAVADOC_TAG = |
+ +209 + | ++ + + + + + | + Pattern.compile("\\s*<([^>]+)>.*"); |
+ +210 + | ++ + + + + + | +|
+ +211 + | ++ + + + + + | + /** Pattern to split type name field in javadoc param tag. */ |
+ +212 + | ++ + + + + + | + private static final Pattern TYPE_NAME_IN_JAVADOC_TAG_SPLITTER = |
+ +213 + | ++ + + + + + | + Pattern.compile("\\s+"); |
+ +214 + | ++ + + + + + | +|
+ +215 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +216 + | ++ + + + + + | + private Scope scope = Scope.PRIVATE; |
+ +217 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +218 + | ++ + + + + + | + private Scope excludeScope; |
+ +219 + | ++ + + + + + | + /** Specify the pattern for {@code @author} tag. */ |
+ +220 + | ++ + + + + + | + private Pattern authorFormat; |
+ +221 + | ++ + + + + + | + /** Specify the pattern for {@code @version} tag. */ |
+ +222 + | ++ + + + + + | + private Pattern versionFormat; |
+ +223 + | ++ + + + + + | + /** |
+ +224 + | ++ + + + + + | + * Control whether to ignore violations when a class has type parameters but |
+ +225 + | ++ + + + + + | + * does not have matching param tags in the Javadoc. |
+ +226 + | ++ + + + + + | + */ |
+ +227 + | ++ + + + + + | + private boolean allowMissingParamTags; |
+ +228 + | ++ + + + + + | + /** Control whether to ignore violations when a Javadoc tag is not recognised. */ |
+ +229 + | ++ + + + + + | + private boolean allowUnknownTags; |
+ +230 + | ++ + + + + + | +|
+ +231 + | ++ + + + + + | + /** |
+ +232 + | ++ + + + + + | + * Specify the list of annotations that allow missed documentation. |
+ +233 + | ++ + + + + + | + * Only short names are allowed, e.g. {@code Generated}. |
+ +234 + | ++ + + + + + | + */ |
+ +235 + | ++ + + + + + | + private List<String> allowedAnnotations = Collections.singletonList("Generated"); |
+ +236 + | ++ + + + + + | +|
+ +237 + | ++ + + + + + | + /** |
+ +238 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +239 + | ++ + + + + + | + * |
+ +240 + | ++ + + + + + | + * @param scope a scope. |
+ +241 + | ++ + + + + + | + */ |
+ +242 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +243 + | ++ + + + + + | + this.scope = scope; |
+ +244 + | ++ + + + + + | + } |
+ +245 + | ++ + + + + + | +|
+ +246 + | ++ + + + + + | + /** |
+ +247 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +248 + | ++ + + + + + | + * |
+ +249 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +250 + | ++ + + + + + | + */ |
+ +251 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +252 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +253 + | ++ + + + + + | + } |
+ +254 + | ++ + + + + + | +|
+ +255 + | ++ + + + + + | + /** |
+ +256 + | ++ + + + + + | + * Setter to specify the pattern for {@code @author} tag. |
+ +257 + | ++ + + + + + | + * |
+ +258 + | ++ + + + + + | + * @param pattern a pattern. |
+ +259 + | ++ + + + + + | + */ |
+ +260 + | ++ + + + + + | + public void setAuthorFormat(Pattern pattern) { |
+ +261 + | ++ + + + + + | + authorFormat = pattern; |
+ +262 + | ++ + + + + + | + } |
+ +263 + | ++ + + + + + | +|
+ +264 + | ++ + + + + + | + /** |
+ +265 + | ++ + + + + + | + * Setter to specify the pattern for {@code @version} tag. |
+ +266 + | ++ + + + + + | + * |
+ +267 + | ++ + + + + + | + * @param pattern a pattern. |
+ +268 + | ++ + + + + + | + */ |
+ +269 + | ++ + + + + + | + public void setVersionFormat(Pattern pattern) { |
+ +270 + | ++ + + + + + | + versionFormat = pattern; |
+ +271 + | ++ + + + + + | + } |
+ +272 + | ++ + + + + + | +|
+ +273 + | ++ + + + + + | + /** |
+ +274 + | ++ + + + + + | + * Setter to control whether to ignore violations when a class has type parameters but |
+ +275 + | ++ + + + + + | + * does not have matching param tags in the Javadoc. |
+ +276 + | ++ + + + + + | + * |
+ +277 + | ++ + + + + + | + * @param flag a {@code Boolean} value |
+ +278 + | ++ + + + + + | + */ |
+ +279 + | ++ + + + + + | + public void setAllowMissingParamTags(boolean flag) { |
+ +280 + | ++ + + + + + | + allowMissingParamTags = flag; |
+ +281 + | ++ + + + + + | + } |
+ +282 + | ++ + + + + + | +|
+ +283 + | ++ + + + + + | + /** |
+ +284 + | ++ + + + + + | + * Setter to control whether to ignore violations when a Javadoc tag is not recognised. |
+ +285 + | ++ + + + + + | + * |
+ +286 + | ++ + + + + + | + * @param flag a {@code Boolean} value |
+ +287 + | ++ + + + + + | + */ |
+ +288 + | ++ + + + + + | + public void setAllowUnknownTags(boolean flag) { |
+ +289 + | ++ + + + + + | + allowUnknownTags = flag; |
+ +290 + | ++ + + + + + | + } |
+ +291 + | ++ + + + + + | +|
+ +292 + | ++ + + + + + | + /** |
+ +293 + | ++ + + + + + | + * Setter to specify the list of annotations that allow missed documentation. |
+ +294 + | ++ + + + + + | + * Only short names are allowed, e.g. {@code Generated}. |
+ +295 + | ++ + + + + + | + * |
+ +296 + | ++ + + + + + | + * @param userAnnotations user's value. |
+ +297 + | ++ + + + + + | + */ |
+ +298 + | ++ + + + + + | + public void setAllowedAnnotations(String... userAnnotations) { |
+ +299 + | ++ + + + + + | + allowedAnnotations = Arrays.asList(userAnnotations); |
+ +300 + | ++ + + + + + | + } |
+ +301 + | ++ + + + + + | +|
+ +302 + | ++ + + + + + | + @Override |
+ +303 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +304 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +305 + | ++ + + + + + | + } |
+ +306 + | ++ + + + + + | +|
+ +307 + | ++ + + + + + | + @Override |
+ +308 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +309 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +310 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +311 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +312 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +313 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +314 + | ++ + + + + + | + }; |
+ +315 + | ++ + + + + + | + } |
+ +316 + | ++ + + + + + | +|
+ +317 + | ++ + + + + + | + @Override |
+ +318 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +319 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +320 + | ++ + + + + + | + } |
+ +321 + | ++ + + + + + | +|
+ +322 + | ++ + + + + + | + @Override |
+ +323 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +324 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast)) { |
+ +325 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +326 + | ++ + + + + + | + final int lineNo = ast.getLineNo(); |
+ +327 + | ++ + + + + + | + final TextBlock textBlock = contents.getJavadocBefore(lineNo); |
+ +328 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (textBlock != null) { |
+ +329 + | ++ + + + + + | + final List<JavadocTag> tags = getJavadocTags(textBlock); |
+ +330 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isOuterMostType(ast)) { |
+ +331 + | ++ + + + + + | + // don't check author/version for inner classes |
+ +332 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::checkTag → KILLED + + + + |
+ checkTag(ast, tags, JavadocTagInfo.AUTHOR.getName(), |
+ +333 + | ++ + + + + + | + authorFormat); |
+ +334 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::checkTag → KILLED + + + + |
+ checkTag(ast, tags, JavadocTagInfo.VERSION.getName(), |
+ +335 + | ++ + + + + + | + versionFormat); |
+ +336 + | ++ + + + + + | + } |
+ +337 + | ++ + + + + + | +|
+ +338 + | ++ + + + + + | + final List<String> typeParamNames = |
+ +339 + | ++ + + + + + | + CheckUtil.getTypeParameterNames(ast); |
+ +340 + | ++ + + + + + | +|
+ +341 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (!allowMissingParamTags) { |
+ +342 + | ++ + + + + + | + // Check type parameters that should exist, do |
+ +343 + | ++ + + + + + | + for (final String typeParamName : typeParamNames) { |
+ +344 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::checkTypeParamTag → KILLED + + + + |
+ checkTypeParamTag( |
+ +345 + | ++ + + + + + | + ast, tags, typeParamName); |
+ +346 + | ++ + + + + + | + } |
+ +347 + | ++ + + + + + | + } |
+ +348 + | ++ + + + + + | +|
+ +349 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::checkUnusedTypeParamTags → KILLED + + + + |
+ checkUnusedTypeParamTags(tags, typeParamNames); |
+ +350 + | ++ + + + + + | + } |
+ +351 + | ++ + + + + + | + } |
+ +352 + | ++ + + + + + | + } |
+ +353 + | ++ + + + + + | +|
+ +354 + | ++ + + + + + | + /** |
+ +355 + | ++ + + + + + | + * Whether we should check this node. |
+ +356 + | ++ + + + + + | + * |
+ +357 + | ++ + + + + + | + * @param ast a given node. |
+ +358 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +359 + | ++ + + + + + | + */ |
+ +360 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast) { |
+ +361 + | ++ + + + + + | + final Scope customScope; |
+ +362 + | ++ + + + + + | +|
+ +363 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
+ +364 + | ++ + + + + + | + customScope = Scope.PUBLIC; |
+ +365 + | ++ + + + + + | + } |
+ +366 + | ++ + + + + + | + else { |
+ +367 + | ++ + + + + + | + final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); |
+ +368 + | ++ + + + + + | + customScope = ScopeUtil.getScopeFromMods(mods); |
+ +369 + | ++ + + + + + | + } |
+ +370 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +371 + | ++ + + + + + | +|
+ +372 + | +
+
+4
+
+
+1. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::shouldCheck → KILLED + +2. shouldCheck : negated conditional → KILLED + +3. shouldCheck : negated conditional → KILLED + +4. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return customScope.isIn(scope) |
+ +373 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ && (surroundingScope == null || surroundingScope.isIn(scope)) |
+ +374 + | ++ + + + + + | + && (excludeScope == null |
+ +375 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ || !customScope.isIn(excludeScope) |
+ +376 + | ++ + + + + + | + || surroundingScope != null |
+ +377 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !surroundingScope.isIn(excludeScope)) |
+ +378 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !AnnotationUtil.containsAnnotation(ast, allowedAnnotations); |
+ +379 + | ++ + + + + + | + } |
+ +380 + | ++ + + + + + | +|
+ +381 + | ++ + + + + + | + /** |
+ +382 + | ++ + + + + + | + * Gets all standalone tags from a given javadoc. |
+ +383 + | ++ + + + + + | + * |
+ +384 + | ++ + + + + + | + * @param textBlock the Javadoc comment to process. |
+ +385 + | ++ + + + + + | + * @return all standalone tags from the given javadoc. |
+ +386 + | ++ + + + + + | + */ |
+ +387 + | ++ + + + + + | + private List<JavadocTag> getJavadocTags(TextBlock textBlock) { |
+ +388 + | ++ + + + + + | + final JavadocTags tags = JavadocUtil.getJavadocTags(textBlock, |
+ +389 + | ++ + + + + + | + JavadocUtil.JavadocTagType.BLOCK); |
+ +390 + | +
+
+1
+
+
+1. getJavadocTags : negated conditional → KILLED + + + + |
+ if (!allowUnknownTags) { |
+ +391 + | ++ + + + + + | + for (final InvalidJavadocTag tag : tags.getInvalidTags()) { |
+ +392 + | +
+
+1
+
+
+1. getJavadocTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::log → KILLED + + + + |
+ log(tag.getLine(), tag.getCol(), MSG_UNKNOWN_TAG, |
+ +393 + | ++ + + + + + | + tag.getName()); |
+ +394 + | ++ + + + + + | + } |
+ +395 + | ++ + + + + + | + } |
+ +396 + | +
+
+1
+
+
+1. getJavadocTags : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::getJavadocTags to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags.getValidTags(); |
+ +397 + | ++ + + + + + | + } |
+ +398 + | ++ + + + + + | +|
+ +399 + | ++ + + + + + | + /** |
+ +400 + | ++ + + + + + | + * Verifies that a type definition has a required tag. |
+ +401 + | ++ + + + + + | + * |
+ +402 + | ++ + + + + + | + * @param ast the AST node for the type definition. |
+ +403 + | ++ + + + + + | + * @param tags tags from the Javadoc comment for the type definition. |
+ +404 + | ++ + + + + + | + * @param tagName the required tag name. |
+ +405 + | ++ + + + + + | + * @param formatPattern regexp for the tag value. |
+ +406 + | ++ + + + + + | + */ |
+ +407 + | ++ + + + + + | + private void checkTag(DetailAST ast, List<JavadocTag> tags, String tagName, |
+ +408 + | ++ + + + + + | + Pattern formatPattern) { |
+ +409 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (formatPattern != null) { |
+ +410 + | ++ + + + + + | + boolean hasTag = false; |
+ +411 + | ++ + + + + + | + final String tagPrefix = "@"; |
+ +412 + | +
+
+4
+
+
+1. checkTag : changed conditional boundary → KILLED + +2. checkTag : Changed increment from -1 to 1 → KILLED + +3. checkTag : Replaced integer subtraction with addition → KILLED + +4. checkTag : negated conditional → KILLED + + + + |
+ for (int i = tags.size() - 1; i >= 0; i--) { |
+ +413 + | ++ + + + + + | + final JavadocTag tag = tags.get(i); |
+ +414 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (tag.getTagName().equals(tagName)) { |
+ +415 + | ++ + + + + + | + hasTag = true; |
+ +416 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (!formatPattern.matcher(tag.getFirstArg()).find()) { |
+ +417 + | +
+
+2
+
+
+1. checkTag : removed call to java/lang/StringBuilder::<init> → KILLED + +2. checkTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::log → KILLED + + + + |
+ log(ast, MSG_TAG_FORMAT, tagPrefix + tagName, formatPattern.pattern()); |
+ +418 + | ++ + + + + + | + } |
+ +419 + | ++ + + + + + | + } |
+ +420 + | ++ + + + + + | + } |
+ +421 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (!hasTag) { |
+ +422 + | +
+
+2
+
+
+1. checkTag : removed call to java/lang/StringBuilder::<init> → KILLED + +2. checkTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::log → KILLED + + + + |
+ log(ast, MSG_MISSING_TAG, tagPrefix + tagName); |
+ +423 + | ++ + + + + + | + } |
+ +424 + | ++ + + + + + | + } |
+ +425 + | ++ + + + + + | + } |
+ +426 + | ++ + + + + + | +|
+ +427 + | ++ + + + + + | + /** |
+ +428 + | ++ + + + + + | + * Verifies that a type definition has the specified param tag for |
+ +429 + | ++ + + + + + | + * the specified type parameter name. |
+ +430 + | ++ + + + + + | + * |
+ +431 + | ++ + + + + + | + * @param ast the AST node for the type definition. |
+ +432 + | ++ + + + + + | + * @param tags tags from the Javadoc comment for the type definition. |
+ +433 + | ++ + + + + + | + * @param typeParamName the name of the type parameter |
+ +434 + | ++ + + + + + | + */ |
+ +435 + | ++ + + + + + | + private void checkTypeParamTag(final DetailAST ast, |
+ +436 + | ++ + + + + + | + final List<JavadocTag> tags, final String typeParamName) { |
+ +437 + | ++ + + + + + | + boolean found = false; |
+ +438 + | +
+
+4
+
+
+1. checkTypeParamTag : changed conditional boundary → KILLED + +2. checkTypeParamTag : Changed increment from -1 to 1 → KILLED + +3. checkTypeParamTag : Replaced integer subtraction with addition → KILLED + +4. checkTypeParamTag : negated conditional → KILLED + + + + |
+ for (int i = tags.size() - 1; i >= 0; i--) { |
+ +439 + | ++ + + + + + | + final JavadocTag tag = tags.get(i); |
+ +440 + | +
+
+1
+
+
+1. checkTypeParamTag : negated conditional → KILLED + + + + |
+ if (tag.isParamTag() |
+ +441 + | +
+
+2
+
+
+1. checkTypeParamTag : removed call to java/lang/StringBuilder::<init> → KILLED + +2. checkTypeParamTag : negated conditional → KILLED + + + + |
+ && tag.getFirstArg().indexOf(OPEN_ANGLE_BRACKET |
+ +442 + | ++ + + + + + | + + typeParamName + CLOSE_ANGLE_BRACKET) == 0) { |
+ +443 + | ++ + + + + + | + found = true; |
+ +444 + | ++ + + + + + | + break; |
+ +445 + | ++ + + + + + | + } |
+ +446 + | ++ + + + + + | + } |
+ +447 + | +
+
+1
+
+
+1. checkTypeParamTag : negated conditional → KILLED + + + + |
+ if (!found) { |
+ +448 + | +
+
+2
+
+
+1. checkTypeParamTag : removed call to java/lang/StringBuilder::<init> → KILLED + +2. checkTypeParamTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::log → KILLED + + + + |
+ log(ast, MSG_MISSING_TAG, JavadocTagInfo.PARAM.getText() |
+ +449 + | ++ + + + + + | + + " " + OPEN_ANGLE_BRACKET + typeParamName + CLOSE_ANGLE_BRACKET); |
+ +450 + | ++ + + + + + | + } |
+ +451 + | ++ + + + + + | + } |
+ +452 + | ++ + + + + + | +|
+ +453 + | ++ + + + + + | + /** |
+ +454 + | ++ + + + + + | + * Checks for unused param tags for type parameters. |
+ +455 + | ++ + + + + + | + * |
+ +456 + | ++ + + + + + | + * @param tags tags from the Javadoc comment for the type definition. |
+ +457 + | ++ + + + + + | + * @param typeParamNames names of type parameters |
+ +458 + | ++ + + + + + | + */ |
+ +459 + | ++ + + + + + | + private void checkUnusedTypeParamTags( |
+ +460 + | ++ + + + + + | + final List<JavadocTag> tags, |
+ +461 + | ++ + + + + + | + final List<String> typeParamNames) { |
+ +462 + | +
+
+4
+
+
+1. checkUnusedTypeParamTags : changed conditional boundary → KILLED + +2. checkUnusedTypeParamTags : Changed increment from -1 to 1 → KILLED + +3. checkUnusedTypeParamTags : Replaced integer subtraction with addition → KILLED + +4. checkUnusedTypeParamTags : negated conditional → KILLED + + + + |
+ for (int i = tags.size() - 1; i >= 0; i--) { |
+ +463 + | ++ + + + + + | + final JavadocTag tag = tags.get(i); |
+ +464 + | +
+
+1
+
+
+1. checkUnusedTypeParamTags : negated conditional → KILLED + + + + |
+ if (tag.isParamTag()) { |
+ +465 + | ++ + + + + + | + final String typeParamName = extractTypeParamNameFromTag(tag); |
+ +466 + | ++ + + + + + | +|
+ +467 + | +
+
+1
+
+
+1. checkUnusedTypeParamTags : negated conditional → KILLED + + + + |
+ if (!typeParamNames.contains(typeParamName)) { |
+ +468 + | +
+
+1
+
+
+1. checkUnusedTypeParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::log → KILLED + + + + |
+ log(tag.getLineNo(), tag.getColumnNo(), |
+ +469 + | ++ + + + + + | + MSG_UNUSED_TAG, |
+ +470 + | +
+
+1
+
+
+1. checkUnusedTypeParamTags : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ JavadocTagInfo.PARAM.getText(), |
+ +471 + | ++ + + + + + | + OPEN_ANGLE_BRACKET + typeParamName + CLOSE_ANGLE_BRACKET); |
+ +472 + | ++ + + + + + | + } |
+ +473 + | ++ + + + + + | + } |
+ +474 + | ++ + + + + + | + } |
+ +475 + | ++ + + + + + | + } |
+ +476 + | ++ + + + + + | +|
+ +477 + | ++ + + + + + | + /** |
+ +478 + | ++ + + + + + | + * Extracts type parameter name from tag. |
+ +479 + | ++ + + + + + | + * |
+ +480 + | ++ + + + + + | + * @param tag javadoc tag to extract parameter name |
+ +481 + | ++ + + + + + | + * @return extracts type parameter name from tag |
+ +482 + | ++ + + + + + | + */ |
+ +483 + | ++ + + + + + | + private static String extractTypeParamNameFromTag(JavadocTag tag) { |
+ +484 + | ++ + + + + + | + final String typeParamName; |
+ +485 + | ++ + + + + + | + final Matcher matchInAngleBrackets = |
+ +486 + | ++ + + + + + | + TYPE_NAME_IN_JAVADOC_TAG.matcher(tag.getFirstArg()); |
+ +487 + | +
+
+1
+
+
+1. extractTypeParamNameFromTag : negated conditional → KILLED + + + + |
+ if (matchInAngleBrackets.find()) { |
+ +488 + | ++ + + + + + | + typeParamName = matchInAngleBrackets.group(1).trim(); |
+ +489 + | ++ + + + + + | + } |
+ +490 + | ++ + + + + + | + else { |
+ +491 + | ++ + + + + + | + typeParamName = TYPE_NAME_IN_JAVADOC_TAG_SPLITTER.split(tag.getFirstArg())[0]; |
+ +492 + | ++ + + + + + | + } |
+ +493 + | +
+
+1
+
+
+1. extractTypeParamNameFromTag : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck::extractTypeParamNameFromTag to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return typeParamName; |
+ +494 + | ++ + + + + + | + } |
+ +495 + | ++ + + + + + | +|
+ +496 + | ++ + + + + + | +} |
Mutations | ||
304 | ++ |
+
+
+
+ 1.1 |
+
309 | ++ |
+
+
+
+ 1.1 |
+
319 | ++ |
+
+
+
+ 1.1 |
+
324 | ++ |
+
+
+
+ 1.1 |
+
328 | ++ |
+
+
+
+ 1.1 |
+
330 | ++ |
+
+
+
+ 1.1 |
+
332 | ++ |
+
+
+
+ 1.1 |
+
334 | ++ |
+
+
+
+ 1.1 |
+
341 | ++ |
+
+
+
+ 1.1 |
+
344 | ++ |
+
+
+
+ 1.1 |
+
349 | ++ |
+
+
+
+ 1.1 |
+
363 | ++ |
+
+
+
+ 1.1 |
+
372 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
373 | ++ |
+
+
+
+ 1.1 2.2 |
+
375 | ++ |
+
+
+
+ 1.1 2.2 |
+
377 | ++ |
+
+
+
+ 1.1 |
+
378 | ++ |
+
+
+
+ 1.1 |
+
390 | ++ |
+
+
+
+ 1.1 |
+
392 | ++ |
+
+
+
+ 1.1 |
+
396 | ++ |
+
+
+
+ 1.1 |
+
409 | ++ |
+
+
+
+ 1.1 |
+
412 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
414 | ++ |
+
+
+
+ 1.1 |
+
416 | ++ |
+
+
+
+ 1.1 |
+
417 | ++ |
+
+
+
+ 1.1 2.2 |
+
421 | ++ |
+
+
+
+ 1.1 |
+
422 | ++ |
+
+
+
+ 1.1 2.2 |
+
438 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
440 | ++ |
+
+
+
+ 1.1 |
+
441 | ++ |
+
+
+
+ 1.1 2.2 |
+
447 | ++ |
+
+
+
+ 1.1 |
+
448 | ++ |
+
+
+
+ 1.1 2.2 |
+
462 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
464 | ++ |
+
+
+
+ 1.1 |
+
467 | ++ |
+
+
+
+ 1.1 |
+
468 | ++ |
+
+
+
+ 1.1 |
+
470 | ++ |
+
+
+
+ 1.1 |
+
487 | ++ |
+
+
+
+ 1.1 |
+
493 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +23 + | ++ + + + + + | +|
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +32 + | ++ + + + + + | +|
+ +33 + | ++ + + + + + | +/** |
+ +34 + | ++ + + + + + | + * <p> |
+ +35 + | ++ + + + + + | + * Checks that a variable has a Javadoc comment. Ignores {@code serialVersionUID} fields. |
+ +36 + | ++ + + + + + | + * </p> |
+ +37 + | ++ + + + + + | + * <ul> |
+ +38 + | ++ + + + + + | + * <li> |
+ +39 + | ++ + + + + + | + * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. |
+ +40 + | ++ + + + + + | + * Default value is {@code private}. |
+ +41 + | ++ + + + + + | + * </li> |
+ +42 + | ++ + + + + + | + * <li> |
+ +43 + | ++ + + + + + | + * Property {@code excludeScope} - Specify the visibility scope where Javadoc |
+ +44 + | ++ + + + + + | + * comments are not checked. |
+ +45 + | ++ + + + + + | + * Default value is {@code null}. |
+ +46 + | ++ + + + + + | + * </li> |
+ +47 + | ++ + + + + + | + * <li> |
+ +48 + | ++ + + + + + | + * Property {@code ignoreNamePattern} - Specify the regexp to define variable names to ignore. |
+ +49 + | ++ + + + + + | + * Default value is {@code null}. |
+ +50 + | ++ + + + + + | + * </li> |
+ +51 + | ++ + + + + + | + * <li> |
+ +52 + | ++ + + + + + | + * Property {@code tokens} - tokens to check Default value is: |
+ +53 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_CONSTANT_DEF"> |
+ +54 + | ++ + + + + + | + * ENUM_CONSTANT_DEF</a>. |
+ +55 + | ++ + + + + + | + * </li> |
+ +56 + | ++ + + + + + | + * </ul> |
+ +57 + | ++ + + + + + | + * <p> |
+ +58 + | ++ + + + + + | + * To configure the default check: |
+ +59 + | ++ + + + + + | + * </p> |
+ +60 + | ++ + + + + + | + * <pre> |
+ +61 + | ++ + + + + + | + * <module name="JavadocVariable"/> |
+ +62 + | ++ + + + + + | + * </pre> |
+ +63 + | ++ + + + + + | + * <p> |
+ +64 + | ++ + + + + + | + * To configure the check for {@code public} scope: |
+ +65 + | ++ + + + + + | + * </p> |
+ +66 + | ++ + + + + + | + * <pre> |
+ +67 + | ++ + + + + + | + * <module name="JavadocVariable"> |
+ +68 + | ++ + + + + + | + * <property name="scope" value="public"/> |
+ +69 + | ++ + + + + + | + * </module> |
+ +70 + | ++ + + + + + | + * </pre> |
+ +71 + | ++ + + + + + | + * <p> |
+ +72 + | ++ + + + + + | + * To configure the check for members which are in {@code private}, |
+ +73 + | ++ + + + + + | + * but not in {@code protected} scope: |
+ +74 + | ++ + + + + + | + * </p> |
+ +75 + | ++ + + + + + | + * <pre> |
+ +76 + | ++ + + + + + | + * <module name="JavadocVariable"> |
+ +77 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +78 + | ++ + + + + + | + * <property name="excludeScope" value="protected"/> |
+ +79 + | ++ + + + + + | + * </module> |
+ +80 + | ++ + + + + + | + * </pre> |
+ +81 + | ++ + + + + + | + * <p> |
+ +82 + | ++ + + + + + | + * To ignore absence of Javadoc comments for variables with names {@code log} or {@code logger}: |
+ +83 + | ++ + + + + + | + * </p> |
+ +84 + | ++ + + + + + | + * <pre> |
+ +85 + | ++ + + + + + | + * <module name="JavadocVariable"> |
+ +86 + | ++ + + + + + | + * <property name="ignoreNamePattern" value="log|logger"/> |
+ +87 + | ++ + + + + + | + * </module> |
+ +88 + | ++ + + + + + | + * </pre> |
+ +89 + | ++ + + + + + | + * |
+ +90 + | ++ + + + + + | + * @since 3.0 |
+ +91 + | ++ + + + + + | + */ |
+ +92 + | ++ + + + + + | +@StatelessCheck |
+ +93 + | ++ + + + + + | +public class JavadocVariableCheck |
+ +94 + | ++ + + + + + | + extends AbstractCheck { |
+ +95 + | ++ + + + + + | +|
+ +96 + | ++ + + + + + | + /** |
+ +97 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +98 + | ++ + + + + + | + * file. |
+ +99 + | ++ + + + + + | + */ |
+ +100 + | ++ + + + + + | + public static final String MSG_JAVADOC_MISSING = "javadoc.missing"; |
+ +101 + | ++ + + + + + | +|
+ +102 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +103 + | ++ + + + + + | + private Scope scope = Scope.PRIVATE; |
+ +104 + | ++ + + + + + | +|
+ +105 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +106 + | ++ + + + + + | + private Scope excludeScope; |
+ +107 + | ++ + + + + + | +|
+ +108 + | ++ + + + + + | + /** Specify the regexp to define variable names to ignore. */ |
+ +109 + | ++ + + + + + | + private Pattern ignoreNamePattern; |
+ +110 + | ++ + + + + + | +|
+ +111 + | ++ + + + + + | + /** |
+ +112 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +113 + | ++ + + + + + | + * |
+ +114 + | ++ + + + + + | + * @param scope a scope. |
+ +115 + | ++ + + + + + | + */ |
+ +116 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +117 + | ++ + + + + + | + this.scope = scope; |
+ +118 + | ++ + + + + + | + } |
+ +119 + | ++ + + + + + | +|
+ +120 + | ++ + + + + + | + /** |
+ +121 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +122 + | ++ + + + + + | + * |
+ +123 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +124 + | ++ + + + + + | + */ |
+ +125 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +126 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +127 + | ++ + + + + + | + } |
+ +128 + | ++ + + + + + | +|
+ +129 + | ++ + + + + + | + /** |
+ +130 + | ++ + + + + + | + * Setter to specify the regexp to define variable names to ignore. |
+ +131 + | ++ + + + + + | + * |
+ +132 + | ++ + + + + + | + * @param pattern a pattern. |
+ +133 + | ++ + + + + + | + */ |
+ +134 + | ++ + + + + + | + public void setIgnoreNamePattern(Pattern pattern) { |
+ +135 + | ++ + + + + + | + ignoreNamePattern = pattern; |
+ +136 + | ++ + + + + + | + } |
+ +137 + | ++ + + + + + | +|
+ +138 + | ++ + + + + + | + @Override |
+ +139 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +140 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +141 + | ++ + + + + + | + } |
+ +142 + | ++ + + + + + | +|
+ +143 + | ++ + + + + + | + @Override |
+ +144 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +145 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +146 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF, |
+ +147 + | ++ + + + + + | + TokenTypes.ENUM_CONSTANT_DEF, |
+ +148 + | ++ + + + + + | + }; |
+ +149 + | ++ + + + + + | + } |
+ +150 + | ++ + + + + + | +|
+ +151 + | ++ + + + + + | + /* |
+ +152 + | ++ + + + + + | + * Skipping enum values is requested. |
+ +153 + | ++ + + + + + | + * Checkstyle's issue #1669: https://github.com/checkstyle/checkstyle/issues/1669 |
+ +154 + | ++ + + + + + | + */ |
+ +155 + | ++ + + + + + | + @Override |
+ +156 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +157 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +158 + | ++ + + + + + | + TokenTypes.VARIABLE_DEF, |
+ +159 + | ++ + + + + + | + }; |
+ +160 + | ++ + + + + + | + } |
+ +161 + | ++ + + + + + | +|
+ +162 + | ++ + + + + + | + @Override |
+ +163 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +164 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast)) { |
+ +165 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +166 + | ++ + + + + + | + final TextBlock textBlock = |
+ +167 + | ++ + + + + + | + contents.getJavadocBefore(ast.getLineNo()); |
+ +168 + | ++ + + + + + | +|
+ +169 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (textBlock == null) { |
+ +170 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::log → KILLED + + + + |
+ log(ast, MSG_JAVADOC_MISSING); |
+ +171 + | ++ + + + + + | + } |
+ +172 + | ++ + + + + + | + } |
+ +173 + | ++ + + + + + | + } |
+ +174 + | ++ + + + + + | +|
+ +175 + | ++ + + + + + | + /** |
+ +176 + | ++ + + + + + | + * Decides whether the variable name of an AST is in the ignore list. |
+ +177 + | ++ + + + + + | + * |
+ +178 + | ++ + + + + + | + * @param ast the AST to check |
+ +179 + | ++ + + + + + | + * @return true if the variable name of ast is in the ignore list. |
+ +180 + | ++ + + + + + | + */ |
+ +181 + | ++ + + + + + | + private boolean isIgnored(DetailAST ast) { |
+ +182 + | ++ + + + + + | + final String name = ast.findFirstToken(TokenTypes.IDENT).getText(); |
+ +183 + | +
+
+4
+
+
+1. isIgnored : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::isIgnored → KILLED + +2. isIgnored : negated conditional → KILLED + +3. isIgnored : negated conditional → KILLED + +4. isIgnored : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return ignoreNamePattern != null && ignoreNamePattern.matcher(name).matches() |
+ +184 + | +
+
+1
+
+
+1. isIgnored : negated conditional → KILLED + + + + |
+ || "serialVersionUID".equals(name); |
+ +185 + | ++ + + + + + | + } |
+ +186 + | ++ + + + + + | +|
+ +187 + | ++ + + + + + | + /** |
+ +188 + | ++ + + + + + | + * Whether we should check this node. |
+ +189 + | ++ + + + + + | + * |
+ +190 + | ++ + + + + + | + * @param ast a given node. |
+ +191 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +192 + | ++ + + + + + | + */ |
+ +193 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast) { |
+ +194 + | ++ + + + + + | + boolean result = false; |
+ +195 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ if (!ScopeUtil.isInCodeBlock(ast) && !isIgnored(ast)) { |
+ +196 + | ++ + + + + + | + Scope customScope = Scope.PUBLIC; |
+ +197 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ if (ast.getType() != TokenTypes.ENUM_CONSTANT_DEF |
+ +198 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
+ +199 + | ++ + + + + + | + final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); |
+ +200 + | ++ + + + + + | + customScope = ScopeUtil.getScopeFromMods(mods); |
+ +201 + | ++ + + + + + | + } |
+ +202 + | ++ + + + + + | +|
+ +203 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +204 + | +
+
+3
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + +3. shouldCheck : negated conditional → KILLED + + + + |
+ result = customScope.isIn(scope) && surroundingScope.isIn(scope) |
+ +205 + | ++ + + + + + | + && (excludeScope == null |
+ +206 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ || !customScope.isIn(excludeScope) |
+ +207 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ || !surroundingScope.isIn(excludeScope)); |
+ +208 + | ++ + + + + + | + } |
+ +209 + | +
+
+3
+
+
+1. shouldCheck : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::shouldCheck → KILLED + +2. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck::shouldCheck → KILLED + +3. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +210 + | ++ + + + + + | + } |
+ +211 + | ++ + + + + + | +|
+ +212 + | ++ + + + + + | +} |
Mutations | ||
140 | ++ |
+
+
+
+ 1.1 |
+
145 | ++ |
+
+
+
+ 1.1 |
+
157 | ++ |
+
+
+
+ 1.1 |
+
164 | ++ |
+
+
+
+ 1.1 |
+
169 | ++ |
+
+
+
+ 1.1 |
+
170 | ++ |
+
+
+
+ 1.1 |
+
183 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
184 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 2.2 |
+
197 | ++ |
+
+
+
+ 1.1 |
+
198 | ++ |
+
+
+
+ 1.1 |
+
204 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
206 | ++ |
+
+
+
+ 1.1 |
+
207 | ++ |
+
+
+
+ 1.1 |
+
209 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +26 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.FileStatefulCheck; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +33 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +34 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +35 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil; |
+ +36 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CheckUtil; |
+ +37 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +38 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +39 + | ++ + + + + + | +|
+ +40 + | ++ + + + + + | +/** |
+ +41 + | ++ + + + + + | + * <p> |
+ +42 + | ++ + + + + + | + * Checks for missing Javadoc comments for a method or constructor. The scope to verify is |
+ +43 + | ++ + + + + + | + * specified using the {@code Scope} class and defaults to {@code Scope.PUBLIC}. To verify |
+ +44 + | ++ + + + + + | + * another scope, set property scope to a different |
+ +45 + | ++ + + + + + | + * <a href="https://checkstyle.org/property_types.html#scope">scope</a>. |
+ +46 + | ++ + + + + + | + * </p> |
+ +47 + | ++ + + + + + | + * <p> |
+ +48 + | ++ + + + + + | + * Javadoc is not required on a method that is tagged with the {@code @Override} annotation. |
+ +49 + | ++ + + + + + | + * However under Java 5 it is not possible to mark a method required for an interface (this |
+ +50 + | ++ + + + + + | + * was <i>corrected</i> under Java 6). Hence Checkstyle supports using the convention of using |
+ +51 + | ++ + + + + + | + * a single {@code {@inheritDoc}} tag instead of all the other tags. |
+ +52 + | ++ + + + + + | + * </p> |
+ +53 + | ++ + + + + + | + * <p> |
+ +54 + | ++ + + + + + | + * For getters and setters for the property {@code allowMissingPropertyJavadoc}, the methods must |
+ +55 + | ++ + + + + + | + * match exactly the structures below. |
+ +56 + | ++ + + + + + | + * </p> |
+ +57 + | ++ + + + + + | + * <pre> |
+ +58 + | ++ + + + + + | + * public void setNumber(final int number) |
+ +59 + | ++ + + + + + | + * { |
+ +60 + | ++ + + + + + | + * mNumber = number; |
+ +61 + | ++ + + + + + | + * } |
+ +62 + | ++ + + + + + | + * |
+ +63 + | ++ + + + + + | + * public int getNumber() |
+ +64 + | ++ + + + + + | + * { |
+ +65 + | ++ + + + + + | + * return mNumber; |
+ +66 + | ++ + + + + + | + * } |
+ +67 + | ++ + + + + + | + * |
+ +68 + | ++ + + + + + | + * public boolean isSomething() |
+ +69 + | ++ + + + + + | + * { |
+ +70 + | ++ + + + + + | + * return false; |
+ +71 + | ++ + + + + + | + * } |
+ +72 + | ++ + + + + + | + * </pre> |
+ +73 + | ++ + + + + + | + * <ul> |
+ +74 + | ++ + + + + + | + * <li> |
+ +75 + | ++ + + + + + | + * Property {@code minLineCount} - Control the minimal amount of lines in method to allow no |
+ +76 + | ++ + + + + + | + * documentation. Default value is {@code -1}. |
+ +77 + | ++ + + + + + | + * </li> |
+ +78 + | ++ + + + + + | + * <li> |
+ +79 + | ++ + + + + + | + * Property {@code allowedAnnotations} - Configure the list of annotations that allow missed |
+ +80 + | ++ + + + + + | + * documentation. Default value is {@code Override}. |
+ +81 + | ++ + + + + + | + * </li> |
+ +82 + | ++ + + + + + | + * <li> |
+ +83 + | ++ + + + + + | + * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. |
+ +84 + | ++ + + + + + | + * Default value is {@code public}. |
+ +85 + | ++ + + + + + | + * </li> |
+ +86 + | ++ + + + + + | + * <li> |
+ +87 + | ++ + + + + + | + * Property {@code excludeScope} - Specify the visibility scope where Javadoc comments are |
+ +88 + | ++ + + + + + | + * not checked. Default value is {@code null}. |
+ +89 + | ++ + + + + + | + * </li> |
+ +90 + | ++ + + + + + | + * <li> |
+ +91 + | ++ + + + + + | + * Property {@code allowMissingPropertyJavadoc} - Control whether to allow missing Javadoc on |
+ +92 + | ++ + + + + + | + * accessor methods for properties (setters and getters). Default value is {@code false}. |
+ +93 + | ++ + + + + + | + * </li> |
+ +94 + | ++ + + + + + | + * <li> |
+ +95 + | ++ + + + + + | + * Property {@code ignoreMethodNamesRegex} - ignore method whose names are matching specified |
+ +96 + | ++ + + + + + | + * regex. Default value is {@code null}. |
+ +97 + | ++ + + + + + | + * </li> |
+ +98 + | ++ + + + + + | + * <li> |
+ +99 + | ++ + + + + + | + * Property {@code tokens} - tokens to check Default value is: |
+ +100 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF"> |
+ +101 + | ++ + + + + + | + * METHOD_DEF</a>, |
+ +102 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF"> |
+ +103 + | ++ + + + + + | + * CTOR_DEF</a>, |
+ +104 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF"> |
+ +105 + | ++ + + + + + | + * ANNOTATION_FIELD_DEF</a>. |
+ +106 + | ++ + + + + + | + * </li> |
+ +107 + | ++ + + + + + | + * </ul> |
+ +108 + | ++ + + + + + | + * <p> |
+ +109 + | ++ + + + + + | + * To configure the default check: |
+ +110 + | ++ + + + + + | + * </p> |
+ +111 + | ++ + + + + + | + * <pre> |
+ +112 + | ++ + + + + + | + * <module name="MissingJavadocMethod"/> |
+ +113 + | ++ + + + + + | + * </pre> |
+ +114 + | ++ + + + + + | + * <p> |
+ +115 + | ++ + + + + + | + * Example: |
+ +116 + | ++ + + + + + | + * </p> |
+ +117 + | ++ + + + + + | + * <pre> |
+ +118 + | ++ + + + + + | + * public class Test { |
+ +119 + | ++ + + + + + | + * public Test() {} // violation, missing javadoc for constructor |
+ +120 + | ++ + + + + + | + * public void test() {} // violation, missing javadoc for method |
+ +121 + | ++ + + + + + | + * /** |
+ +122 + | ++ + + + + + | + * * Some description here. |
+ +123 + | ++ + + + + + | + * */ |
+ +124 + | ++ + + + + + | + * public void test2() {} // OK |
+ +125 + | ++ + + + + + | + * |
+ +126 + | ++ + + + + + | + * @Override |
+ +127 + | ++ + + + + + | + * public String toString() { // OK |
+ +128 + | ++ + + + + + | + * return "Some string"; |
+ +129 + | ++ + + + + + | + * } |
+ +130 + | ++ + + + + + | + * |
+ +131 + | ++ + + + + + | + * private void test1() {} // OK |
+ +132 + | ++ + + + + + | + * protected void test2() {} // OK |
+ +133 + | ++ + + + + + | + * void test3() {} // OK |
+ +134 + | ++ + + + + + | + * } |
+ +135 + | ++ + + + + + | + * </pre> |
+ +136 + | ++ + + + + + | + * |
+ +137 + | ++ + + + + + | + * <p> |
+ +138 + | ++ + + + + + | + * To configure the check for {@code private} scope: |
+ +139 + | ++ + + + + + | + * </p> |
+ +140 + | ++ + + + + + | + * <pre> |
+ +141 + | ++ + + + + + | + * <module name="MissingJavadocMethod"> |
+ +142 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +143 + | ++ + + + + + | + * </module> |
+ +144 + | ++ + + + + + | + * </pre> |
+ +145 + | ++ + + + + + | + * <p>Example:</p> |
+ +146 + | ++ + + + + + | + * <pre> |
+ +147 + | ++ + + + + + | + * public class Test { |
+ +148 + | ++ + + + + + | + * private void test1() {} // violation, the private method is missing javadoc |
+ +149 + | ++ + + + + + | + * } |
+ +150 + | ++ + + + + + | + * </pre> |
+ +151 + | ++ + + + + + | + * |
+ +152 + | ++ + + + + + | + * <p> |
+ +153 + | ++ + + + + + | + * To configure the check for methods which are in {@code private}, but not in {@code protected} |
+ +154 + | ++ + + + + + | + * scope: |
+ +155 + | ++ + + + + + | + * </p> |
+ +156 + | ++ + + + + + | + * <pre> |
+ +157 + | ++ + + + + + | + * <module name="MissingJavadocMethod"> |
+ +158 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +159 + | ++ + + + + + | + * <property name="excludeScope" value="protected"/> |
+ +160 + | ++ + + + + + | + * </module> |
+ +161 + | ++ + + + + + | + * </pre> |
+ +162 + | ++ + + + + + | + * <p>Example:</p> |
+ +163 + | ++ + + + + + | + * <pre> |
+ +164 + | ++ + + + + + | + * public class Test { |
+ +165 + | ++ + + + + + | + * private void test1() {} // violation, the private method is missing javadoc |
+ +166 + | ++ + + + + + | + * /** |
+ +167 + | ++ + + + + + | + * * Some description here |
+ +168 + | ++ + + + + + | + * */ |
+ +169 + | ++ + + + + + | + * private void test1() {} // OK |
+ +170 + | ++ + + + + + | + * protected void test2() {} // OK |
+ +171 + | ++ + + + + + | + * } |
+ +172 + | ++ + + + + + | + * </pre> |
+ +173 + | ++ + + + + + | + * |
+ +174 + | ++ + + + + + | + * <p> |
+ +175 + | ++ + + + + + | + * To configure the check for ignoring methods named {@code foo(),foo1(),foo2()}, etc.: |
+ +176 + | ++ + + + + + | + * </p> |
+ +177 + | ++ + + + + + | + * <pre> |
+ +178 + | ++ + + + + + | + * <module name="MissingJavadocMethod"> |
+ +179 + | ++ + + + + + | + * <property name="ignoreMethodNamesRegex" value="^foo.*$"/> |
+ +180 + | ++ + + + + + | + * </module> |
+ +181 + | ++ + + + + + | + * </pre> |
+ +182 + | ++ + + + + + | + * <p>Example:</p> |
+ +183 + | ++ + + + + + | + * <pre> |
+ +184 + | ++ + + + + + | + * public class Test { |
+ +185 + | ++ + + + + + | + * public void test1() {} // violation, method is missing javadoc |
+ +186 + | ++ + + + + + | + * public void foo() {} // OK |
+ +187 + | ++ + + + + + | + * public void foobar() {} // OK |
+ +188 + | ++ + + + + + | + * } |
+ +189 + | ++ + + + + + | + * </pre> |
+ +190 + | ++ + + + + + | + * |
+ +191 + | ++ + + + + + | + * <p> |
+ +192 + | ++ + + + + + | + * To configure the check for ignoring missing javadoc for accessor methods: |
+ +193 + | ++ + + + + + | + * </p> |
+ +194 + | ++ + + + + + | + * <pre> |
+ +195 + | ++ + + + + + | + * <module name="MissingJavadocMethod"> |
+ +196 + | ++ + + + + + | + * <property name="allowMissingPropertyJavadoc" value="true"/> |
+ +197 + | ++ + + + + + | + * </module> |
+ +198 + | ++ + + + + + | + * </pre> |
+ +199 + | ++ + + + + + | + * <p>Example:</p> |
+ +200 + | ++ + + + + + | + * <pre> |
+ +201 + | ++ + + + + + | + * public class Test { |
+ +202 + | ++ + + + + + | + * private String text; |
+ +203 + | ++ + + + + + | + * |
+ +204 + | ++ + + + + + | + * public void test() {} // violation, method is missing javadoc |
+ +205 + | ++ + + + + + | + * public String getText() { return text; } // OK |
+ +206 + | ++ + + + + + | + * public void setText(String text) { this.text = text; } // OK |
+ +207 + | ++ + + + + + | + * } |
+ +208 + | ++ + + + + + | + * </pre> |
+ +209 + | ++ + + + + + | + * |
+ +210 + | ++ + + + + + | + * <p> |
+ +211 + | ++ + + + + + | + * To configure the check with annotations that allow missed documentation: |
+ +212 + | ++ + + + + + | + * </p> |
+ +213 + | ++ + + + + + | + * <pre> |
+ +214 + | ++ + + + + + | + * <module name="MissingJavadocMethod"> |
+ +215 + | ++ + + + + + | + * <property name="allowedAnnotations" value="Override,Deprecated"/> |
+ +216 + | ++ + + + + + | + * </module> |
+ +217 + | ++ + + + + + | + * </pre> |
+ +218 + | ++ + + + + + | + * <p>Example:</p> |
+ +219 + | ++ + + + + + | + * <pre> |
+ +220 + | ++ + + + + + | + * public class Test { |
+ +221 + | ++ + + + + + | + * public void test() {} // violation, method is missing javadoc |
+ +222 + | ++ + + + + + | + * @Override |
+ +223 + | ++ + + + + + | + * public void test1() {} // OK |
+ +224 + | ++ + + + + + | + * @Deprecated |
+ +225 + | ++ + + + + + | + * public void test2() {} // OK |
+ +226 + | ++ + + + + + | + * @SuppressWarnings |
+ +227 + | ++ + + + + + | + * public void test3() {} // violation, method is missing javadoc |
+ +228 + | ++ + + + + + | + * /** |
+ +229 + | ++ + + + + + | + * * Some description here. |
+ +230 + | ++ + + + + + | + * */ |
+ +231 + | ++ + + + + + | + * @SuppressWarnings |
+ +232 + | ++ + + + + + | + * public void test4() {} // OK |
+ +233 + | ++ + + + + + | + * } |
+ +234 + | ++ + + + + + | + * </pre> |
+ +235 + | ++ + + + + + | + * |
+ +236 + | ++ + + + + + | + * @since 8.21 |
+ +237 + | ++ + + + + + | + */ |
+ +238 + | ++ + + + + + | +@FileStatefulCheck |
+ +239 + | ++ + + + + + | +public class MissingJavadocMethodCheck extends AbstractCheck { |
+ +240 + | ++ + + + + + | +|
+ +241 + | ++ + + + + + | + /** |
+ +242 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +243 + | ++ + + + + + | + * file. |
+ +244 + | ++ + + + + + | + */ |
+ +245 + | ++ + + + + + | + public static final String MSG_JAVADOC_MISSING = "javadoc.missing"; |
+ +246 + | ++ + + + + + | +|
+ +247 + | ++ + + + + + | + /** Default value of minimal amount of lines in method to allow no documentation.*/ |
+ +248 + | ++ + + + + + | + private static final int DEFAULT_MIN_LINE_COUNT = -1; |
+ +249 + | ++ + + + + + | +|
+ +250 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +251 + | ++ + + + + + | + private Scope scope = Scope.PUBLIC; |
+ +252 + | ++ + + + + + | +|
+ +253 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +254 + | ++ + + + + + | + private Scope excludeScope; |
+ +255 + | ++ + + + + + | +|
+ +256 + | ++ + + + + + | + /** Control the minimal amount of lines in method to allow no documentation.*/ |
+ +257 + | ++ + + + + + | + private int minLineCount = DEFAULT_MIN_LINE_COUNT; |
+ +258 + | ++ + + + + + | +|
+ +259 + | ++ + + + + + | + /** |
+ +260 + | ++ + + + + + | + * Control whether to allow missing Javadoc on accessor methods for |
+ +261 + | ++ + + + + + | + * properties (setters and getters). |
+ +262 + | ++ + + + + + | + */ |
+ +263 + | ++ + + + + + | + private boolean allowMissingPropertyJavadoc; |
+ +264 + | ++ + + + + + | +|
+ +265 + | ++ + + + + + | + /** Ignore method whose names are matching specified regex. */ |
+ +266 + | ++ + + + + + | + private Pattern ignoreMethodNamesRegex; |
+ +267 + | ++ + + + + + | +|
+ +268 + | ++ + + + + + | + /** Configure the list of annotations that allow missed documentation. */ |
+ +269 + | ++ + + + + + | + private List<String> allowedAnnotations = Collections.singletonList("Override"); |
+ +270 + | ++ + + + + + | +|
+ +271 + | ++ + + + + + | + /** |
+ +272 + | ++ + + + + + | + * Setter to configure the list of annotations that allow missed documentation. |
+ +273 + | ++ + + + + + | + * |
+ +274 + | ++ + + + + + | + * @param userAnnotations user's value. |
+ +275 + | ++ + + + + + | + */ |
+ +276 + | ++ + + + + + | + public void setAllowedAnnotations(String... userAnnotations) { |
+ +277 + | ++ + + + + + | + allowedAnnotations = Arrays.asList(userAnnotations); |
+ +278 + | ++ + + + + + | + } |
+ +279 + | ++ + + + + + | +|
+ +280 + | ++ + + + + + | + /** |
+ +281 + | ++ + + + + + | + * Setter to ignore method whose names are matching specified regex. |
+ +282 + | ++ + + + + + | + * |
+ +283 + | ++ + + + + + | + * @param pattern a pattern. |
+ +284 + | ++ + + + + + | + */ |
+ +285 + | ++ + + + + + | + public void setIgnoreMethodNamesRegex(Pattern pattern) { |
+ +286 + | ++ + + + + + | + ignoreMethodNamesRegex = pattern; |
+ +287 + | ++ + + + + + | + } |
+ +288 + | ++ + + + + + | +|
+ +289 + | ++ + + + + + | + /** |
+ +290 + | ++ + + + + + | + * Setter to control the minimal amount of lines in method to allow no documentation. |
+ +291 + | ++ + + + + + | + * |
+ +292 + | ++ + + + + + | + * @param value user's value. |
+ +293 + | ++ + + + + + | + */ |
+ +294 + | ++ + + + + + | + public void setMinLineCount(int value) { |
+ +295 + | ++ + + + + + | + minLineCount = value; |
+ +296 + | ++ + + + + + | + } |
+ +297 + | ++ + + + + + | +|
+ +298 + | ++ + + + + + | + /** |
+ +299 + | ++ + + + + + | + * Setter to control whether to allow missing Javadoc on accessor methods for properties |
+ +300 + | ++ + + + + + | + * (setters and getters). |
+ +301 + | ++ + + + + + | + * |
+ +302 + | ++ + + + + + | + * @param flag a {@code Boolean} value |
+ +303 + | ++ + + + + + | + */ |
+ +304 + | ++ + + + + + | + public void setAllowMissingPropertyJavadoc(final boolean flag) { |
+ +305 + | ++ + + + + + | + allowMissingPropertyJavadoc = flag; |
+ +306 + | ++ + + + + + | + } |
+ +307 + | ++ + + + + + | +|
+ +308 + | ++ + + + + + | + /** |
+ +309 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +310 + | ++ + + + + + | + * |
+ +311 + | ++ + + + + + | + * @param scope a scope. |
+ +312 + | ++ + + + + + | + */ |
+ +313 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +314 + | ++ + + + + + | + this.scope = scope; |
+ +315 + | ++ + + + + + | + } |
+ +316 + | ++ + + + + + | +|
+ +317 + | ++ + + + + + | + /** |
+ +318 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +319 + | ++ + + + + + | + * |
+ +320 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +321 + | ++ + + + + + | + */ |
+ +322 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +323 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +324 + | ++ + + + + + | + } |
+ +325 + | ++ + + + + + | +|
+ +326 + | ++ + + + + + | + @Override |
+ +327 + | ++ + + + + + | + public final int[] getRequiredTokens() { |
+ +328 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +329 + | ++ + + + + + | + } |
+ +330 + | ++ + + + + + | +|
+ +331 + | ++ + + + + + | + @Override |
+ +332 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +333 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +334 + | ++ + + + + + | + } |
+ +335 + | ++ + + + + + | +|
+ +336 + | ++ + + + + + | + @Override |
+ +337 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +338 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +339 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +340 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +341 + | ++ + + + + + | + TokenTypes.ANNOTATION_FIELD_DEF, |
+ +342 + | ++ + + + + + | + }; |
+ +343 + | ++ + + + + + | + } |
+ +344 + | ++ + + + + + | +|
+ +345 + | ++ + + + + + | + @Override |
+ +346 + | ++ + + + + + | + public final void visitToken(DetailAST ast) { |
+ +347 + | ++ + + + + + | + final Scope theScope = calculateScope(ast); |
+ +348 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast, theScope)) { |
+ +349 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +350 + | ++ + + + + + | + final TextBlock textBlock = contents.getJavadocBefore(ast.getLineNo()); |
+ +351 + | ++ + + + + + | +|
+ +352 + | +
+
+2
+
+
+1. visitToken : negated conditional → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (textBlock == null && !isMissingJavadocAllowed(ast)) { |
+ +353 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::log → KILLED + + + + |
+ log(ast, MSG_JAVADOC_MISSING); |
+ +354 + | ++ + + + + + | + } |
+ +355 + | ++ + + + + + | + } |
+ +356 + | ++ + + + + + | + } |
+ +357 + | ++ + + + + + | +|
+ +358 + | ++ + + + + + | + /** |
+ +359 + | ++ + + + + + | + * Some javadoc. |
+ +360 + | ++ + + + + + | + * |
+ +361 + | ++ + + + + + | + * @param methodDef Some javadoc. |
+ +362 + | ++ + + + + + | + * @return Some javadoc. |
+ +363 + | ++ + + + + + | + */ |
+ +364 + | ++ + + + + + | + private static int getMethodsNumberOfLine(DetailAST methodDef) { |
+ +365 + | ++ + + + + + | + final int numberOfLines; |
+ +366 + | ++ + + + + + | + final DetailAST lcurly = methodDef.getLastChild(); |
+ +367 + | ++ + + + + + | + final DetailAST rcurly = lcurly.getLastChild(); |
+ +368 + | ++ + + + + + | +|
+ +369 + | +
+
+1
+
+
+1. getMethodsNumberOfLine : negated conditional → KILLED + + + + |
+ if (lcurly.getFirstChild() == rcurly) { |
+ +370 + | ++ + + + + + | + numberOfLines = 1; |
+ +371 + | ++ + + + + + | + } |
+ +372 + | ++ + + + + + | + else { |
+ +373 + | +
+
+2
+
+
+1. getMethodsNumberOfLine : Replaced integer subtraction with addition → KILLED + +2. getMethodsNumberOfLine : Replaced integer subtraction with addition → KILLED + + + + |
+ numberOfLines = rcurly.getLineNo() - lcurly.getLineNo() - 1; |
+ +374 + | ++ + + + + + | + } |
+ +375 + | +
+
+1
+
+
+1. getMethodsNumberOfLine : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return numberOfLines; |
+ +376 + | ++ + + + + + | + } |
+ +377 + | ++ + + + + + | +|
+ +378 + | ++ + + + + + | + /** |
+ +379 + | ++ + + + + + | + * Checks if a missing Javadoc is allowed by the check's configuration. |
+ +380 + | ++ + + + + + | + * |
+ +381 + | ++ + + + + + | + * @param ast the tree node for the method or constructor. |
+ +382 + | ++ + + + + + | + * @return True if this method or constructor doesn't need Javadoc. |
+ +383 + | ++ + + + + + | + */ |
+ +384 + | ++ + + + + + | + private boolean isMissingJavadocAllowed(final DetailAST ast) { |
+ +385 + | +
+
+3
+
+
+1. isMissingJavadocAllowed : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::isMissingJavadocAllowed → KILLED + +2. isMissingJavadocAllowed : negated conditional → KILLED + +3. isMissingJavadocAllowed : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return allowMissingPropertyJavadoc |
+ +386 + | +
+
+2
+
+
+1. isMissingJavadocAllowed : negated conditional → KILLED + +2. isMissingJavadocAllowed : negated conditional → KILLED + + + + |
+ && (CheckUtil.isSetterMethod(ast) || CheckUtil.isGetterMethod(ast)) |
+ +387 + | +
+
+1
+
+
+1. isMissingJavadocAllowed : negated conditional → KILLED + + + + |
+ || matchesSkipRegex(ast) |
+ +388 + | +
+
+1
+
+
+1. isMissingJavadocAllowed : negated conditional → KILLED + + + + |
+ || isContentsAllowMissingJavadoc(ast); |
+ +389 + | ++ + + + + + | + } |
+ +390 + | ++ + + + + + | +|
+ +391 + | ++ + + + + + | + /** |
+ +392 + | ++ + + + + + | + * Checks if the Javadoc can be missing if the method or constructor is |
+ +393 + | ++ + + + + + | + * below the minimum line count or has a special annotation. |
+ +394 + | ++ + + + + + | + * |
+ +395 + | ++ + + + + + | + * @param ast the tree node for the method or constructor. |
+ +396 + | ++ + + + + + | + * @return True if this method or constructor doesn't need Javadoc. |
+ +397 + | ++ + + + + + | + */ |
+ +398 + | ++ + + + + + | + private boolean isContentsAllowMissingJavadoc(DetailAST ast) { |
+ +399 + | +
+
+4
+
+
+1. isContentsAllowMissingJavadoc : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::isContentsAllowMissingJavadoc → KILLED + +2. isContentsAllowMissingJavadoc : negated conditional → KILLED + +3. isContentsAllowMissingJavadoc : negated conditional → KILLED + +4. isContentsAllowMissingJavadoc : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return (ast.getType() == TokenTypes.METHOD_DEF || ast.getType() == TokenTypes.CTOR_DEF) |
+ +400 + | +
+
+2
+
+
+1. isContentsAllowMissingJavadoc : changed conditional boundary → KILLED + +2. isContentsAllowMissingJavadoc : negated conditional → KILLED + + + + |
+ && (getMethodsNumberOfLine(ast) <= minLineCount |
+ +401 + | +
+
+1
+
+
+1. isContentsAllowMissingJavadoc : negated conditional → KILLED + + + + |
+ || AnnotationUtil.containsAnnotation(ast, allowedAnnotations)); |
+ +402 + | ++ + + + + + | + } |
+ +403 + | ++ + + + + + | +|
+ +404 + | ++ + + + + + | + /** |
+ +405 + | ++ + + + + + | + * Checks if the given method name matches the regex. In that case |
+ +406 + | ++ + + + + + | + * we skip enforcement of javadoc for this method |
+ +407 + | ++ + + + + + | + * |
+ +408 + | ++ + + + + + | + * @param methodDef {@link TokenTypes#METHOD_DEF METHOD_DEF} |
+ +409 + | ++ + + + + + | + * @return true if given method name matches the regex. |
+ +410 + | ++ + + + + + | + */ |
+ +411 + | ++ + + + + + | + private boolean matchesSkipRegex(DetailAST methodDef) { |
+ +412 + | ++ + + + + + | + boolean result = false; |
+ +413 + | +
+
+1
+
+
+1. matchesSkipRegex : negated conditional → KILLED + + + + |
+ if (ignoreMethodNamesRegex != null) { |
+ +414 + | ++ + + + + + | + final DetailAST ident = methodDef.findFirstToken(TokenTypes.IDENT); |
+ +415 + | ++ + + + + + | + final String methodName = ident.getText(); |
+ +416 + | ++ + + + + + | +|
+ +417 + | ++ + + + + + | + final Matcher matcher = ignoreMethodNamesRegex.matcher(methodName); |
+ +418 + | +
+
+1
+
+
+1. matchesSkipRegex : negated conditional → KILLED + + + + |
+ if (matcher.matches()) { |
+ +419 + | ++ + + + + + | + result = true; |
+ +420 + | ++ + + + + + | + } |
+ +421 + | ++ + + + + + | + } |
+ +422 + | +
+
+3
+
+
+1. matchesSkipRegex : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::matchesSkipRegex → KILLED + +2. matchesSkipRegex : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::matchesSkipRegex → KILLED + +3. matchesSkipRegex : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +423 + | ++ + + + + + | + } |
+ +424 + | ++ + + + + + | +|
+ +425 + | ++ + + + + + | + /** |
+ +426 + | ++ + + + + + | + * Whether we should check this node. |
+ +427 + | ++ + + + + + | + * |
+ +428 + | ++ + + + + + | + * @param ast a given node. |
+ +429 + | ++ + + + + + | + * @param nodeScope the scope of the node. |
+ +430 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +431 + | ++ + + + + + | + */ |
+ +432 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast, final Scope nodeScope) { |
+ +433 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +434 + | ++ + + + + + | +|
+ +435 + | +
+
+5
+
+
+1. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::shouldCheck → KILLED + +2. shouldCheck : negated conditional → KILLED + +3. shouldCheck : negated conditional → KILLED + +4. shouldCheck : negated conditional → KILLED + +5. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return (excludeScope == null |
+ +436 + | ++ + + + + + | + || nodeScope != excludeScope |
+ +437 + | ++ + + + + + | + && surroundingScope != excludeScope) |
+ +438 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && nodeScope.isIn(scope) |
+ +439 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && surroundingScope.isIn(scope); |
+ +440 + | ++ + + + + + | + } |
+ +441 + | ++ + + + + + | +|
+ +442 + | ++ + + + + + | + /** |
+ +443 + | ++ + + + + + | + * Returns the scope for the method/constructor at the specified AST. If |
+ +444 + | ++ + + + + + | + * the method is in an interface or annotation block, the scope is assumed |
+ +445 + | ++ + + + + + | + * to be public. |
+ +446 + | ++ + + + + + | + * |
+ +447 + | ++ + + + + + | + * @param ast the token of the method/constructor |
+ +448 + | ++ + + + + + | + * @return the scope of the method/constructor |
+ +449 + | ++ + + + + + | + */ |
+ +450 + | ++ + + + + + | + private static Scope calculateScope(final DetailAST ast) { |
+ +451 + | ++ + + + + + | + final Scope scope; |
+ +452 + | ++ + + + + + | +|
+ +453 + | +
+
+1
+
+
+1. calculateScope : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
+ +454 + | ++ + + + + + | + scope = Scope.PUBLIC; |
+ +455 + | ++ + + + + + | + } |
+ +456 + | ++ + + + + + | + else { |
+ +457 + | ++ + + + + + | + final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); |
+ +458 + | ++ + + + + + | + scope = ScopeUtil.getScopeFromMods(mods); |
+ +459 + | ++ + + + + + | + } |
+ +460 + | +
+
+1
+
+
+1. calculateScope : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck::calculateScope to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return scope; |
+ +461 + | ++ + + + + + | + } |
+ +462 + | ++ + + + + + | +|
+ +463 + | ++ + + + + + | +} |
Mutations | ||
328 | ++ |
+
+
+
+ 1.1 |
+
333 | ++ |
+
+
+
+ 1.1 |
+
338 | ++ |
+
+
+
+ 1.1 |
+
348 | ++ |
+
+
+
+ 1.1 |
+
352 | ++ |
+
+
+
+ 1.1 2.2 |
+
353 | ++ |
+
+
+
+ 1.1 |
+
369 | ++ |
+
+
+
+ 1.1 |
+
373 | ++ |
+
+
+
+ 1.1 2.2 |
+
375 | ++ |
+
+
+
+ 1.1 |
+
385 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
386 | ++ |
+
+
+
+ 1.1 2.2 |
+
387 | ++ |
+
+
+
+ 1.1 |
+
388 | ++ |
+
+
+
+ 1.1 |
+
399 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
400 | ++ |
+
+
+
+ 1.1 2.2 |
+
401 | ++ |
+
+
+
+ 1.1 |
+
413 | ++ |
+
+
+
+ 1.1 |
+
418 | ++ |
+
+
+
+ 1.1 |
+
422 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
435 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 5.5 |
+
438 | ++ |
+
+
+
+ 1.1 |
+
439 | ++ |
+
+
+
+ 1.1 |
+
453 | ++ |
+
+
+
+ 1.1 |
+
460 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Optional; |
+ +23 + | ++ + + + + + | +|
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +30 + | ++ + + + + + | +|
+ +31 + | ++ + + + + + | +/** |
+ +32 + | ++ + + + + + | + * <p> |
+ +33 + | ++ + + + + + | + * Checks for missing Javadoc comments in package-info.java files. |
+ +34 + | ++ + + + + + | + * </p> |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * Rationale: description and other related documentation for a package can be written up |
+ +37 + | ++ + + + + + | + * in the package-info.java file and it gets used in the production of the Javadocs. |
+ +38 + | ++ + + + + + | + * See <a |
+ +39 + | ++ + + + + + | + * href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#packagecomment" |
+ +40 + | ++ + + + + + | + * >link</a> for more info. |
+ +41 + | ++ + + + + + | + * </p> |
+ +42 + | ++ + + + + + | + * <p> |
+ +43 + | ++ + + + + + | + * To configure the check: |
+ +44 + | ++ + + + + + | + * </p> |
+ +45 + | ++ + + + + + | + * <pre> |
+ +46 + | ++ + + + + + | + * <module name="MissingJavadocPackage"/> |
+ +47 + | ++ + + + + + | + * </pre> |
+ +48 + | ++ + + + + + | + * <p>Example:</p> |
+ +49 + | ++ + + + + + | + * <pre> |
+ +50 + | ++ + + + + + | + * /** |
+ +51 + | ++ + + + + + | + * * Provides API classes |
+ +52 + | ++ + + + + + | + * */ |
+ +53 + | ++ + + + + + | + * package com.checkstyle.api; // no violation |
+ +54 + | ++ + + + + + | + * /* |
+ +55 + | ++ + + + + + | + * * Block comment is not a javadoc |
+ +56 + | ++ + + + + + | + * */ |
+ +57 + | ++ + + + + + | + * package com.checkstyle.api; // violation |
+ +58 + | ++ + + + + + | + * </pre> |
+ +59 + | ++ + + + + + | + * |
+ +60 + | ++ + + + + + | + * @since 8.22 |
+ +61 + | ++ + + + + + | + */ |
+ +62 + | ++ + + + + + | +@StatelessCheck |
+ +63 + | ++ + + + + + | +public class MissingJavadocPackageCheck extends AbstractCheck { |
+ +64 + | ++ + + + + + | +|
+ +65 + | ++ + + + + + | + /** |
+ +66 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +67 + | ++ + + + + + | + * file. |
+ +68 + | ++ + + + + + | + */ |
+ +69 + | ++ + + + + + | + public static final String MSG_PKG_JAVADOC_MISSING = "package.javadoc.missing"; |
+ +70 + | ++ + + + + + | +|
+ +71 + | ++ + + + + + | + @Override |
+ +72 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +73 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +74 + | ++ + + + + + | + } |
+ +75 + | ++ + + + + + | +|
+ +76 + | ++ + + + + + | + @Override |
+ +77 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +78 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getRequiredTokens(); |
+ +79 + | ++ + + + + + | + } |
+ +80 + | ++ + + + + + | +|
+ +81 + | ++ + + + + + | + @Override |
+ +82 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +83 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] {TokenTypes.PACKAGE_DEF}; |
+ +84 + | ++ + + + + + | + } |
+ +85 + | ++ + + + + + | +|
+ +86 + | ++ + + + + + | + @Override |
+ +87 + | ++ + + + + + | + public boolean isCommentNodesRequired() { |
+ +88 + | +
+
+2
+
+
+1. isCommentNodesRequired : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::isCommentNodesRequired → KILLED + +2. isCommentNodesRequired : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return true; |
+ +89 + | ++ + + + + + | + } |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + @Override |
+ +92 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +93 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +94 + | +
+
+2
+
+
+1. visitToken : negated conditional → KILLED + +2. visitToken : negated conditional → KILLED + + + + |
+ if (contents.inPackageInfo() && !hasJavadoc(ast)) { |
+ +95 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::log → KILLED + + + + |
+ log(ast, MSG_PKG_JAVADOC_MISSING); |
+ +96 + | ++ + + + + + | + } |
+ +97 + | ++ + + + + + | + } |
+ +98 + | ++ + + + + + | +|
+ +99 + | ++ + + + + + | + /** |
+ +100 + | ++ + + + + + | + * Checks that there is javadoc before ast. |
+ +101 + | ++ + + + + + | + * Because of <a href="https://github.com/checkstyle/checkstyle/issues/4392">parser bug</a> |
+ +102 + | ++ + + + + + | + * parser can place javadoc comment either as previous sibling of package definition |
+ +103 + | ++ + + + + + | + * or (if there is annotation between package def and javadoc) inside package definition tree. |
+ +104 + | ++ + + + + + | + * So we should look for javadoc in both places. |
+ +105 + | ++ + + + + + | + * |
+ +106 + | ++ + + + + + | + * @param ast {@link TokenTypes#PACKAGE_DEF} token to check |
+ +107 + | ++ + + + + + | + * @return true if there is javadoc, false otherwise |
+ +108 + | ++ + + + + + | + */ |
+ +109 + | ++ + + + + + | + private static boolean hasJavadoc(DetailAST ast) { |
+ +110 + | +
+
+1
+
+
+1. hasJavadoc : negated conditional → KILLED + + + + |
+ final boolean hasJavadocBefore = ast.getPreviousSibling() != null |
+ +111 + | +
+
+1
+
+
+1. hasJavadoc : negated conditional → KILLED + + + + |
+ && isJavadoc(ast.getPreviousSibling()); |
+ +112 + | +
+
+4
+
+
+1. hasJavadoc : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::hasJavadoc → KILLED + +2. hasJavadoc : negated conditional → KILLED + +3. hasJavadoc : negated conditional → KILLED + +4. hasJavadoc : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return hasJavadocBefore || hasJavadocAboveAnnotation(ast); |
+ +113 + | ++ + + + + + | + } |
+ +114 + | ++ + + + + + | +|
+ +115 + | ++ + + + + + | + /** |
+ +116 + | ++ + + + + + | + * Checks javadoc existence in annotations list. |
+ +117 + | ++ + + + + + | + * |
+ +118 + | ++ + + + + + | + * @param ast package def |
+ +119 + | ++ + + + + + | + * @return true if there is a javadoc, false otherwise |
+ +120 + | ++ + + + + + | + */ |
+ +121 + | ++ + + + + + | + private static boolean hasJavadocAboveAnnotation(DetailAST ast) { |
+ +122 + | ++ + + + + + | + final Optional<DetailAST> firstAnnotationChild = Optional.of(ast.getFirstChild()) |
+ +123 + | ++ + + + + + | + .map(DetailAST::getFirstChild) |
+ +124 + | ++ + + + + + | + .map(DetailAST::getFirstChild); |
+ +125 + | ++ + + + + + | + boolean result = false; |
+ +126 + | +
+
+1
+
+
+1. hasJavadocAboveAnnotation : negated conditional → KILLED + + + + |
+ if (firstAnnotationChild.isPresent()) { |
+ +127 + | +
+
+1
+
+
+1. hasJavadocAboveAnnotation : negated conditional → KILLED + + + + |
+ for (DetailAST child = firstAnnotationChild.get(); child != null; |
+ +128 + | ++ + + + + + | + child = child.getNextSibling()) { |
+ +129 + | +
+
+1
+
+
+1. hasJavadocAboveAnnotation : negated conditional → KILLED + + + + |
+ if (isJavadoc(child)) { |
+ +130 + | ++ + + + + + | + result = true; |
+ +131 + | ++ + + + + + | + break; |
+ +132 + | ++ + + + + + | + } |
+ +133 + | ++ + + + + + | + } |
+ +134 + | ++ + + + + + | + } |
+ +135 + | +
+
+3
+
+
+1. hasJavadocAboveAnnotation : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::hasJavadocAboveAnnotation → KILLED + +2. hasJavadocAboveAnnotation : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::hasJavadocAboveAnnotation → KILLED + +3. hasJavadocAboveAnnotation : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return result; |
+ +136 + | ++ + + + + + | + } |
+ +137 + | ++ + + + + + | +|
+ +138 + | ++ + + + + + | + /** |
+ +139 + | ++ + + + + + | + * Checks that ast is a javadoc comment. |
+ +140 + | ++ + + + + + | + * |
+ +141 + | ++ + + + + + | + * @param ast token to check |
+ +142 + | ++ + + + + + | + * @return true if ast is a javadoc comment, false otherwise |
+ +143 + | ++ + + + + + | + */ |
+ +144 + | ++ + + + + + | + private static boolean isJavadoc(DetailAST ast) { |
+ +145 + | +
+
+4
+
+
+1. isJavadoc : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheck::isJavadoc → KILLED + +2. isJavadoc : negated conditional → KILLED + +3. isJavadoc : negated conditional → KILLED + +4. isJavadoc : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return ast.getType() == TokenTypes.BLOCK_COMMENT_BEGIN && JavadocUtil.isJavadocComment(ast); |
+ +146 + | ++ + + + + + | + } |
+ +147 + | ++ + + + + + | +} |
Mutations | ||
73 | ++ |
+
+
+
+ 1.1 |
+
78 | ++ |
+
+
+
+ 1.1 |
+
83 | ++ |
+
+
+
+ 1.1 |
+
88 | ++ |
+
+
+
+ 1.1 2.2 |
+
94 | ++ |
+
+
+
+ 1.1 2.2 |
+
95 | ++ |
+
+
+
+ 1.1 |
+
110 | ++ |
+
+
+
+ 1.1 |
+
111 | ++ |
+
+
+
+ 1.1 |
+
112 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
126 | ++ |
+
+
+
+ 1.1 |
+
127 | ++ |
+
+
+
+ 1.1 |
+
129 | ++ |
+
+
+
+ 1.1 |
+
135 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
145 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +|
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.Scope; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +33 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil; |
+ +34 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +35 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; |
+ +36 + | ++ + + + + + | +|
+ +37 + | ++ + + + + + | +/** |
+ +38 + | ++ + + + + + | + * <p> |
+ +39 + | ++ + + + + + | + * Checks for missing Javadoc comments for class, enum, interface, and annotation interface |
+ +40 + | ++ + + + + + | + * definitions. The scope to verify is specified using the {@code Scope} class and defaults |
+ +41 + | ++ + + + + + | + * to {@code Scope.PUBLIC}. To verify another scope, set property scope to one of the |
+ +42 + | ++ + + + + + | + * {@code Scope} constants. |
+ +43 + | ++ + + + + + | + * </p> |
+ +44 + | ++ + + + + + | + * <ul> |
+ +45 + | ++ + + + + + | + * <li> |
+ +46 + | ++ + + + + + | + * Property {@code scope} - specify the visibility scope where Javadoc comments are checked. |
+ +47 + | ++ + + + + + | + * Default value is {@code public}. |
+ +48 + | ++ + + + + + | + * </li> |
+ +49 + | ++ + + + + + | + * <li> |
+ +50 + | ++ + + + + + | + * Property {@code excludeScope} - specify the visibility scope where Javadoc comments are not |
+ +51 + | ++ + + + + + | + * checked. Default value is {@code null}. |
+ +52 + | ++ + + + + + | + * </li> |
+ +53 + | ++ + + + + + | + * <li> |
+ +54 + | ++ + + + + + | + * Property {@code skipAnnotations} - specify the list of annotations that allow missed |
+ +55 + | ++ + + + + + | + * documentation. Only short names are allowed, e.g. {@code Generated}. Default value is |
+ +56 + | ++ + + + + + | + * {@code Generated}. |
+ +57 + | ++ + + + + + | + * </li> |
+ +58 + | ++ + + + + + | + * <li> |
+ +59 + | ++ + + + + + | + * Property {@code tokens} - tokens to check Default value is: |
+ +60 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF"> |
+ +61 + | ++ + + + + + | + * INTERFACE_DEF</a>, |
+ +62 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF"> |
+ +63 + | ++ + + + + + | + * CLASS_DEF</a>, |
+ +64 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF"> |
+ +65 + | ++ + + + + + | + * ENUM_DEF</a>, |
+ +66 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF"> |
+ +67 + | ++ + + + + + | + * ANNOTATION_DEF</a>. |
+ +68 + | ++ + + + + + | + * </li> |
+ +69 + | ++ + + + + + | + * </ul> |
+ +70 + | ++ + + + + + | + * <p> |
+ +71 + | ++ + + + + + | + * To configure the default check to make sure all public class, enum, interface, and annotation |
+ +72 + | ++ + + + + + | + * interface, definitions have javadocs: |
+ +73 + | ++ + + + + + | + * </p> |
+ +74 + | ++ + + + + + | + * <pre> |
+ +75 + | ++ + + + + + | + * <module name="MissingJavadocType"/> |
+ +76 + | ++ + + + + + | + * </pre> |
+ +77 + | ++ + + + + + | + * <p> |
+ +78 + | ++ + + + + + | + * Example: |
+ +79 + | ++ + + + + + | + * </p> |
+ +80 + | ++ + + + + + | + * <pre> |
+ +81 + | ++ + + + + + | + * public class PublicClass {} // violation |
+ +82 + | ++ + + + + + | + * private class PublicClass {} |
+ +83 + | ++ + + + + + | + * protected class PublicClass {} |
+ +84 + | ++ + + + + + | + * class PackagePrivateClass {} |
+ +85 + | ++ + + + + + | + * </pre> |
+ +86 + | ++ + + + + + | + * <p> |
+ +87 + | ++ + + + + + | + * To configure the check for {@code private} scope: |
+ +88 + | ++ + + + + + | + * </p> |
+ +89 + | ++ + + + + + | + * <pre> |
+ +90 + | ++ + + + + + | + * <module name="MissingJavadocType"> |
+ +91 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +92 + | ++ + + + + + | + * </module> |
+ +93 + | ++ + + + + + | + * </pre> |
+ +94 + | ++ + + + + + | + * <p> |
+ +95 + | ++ + + + + + | + * Example: |
+ +96 + | ++ + + + + + | + * </p> |
+ +97 + | ++ + + + + + | + * <pre> |
+ +98 + | ++ + + + + + | + * public class PublicClass {} // violation |
+ +99 + | ++ + + + + + | + * private class PublicClass {} // violation |
+ +100 + | ++ + + + + + | + * protected class PublicClass {} // violation |
+ +101 + | ++ + + + + + | + * class PackagePrivateClass {} // violation |
+ +102 + | ++ + + + + + | + * </pre> |
+ +103 + | ++ + + + + + | + * <p> |
+ +104 + | ++ + + + + + | + * To configure the check for {@code private} classes only: |
+ +105 + | ++ + + + + + | + * </p> |
+ +106 + | ++ + + + + + | + * <pre> |
+ +107 + | ++ + + + + + | + * <module name="MissingJavadocType"> |
+ +108 + | ++ + + + + + | + * <property name="scope" value="private"/> |
+ +109 + | ++ + + + + + | + * <property name="excludeScope" value="package"/> |
+ +110 + | ++ + + + + + | + * </module> |
+ +111 + | ++ + + + + + | + * </pre> |
+ +112 + | ++ + + + + + | + * <p> |
+ +113 + | ++ + + + + + | + * Example: |
+ +114 + | ++ + + + + + | + * </p> |
+ +115 + | ++ + + + + + | + * <pre> |
+ +116 + | ++ + + + + + | + * public class PublicClass {} |
+ +117 + | ++ + + + + + | + * private class PublicClass {} // violation |
+ +118 + | ++ + + + + + | + * protected class PublicClass {} |
+ +119 + | ++ + + + + + | + * class PackagePrivateClass {} |
+ +120 + | ++ + + + + + | + * </pre> |
+ +121 + | ++ + + + + + | + * <p> |
+ +122 + | ++ + + + + + | + * Example that allows missing comments for classes annotated with {@code @SpringBootApplication} |
+ +123 + | ++ + + + + + | + * and {@code @Configuration}: |
+ +124 + | ++ + + + + + | + * </p> |
+ +125 + | ++ + + + + + | + * <pre> |
+ +126 + | ++ + + + + + | + * @SpringBootApplication // no violations about missing comment on class |
+ +127 + | ++ + + + + + | + * public class Application {} |
+ +128 + | ++ + + + + + | + * |
+ +129 + | ++ + + + + + | + * @Configuration // no violations about missing comment on class |
+ +130 + | ++ + + + + + | + * class DatabaseConfiguration {} |
+ +131 + | ++ + + + + + | + * </pre> |
+ +132 + | ++ + + + + + | + * <p> |
+ +133 + | ++ + + + + + | + * Use following configuration: |
+ +134 + | ++ + + + + + | + * </p> |
+ +135 + | ++ + + + + + | + * <pre> |
+ +136 + | ++ + + + + + | + * <module name="MissingJavadocType"> |
+ +137 + | ++ + + + + + | + * <property name="skipAnnotations" value="SpringBootApplication,Configuration"/> |
+ +138 + | ++ + + + + + | + * </module> |
+ +139 + | ++ + + + + + | + * </pre> |
+ +140 + | ++ + + + + + | + * |
+ +141 + | ++ + + + + + | + * @since 8.20 |
+ +142 + | ++ + + + + + | + */ |
+ +143 + | ++ + + + + + | +@StatelessCheck |
+ +144 + | ++ + + + + + | +public class MissingJavadocTypeCheck extends AbstractCheck { |
+ +145 + | ++ + + + + + | +|
+ +146 + | ++ + + + + + | + /** |
+ +147 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +148 + | ++ + + + + + | + * file. |
+ +149 + | ++ + + + + + | + */ |
+ +150 + | ++ + + + + + | + public static final String MSG_JAVADOC_MISSING = "javadoc.missing"; |
+ +151 + | ++ + + + + + | +|
+ +152 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are checked. */ |
+ +153 + | ++ + + + + + | + private Scope scope = Scope.PUBLIC; |
+ +154 + | ++ + + + + + | + /** Specify the visibility scope where Javadoc comments are not checked. */ |
+ +155 + | ++ + + + + + | + private Scope excludeScope; |
+ +156 + | ++ + + + + + | +|
+ +157 + | ++ + + + + + | + /** |
+ +158 + | ++ + + + + + | + * Specify the list of annotations that allow missed documentation. |
+ +159 + | ++ + + + + + | + * Only short names are allowed, e.g. {@code Generated}. |
+ +160 + | ++ + + + + + | + */ |
+ +161 + | ++ + + + + + | + private List<String> skipAnnotations = Collections.singletonList("Generated"); |
+ +162 + | ++ + + + + + | +|
+ +163 + | ++ + + + + + | + /** |
+ +164 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are checked. |
+ +165 + | ++ + + + + + | + * |
+ +166 + | ++ + + + + + | + * @param scope a scope. |
+ +167 + | ++ + + + + + | + */ |
+ +168 + | ++ + + + + + | + public void setScope(Scope scope) { |
+ +169 + | ++ + + + + + | + this.scope = scope; |
+ +170 + | ++ + + + + + | + } |
+ +171 + | ++ + + + + + | +|
+ +172 + | ++ + + + + + | + /** |
+ +173 + | ++ + + + + + | + * Setter to specify the visibility scope where Javadoc comments are not checked. |
+ +174 + | ++ + + + + + | + * |
+ +175 + | ++ + + + + + | + * @param excludeScope a scope. |
+ +176 + | ++ + + + + + | + */ |
+ +177 + | ++ + + + + + | + public void setExcludeScope(Scope excludeScope) { |
+ +178 + | ++ + + + + + | + this.excludeScope = excludeScope; |
+ +179 + | ++ + + + + + | + } |
+ +180 + | ++ + + + + + | +|
+ +181 + | ++ + + + + + | + /** |
+ +182 + | ++ + + + + + | + * Setter to specify the list of annotations that allow missed documentation. |
+ +183 + | ++ + + + + + | + * Only short names are allowed, e.g. {@code Generated}. |
+ +184 + | ++ + + + + + | + * |
+ +185 + | ++ + + + + + | + * @param userAnnotations user's value. |
+ +186 + | ++ + + + + + | + */ |
+ +187 + | ++ + + + + + | + public void setSkipAnnotations(String... userAnnotations) { |
+ +188 + | ++ + + + + + | + skipAnnotations = Arrays.asList(userAnnotations); |
+ +189 + | ++ + + + + + | + } |
+ +190 + | ++ + + + + + | +|
+ +191 + | ++ + + + + + | + @Override |
+ +192 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +193 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableTokens(); |
+ +194 + | ++ + + + + + | + } |
+ +195 + | ++ + + + + + | +|
+ +196 + | ++ + + + + + | + @Override |
+ +197 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +198 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +199 + | ++ + + + + + | + TokenTypes.INTERFACE_DEF, |
+ +200 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +201 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +202 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +203 + | ++ + + + + + | + }; |
+ +204 + | ++ + + + + + | + } |
+ +205 + | ++ + + + + + | +|
+ +206 + | ++ + + + + + | + @Override |
+ +207 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +208 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +209 + | ++ + + + + + | + } |
+ +210 + | ++ + + + + + | +|
+ +211 + | ++ + + + + + | + @Override |
+ +212 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +213 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (shouldCheck(ast)) { |
+ +214 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +215 + | ++ + + + + + | + final int lineNo = ast.getLineNo(); |
+ +216 + | ++ + + + + + | + final TextBlock textBlock = contents.getJavadocBefore(lineNo); |
+ +217 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (textBlock == null) { |
+ +218 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck::log → KILLED + + + + |
+ log(lineNo, MSG_JAVADOC_MISSING); |
+ +219 + | ++ + + + + + | + } |
+ +220 + | ++ + + + + + | + } |
+ +221 + | ++ + + + + + | + } |
+ +222 + | ++ + + + + + | +|
+ +223 + | ++ + + + + + | + /** |
+ +224 + | ++ + + + + + | + * Whether we should check this node. |
+ +225 + | ++ + + + + + | + * |
+ +226 + | ++ + + + + + | + * @param ast a given node. |
+ +227 + | ++ + + + + + | + * @return whether we should check a given node. |
+ +228 + | ++ + + + + + | + */ |
+ +229 + | ++ + + + + + | + private boolean shouldCheck(final DetailAST ast) { |
+ +230 + | ++ + + + + + | + final Scope customScope; |
+ +231 + | ++ + + + + + | +|
+ +232 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
+ +233 + | ++ + + + + + | + customScope = Scope.PUBLIC; |
+ +234 + | ++ + + + + + | + } |
+ +235 + | ++ + + + + + | + else { |
+ +236 + | ++ + + + + + | + final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); |
+ +237 + | ++ + + + + + | + customScope = ScopeUtil.getScopeFromMods(mods); |
+ +238 + | ++ + + + + + | + } |
+ +239 + | ++ + + + + + | + final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); |
+ +240 + | ++ + + + + + | +|
+ +241 + | +
+
+4
+
+
+1. shouldCheck : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck::shouldCheck → KILLED + +2. shouldCheck : negated conditional → KILLED + +3. shouldCheck : negated conditional → KILLED + +4. shouldCheck : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return customScope.isIn(scope) |
+ +242 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ && (surroundingScope == null || surroundingScope.isIn(scope)) |
+ +243 + | ++ + + + + + | + && (excludeScope == null |
+ +244 + | +
+
+2
+
+
+1. shouldCheck : negated conditional → KILLED + +2. shouldCheck : negated conditional → KILLED + + + + |
+ || !customScope.isIn(excludeScope) |
+ +245 + | ++ + + + + + | + || surroundingScope != null |
+ +246 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !surroundingScope.isIn(excludeScope)) |
+ +247 + | +
+
+1
+
+
+1. shouldCheck : negated conditional → KILLED + + + + |
+ && !AnnotationUtil.containsAnnotation(ast, skipAnnotations); |
+ +248 + | ++ + + + + + | + } |
+ +249 + | ++ + + + + + | +|
+ +250 + | ++ + + + + + | +} |
Mutations | ||
193 | ++ |
+
+
+
+ 1.1 |
+
198 | ++ |
+
+
+
+ 1.1 |
+
208 | ++ |
+
+
+
+ 1.1 |
+
213 | ++ |
+
+
+
+ 1.1 |
+
217 | ++ |
+
+
+
+ 1.1 |
+
218 | ++ |
+
+
+
+ 1.1 |
+
232 | ++ |
+
+
+
+ 1.1 |
+
241 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
242 | ++ |
+
+
+
+ 1.1 2.2 |
+
244 | ++ |
+
+
+
+ 1.1 2.2 |
+
246 | ++ |
+
+
+
+ 1.1 |
+
247 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +23 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +24 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +/** |
+ +28 + | ++ + + + + + | + * <p> |
+ +29 + | ++ + + + + + | + * Checks that the at-clause tag is followed by description. |
+ +30 + | ++ + + + + + | + * </p> |
+ +31 + | ++ + + + + + | + * <ul> |
+ +32 + | ++ + + + + + | + * <li> |
+ +33 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +34 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +35 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +36 + | ++ + + + + + | + * Default value is {@code false}. |
+ +37 + | ++ + + + + + | + * </li> |
+ +38 + | ++ + + + + + | + * <li> |
+ +39 + | ++ + + + + + | + * Property {@code javadocTokens} - javadoc tokens to check |
+ +40 + | ++ + + + + + | + * Default value is |
+ +41 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#PARAM_LITERAL"> |
+ +42 + | ++ + + + + + | + * PARAM_LITERAL</a>, |
+ +43 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#RETURN_LITERAL"> |
+ +44 + | ++ + + + + + | + * RETURN_LITERAL</a>, |
+ +45 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#THROWS_LITERAL"> |
+ +46 + | ++ + + + + + | + * THROWS_LITERAL</a>, |
+ +47 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#EXCEPTION_LITERAL"> |
+ +48 + | ++ + + + + + | + * EXCEPTION_LITERAL</a>, |
+ +49 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypes.html#DEPRECATED_LITERAL"> |
+ +50 + | ++ + + + + + | + * DEPRECATED_LITERAL</a>. |
+ +51 + | ++ + + + + + | + * </li> |
+ +52 + | ++ + + + + + | + * </ul> |
+ +53 + | ++ + + + + + | + * <p> |
+ +54 + | ++ + + + + + | + * Default configuration that will check {@code @param}, {@code @return}, |
+ +55 + | ++ + + + + + | + * {@code @throws}, {@code @deprecated}: |
+ +56 + | ++ + + + + + | + * </p> |
+ +57 + | ++ + + + + + | + * <pre> |
+ +58 + | ++ + + + + + | + * <module name="NonEmptyAtclauseDescription"/> |
+ +59 + | ++ + + + + + | + * </pre> |
+ +60 + | ++ + + + + + | + * <p> |
+ +61 + | ++ + + + + + | + * To configure the check to validate only {@code @param} and {@code @return} tags: |
+ +62 + | ++ + + + + + | + * </p> |
+ +63 + | ++ + + + + + | + * <pre> |
+ +64 + | ++ + + + + + | + * <module name="NonEmptyAtclauseDescription"> |
+ +65 + | ++ + + + + + | + * <property name="javadocTokens" value="PARAM_LITERAL,RETURN_LITERAL"/> |
+ +66 + | ++ + + + + + | + * </module> |
+ +67 + | ++ + + + + + | + * </pre> |
+ +68 + | ++ + + + + + | + * |
+ +69 + | ++ + + + + + | + * @since 6.0 |
+ +70 + | ++ + + + + + | + */ |
+ +71 + | ++ + + + + + | +@StatelessCheck |
+ +72 + | ++ + + + + + | +public class NonEmptyAtclauseDescriptionCheck extends AbstractJavadocCheck { |
+ +73 + | ++ + + + + + | +|
+ +74 + | ++ + + + + + | + /** |
+ +75 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +76 + | ++ + + + + + | + * file. |
+ +77 + | ++ + + + + + | + */ |
+ +78 + | ++ + + + + + | + public static final String MSG_KEY = "non.empty.atclause"; |
+ +79 + | ++ + + + + + | +|
+ +80 + | ++ + + + + + | + @Override |
+ +81 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +82 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +83 + | ++ + + + + + | + JavadocTokenTypes.PARAM_LITERAL, |
+ +84 + | ++ + + + + + | + JavadocTokenTypes.RETURN_LITERAL, |
+ +85 + | ++ + + + + + | + JavadocTokenTypes.THROWS_LITERAL, |
+ +86 + | ++ + + + + + | + JavadocTokenTypes.EXCEPTION_LITERAL, |
+ +87 + | ++ + + + + + | + JavadocTokenTypes.DEPRECATED_LITERAL, |
+ +88 + | ++ + + + + + | + }; |
+ +89 + | ++ + + + + + | + } |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + @Override |
+ +92 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +93 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (isEmptyTag(ast.getParent())) { |
+ +94 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_KEY, ast.getText()); |
+ +95 + | ++ + + + + + | + } |
+ +96 + | ++ + + + + + | + } |
+ +97 + | ++ + + + + + | +|
+ +98 + | ++ + + + + + | + /** |
+ +99 + | ++ + + + + + | + * Tests if at-clause tag is empty. |
+ +100 + | ++ + + + + + | + * |
+ +101 + | ++ + + + + + | + * @param tagNode at-clause tag. |
+ +102 + | ++ + + + + + | + * @return true, if at-clause tag is empty. |
+ +103 + | ++ + + + + + | + */ |
+ +104 + | ++ + + + + + | + private static boolean isEmptyTag(DetailNode tagNode) { |
+ +105 + | ++ + + + + + | + final DetailNode tagDescription = |
+ +106 + | ++ + + + + + | + JavadocUtil.findFirstToken(tagNode, JavadocTokenTypes.DESCRIPTION); |
+ +107 + | +
+
+3
+
+
+1. isEmptyTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheck::isEmptyTag → KILLED + +2. isEmptyTag : negated conditional → KILLED + +3. isEmptyTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return tagDescription == null; |
+ +108 + | ++ + + + + + | + } |
+ +109 + | ++ + + + + + | +|
+ +110 + | ++ + + + + + | +} |
Mutations | ||
82 | ++ |
+
+
+
+ 1.1 |
+
93 | ++ |
+
+
+
+ 1.1 |
+
94 | ++ |
+
+
+
+ 1.1 |
+
107 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.ArrayList; |
+ +23 + | ++ + + + + + | +import java.util.Arrays; |
+ +24 + | ++ + + + + + | +import java.util.List; |
+ +25 + | ++ + + + + + | +import java.util.stream.Collectors; |
+ +26 + | ++ + + + + + | +|
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.TokenUtil; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | +/** |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * Checks that a Javadoc block can fit in a single line and doesn't contain at-clauses. |
+ +37 + | ++ + + + + + | + * Javadoc comment that contains at least one at-clause should be formatted in a few lines. |
+ +38 + | ++ + + + + + | + * </p> |
+ +39 + | ++ + + + + + | + * <ul> |
+ +40 + | ++ + + + + + | + * <li> |
+ +41 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +42 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +43 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +44 + | ++ + + + + + | + * Default value is {@code false}. |
+ +45 + | ++ + + + + + | + * </li> |
+ +46 + | ++ + + + + + | + * <li> |
+ +47 + | ++ + + + + + | + * Property {@code ignoredTags} - Specify at-clauses which are ignored by the check. |
+ +48 + | ++ + + + + + | + * Default value is {@code {}}. |
+ +49 + | ++ + + + + + | + * </li> |
+ +50 + | ++ + + + + + | + * <li> |
+ +51 + | ++ + + + + + | + * Property {@code ignoreInlineTags} - Control whether inline tags must be ignored. |
+ +52 + | ++ + + + + + | + * Default value is {@code true}. |
+ +53 + | ++ + + + + + | + * </li> |
+ +54 + | ++ + + + + + | + * </ul> |
+ +55 + | ++ + + + + + | + * <p> |
+ +56 + | ++ + + + + + | + * To configure the check: |
+ +57 + | ++ + + + + + | + * </p> |
+ +58 + | ++ + + + + + | + * <pre> |
+ +59 + | ++ + + + + + | + * <module name="SingleLineJavadoc"/> |
+ +60 + | ++ + + + + + | + * </pre> |
+ +61 + | ++ + + + + + | + * <p> |
+ +62 + | ++ + + + + + | + * To configure the check with a list of ignored at-clauses |
+ +63 + | ++ + + + + + | + * and make inline at-clauses not ignored: |
+ +64 + | ++ + + + + + | + * </p> |
+ +65 + | ++ + + + + + | + * <pre> |
+ +66 + | ++ + + + + + | + * <module name="SingleLineJavadoc"> |
+ +67 + | ++ + + + + + | + * <property name="ignoredTags" value="@inheritDoc, @see"/> |
+ +68 + | ++ + + + + + | + * <property name="ignoreInlineTags" value="false"/> |
+ +69 + | ++ + + + + + | + * </module> |
+ +70 + | ++ + + + + + | + * </pre> |
+ +71 + | ++ + + + + + | + * |
+ +72 + | ++ + + + + + | + * @since 6.0 |
+ +73 + | ++ + + + + + | + */ |
+ +74 + | ++ + + + + + | +@StatelessCheck |
+ +75 + | ++ + + + + + | +public class SingleLineJavadocCheck extends AbstractJavadocCheck { |
+ +76 + | ++ + + + + + | +|
+ +77 + | ++ + + + + + | + /** |
+ +78 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +79 + | ++ + + + + + | + * file. |
+ +80 + | ++ + + + + + | + */ |
+ +81 + | ++ + + + + + | + public static final String MSG_KEY = "singleline.javadoc"; |
+ +82 + | ++ + + + + + | +|
+ +83 + | ++ + + + + + | + /** |
+ +84 + | ++ + + + + + | + * Specify at-clauses which are ignored by the check. |
+ +85 + | ++ + + + + + | + */ |
+ +86 + | +
+
+1
+
+
+1. + + |
+ private List<String> ignoredTags = new ArrayList<>(); |
+ +87 + | ++ + + + + + | +|
+ +88 + | ++ + + + + + | + /** Control whether inline tags must be ignored. */ |
+ +89 + | ++ + + + + + | + private boolean ignoreInlineTags = true; |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + /** |
+ +92 + | ++ + + + + + | + * Setter to specify at-clauses which are ignored by the check. |
+ +93 + | ++ + + + + + | + * |
+ +94 + | ++ + + + + + | + * @param tags to be ignored by check. |
+ +95 + | ++ + + + + + | + */ |
+ +96 + | ++ + + + + + | + public void setIgnoredTags(String... tags) { |
+ +97 + | ++ + + + + + | + ignoredTags = Arrays.stream(tags).collect(Collectors.toList()); |
+ +98 + | ++ + + + + + | + } |
+ +99 + | ++ + + + + + | +|
+ +100 + | ++ + + + + + | + /** |
+ +101 + | ++ + + + + + | + * Setter to control whether inline tags must be ignored. |
+ +102 + | ++ + + + + + | + * |
+ +103 + | ++ + + + + + | + * @param ignoreInlineTags whether inline tags must be ignored. |
+ +104 + | ++ + + + + + | + */ |
+ +105 + | ++ + + + + + | + public void setIgnoreInlineTags(boolean ignoreInlineTags) { |
+ +106 + | ++ + + + + + | + this.ignoreInlineTags = ignoreInlineTags; |
+ +107 + | ++ + + + + + | + } |
+ +108 + | ++ + + + + + | +|
+ +109 + | ++ + + + + + | + @Override |
+ +110 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +111 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +112 + | ++ + + + + + | + JavadocTokenTypes.JAVADOC, |
+ +113 + | ++ + + + + + | + }; |
+ +114 + | ++ + + + + + | + } |
+ +115 + | ++ + + + + + | +|
+ +116 + | ++ + + + + + | + @Override |
+ +117 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +118 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +119 + | ++ + + + + + | + } |
+ +120 + | ++ + + + + + | +|
+ +121 + | ++ + + + + + | + @Override |
+ +122 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +123 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (isSingleLineJavadoc(getBlockCommentAst()) |
+ +124 + | +
+
+3
+
+
+1. visitJavadocToken : negated conditional → KILLED + +2. visitJavadocToken : negated conditional → KILLED + +3. visitJavadocToken : negated conditional → KILLED + + + + |
+ && (hasJavadocTags(ast) || !ignoreInlineTags && hasJavadocInlineTags(ast))) { |
+ +125 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_KEY); |
+ +126 + | ++ + + + + + | + } |
+ +127 + | ++ + + + + + | + } |
+ +128 + | ++ + + + + + | +|
+ +129 + | ++ + + + + + | + /** |
+ +130 + | ++ + + + + + | + * Checks if comment is single line comment. |
+ +131 + | ++ + + + + + | + * |
+ +132 + | ++ + + + + + | + * @param blockCommentStart the AST tree in which a block comment starts |
+ +133 + | ++ + + + + + | + * @return true, if comment is single line comment. |
+ +134 + | ++ + + + + + | + */ |
+ +135 + | ++ + + + + + | + private static boolean isSingleLineJavadoc(DetailAST blockCommentStart) { |
+ +136 + | ++ + + + + + | + final DetailAST blockCommentEnd = blockCommentStart.getLastChild(); |
+ +137 + | +
+
+3
+
+
+1. isSingleLineJavadoc : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::isSingleLineJavadoc → KILLED + +2. isSingleLineJavadoc : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::isSingleLineJavadoc → KILLED + +3. isSingleLineJavadoc : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return TokenUtil.areOnSameLine(blockCommentStart, blockCommentEnd); |
+ +138 + | ++ + + + + + | + } |
+ +139 + | ++ + + + + + | +|
+ +140 + | ++ + + + + + | + /** |
+ +141 + | ++ + + + + + | + * Checks if comment has javadoc tags which are not ignored. Also works |
+ +142 + | ++ + + + + + | + * on custom tags. As block tags can be interpreted only at the beginning of a line, |
+ +143 + | ++ + + + + + | + * only the first instance is checked. |
+ +144 + | ++ + + + + + | + * |
+ +145 + | ++ + + + + + | + * @param javadocRoot javadoc root node. |
+ +146 + | ++ + + + + + | + * @return true, if comment has javadoc tags which are not ignored. |
+ +147 + | ++ + + + + + | + * @see <a href= |
+ +148 + | ++ + + + + + | + * "https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#blockandinlinetags"> |
+ +149 + | ++ + + + + + | + * Block and inline tags</a> |
+ +150 + | ++ + + + + + | + */ |
+ +151 + | ++ + + + + + | + private boolean hasJavadocTags(DetailNode javadocRoot) { |
+ +152 + | ++ + + + + + | + final DetailNode javadocTagSection = |
+ +153 + | ++ + + + + + | + JavadocUtil.findFirstToken(javadocRoot, JavadocTokenTypes.JAVADOC_TAG); |
+ +154 + | +
+
+4
+
+
+1. hasJavadocTags : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::hasJavadocTags → KILLED + +2. hasJavadocTags : negated conditional → KILLED + +3. hasJavadocTags : negated conditional → KILLED + +4. hasJavadocTags : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return javadocTagSection != null && !isTagIgnored(javadocTagSection); |
+ +155 + | ++ + + + + + | + } |
+ +156 + | ++ + + + + + | +|
+ +157 + | ++ + + + + + | + /** |
+ +158 + | ++ + + + + + | + * Checks if comment has in-line tags which are not ignored. |
+ +159 + | ++ + + + + + | + * |
+ +160 + | ++ + + + + + | + * @param javadocRoot javadoc root node. |
+ +161 + | ++ + + + + + | + * @return true, if comment has in-line tags which are not ignored. |
+ +162 + | ++ + + + + + | + * @see <a href= |
+ +163 + | ++ + + + + + | + * "https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadoctags"> |
+ +164 + | ++ + + + + + | + * JavadocTags</a> |
+ +165 + | ++ + + + + + | + */ |
+ +166 + | ++ + + + + + | + private boolean hasJavadocInlineTags(DetailNode javadocRoot) { |
+ +167 + | ++ + + + + + | + DetailNode javadocTagSection = |
+ +168 + | ++ + + + + + | + JavadocUtil.findFirstToken(javadocRoot, JavadocTokenTypes.JAVADOC_INLINE_TAG); |
+ +169 + | ++ + + + + + | + boolean foundTag = false; |
+ +170 + | +
+
+1
+
+
+1. hasJavadocInlineTags : negated conditional → KILLED + + + + |
+ while (javadocTagSection != null) { |
+ +171 + | +
+
+1
+
+
+1. hasJavadocInlineTags : negated conditional → KILLED + + + + |
+ if (!isTagIgnored(javadocTagSection)) { |
+ +172 + | ++ + + + + + | + foundTag = true; |
+ +173 + | ++ + + + + + | + break; |
+ +174 + | ++ + + + + + | + } |
+ +175 + | ++ + + + + + | + javadocTagSection = JavadocUtil.getNextSibling( |
+ +176 + | ++ + + + + + | + javadocTagSection, JavadocTokenTypes.JAVADOC_INLINE_TAG); |
+ +177 + | ++ + + + + + | + } |
+ +178 + | +
+
+3
+
+
+1. hasJavadocInlineTags : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::hasJavadocInlineTags → KILLED + +2. hasJavadocInlineTags : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::hasJavadocInlineTags → KILLED + +3. hasJavadocInlineTags : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return foundTag; |
+ +179 + | ++ + + + + + | + } |
+ +180 + | ++ + + + + + | +|
+ +181 + | ++ + + + + + | + /** |
+ +182 + | ++ + + + + + | + * Checks if list of ignored tags contains javadocTagSection's javadoc tag. |
+ +183 + | ++ + + + + + | + * |
+ +184 + | ++ + + + + + | + * @param javadocTagSection to check javadoc tag in. |
+ +185 + | ++ + + + + + | + * @return true, if ignoredTags contains javadocTagSection's javadoc tag. |
+ +186 + | ++ + + + + + | + */ |
+ +187 + | ++ + + + + + | + private boolean isTagIgnored(DetailNode javadocTagSection) { |
+ +188 + | +
+
+3
+
+
+1. isTagIgnored : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::isTagIgnored → KILLED + +2. isTagIgnored : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck::isTagIgnored → KILLED + +3. isTagIgnored : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return ignoredTags.contains(JavadocUtil.getTagName(javadocTagSection)); |
+ +189 + | ++ + + + + + | + } |
+ +190 + | ++ + + + + + | +|
+ +191 + | ++ + + + + + | +} |
Mutations | ||
86 | ++ |
+
+
+
+ 1.1 |
+
111 | ++ |
+
+
+
+ 1.1 |
+
118 | ++ |
+
+
+
+ 1.1 |
+
123 | ++ |
+
+
+
+ 1.1 |
+
124 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
125 | ++ |
+
+
+
+ 1.1 |
+
137 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
154 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
170 | ++ |
+
+
+
+ 1.1 |
+
171 | ++ |
+
+
+
+ 1.1 |
+
178 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
188 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.Arrays; |
+ +23 + | ++ + + + + + | +import java.util.Collections; |
+ +24 + | ++ + + + + + | +import java.util.HashSet; |
+ +25 + | ++ + + + + + | +import java.util.Set; |
+ +26 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +27 + | ++ + + + + + | +|
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailNode; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | +/** |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * Checks that |
+ +37 + | ++ + + + + + | + * <a href="https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#firstsentence"> |
+ +38 + | ++ + + + + + | + * Javadoc summary sentence</a> does not contain phrases that are not recommended to use. |
+ +39 + | ++ + + + + + | + * Summaries that contain only the {@code {@inheritDoc}} tag are skipped. |
+ +40 + | ++ + + + + + | + * Check also violate Javadoc that does not contain first sentence. |
+ +41 + | ++ + + + + + | + * </p> |
+ +42 + | ++ + + + + + | + * <ul> |
+ +43 + | ++ + + + + + | + * <li> |
+ +44 + | ++ + + + + + | + * Property {@code violateExecutionOnNonTightHtml} - Control when to print violations |
+ +45 + | ++ + + + + + | + * if the Javadoc being examined by this check violates the tight html rules defined at |
+ +46 + | ++ + + + + + | + * <a href="https://checkstyle.org/writingjavadocchecks.html#Tight-HTML_rules">Tight-HTML Rules</a>. |
+ +47 + | ++ + + + + + | + * Default value is {@code false}. |
+ +48 + | ++ + + + + + | + * </li> |
+ +49 + | ++ + + + + + | + * <li> |
+ +50 + | ++ + + + + + | + * Property {@code forbiddenSummaryFragments} - Specify the regexp for forbidden summary fragments. |
+ +51 + | ++ + + + + + | + * Default value is {@code "^$" (empty)}. |
+ +52 + | ++ + + + + + | + * </li> |
+ +53 + | ++ + + + + + | + * <li> |
+ +54 + | ++ + + + + + | + * Property {@code period} - Specify the period symbol at the end of first javadoc sentence. |
+ +55 + | ++ + + + + + | + * Default value is {@code "."}. |
+ +56 + | ++ + + + + + | + * </li> |
+ +57 + | ++ + + + + + | + * </ul> |
+ +58 + | ++ + + + + + | + * <p> |
+ +59 + | ++ + + + + + | + * By default Check validate that first sentence is not empty and first sentence is not missing: |
+ +60 + | ++ + + + + + | + * </p> |
+ +61 + | ++ + + + + + | + * <pre> |
+ +62 + | ++ + + + + + | + * <module name="SummaryJavadocCheck"/> |
+ +63 + | ++ + + + + + | + * </pre> |
+ +64 + | ++ + + + + + | + * <p> |
+ +65 + | ++ + + + + + | + * Example of {@code {@inheritDoc}} without summary. |
+ +66 + | ++ + + + + + | + * </p> |
+ +67 + | ++ + + + + + | + * <pre> |
+ +68 + | ++ + + + + + | + * public class Test extends Exception { |
+ +69 + | ++ + + + + + | + * //Valid |
+ +70 + | ++ + + + + + | + * /** |
+ +71 + | ++ + + + + + | + * * {@inheritDoc} |
+ +72 + | ++ + + + + + | + * */ |
+ +73 + | ++ + + + + + | + * public String ValidFunction(){ |
+ +74 + | ++ + + + + + | + * return ""; |
+ +75 + | ++ + + + + + | + * } |
+ +76 + | ++ + + + + + | + * //Violation |
+ +77 + | ++ + + + + + | + * /** |
+ +78 + | ++ + + + + + | + * * |
+ +79 + | ++ + + + + + | + * */ |
+ +80 + | ++ + + + + + | + * public String InvalidFunction(){ |
+ +81 + | ++ + + + + + | + * return ""; |
+ +82 + | ++ + + + + + | + * } |
+ +83 + | ++ + + + + + | + * } |
+ +84 + | ++ + + + + + | + * </pre> |
+ +85 + | ++ + + + + + | + * <p> |
+ +86 + | ++ + + + + + | + * To ensure that summary do not contain phrase like "This method returns", |
+ +87 + | ++ + + + + + | + * use following config: |
+ +88 + | ++ + + + + + | + * </p> |
+ +89 + | ++ + + + + + | + * <pre> |
+ +90 + | ++ + + + + + | + * <module name="SummaryJavadocCheck"> |
+ +91 + | ++ + + + + + | + * <property name="forbiddenSummaryFragments" |
+ +92 + | ++ + + + + + | + * value="^This method returns.*"/> |
+ +93 + | ++ + + + + + | + * </module> |
+ +94 + | ++ + + + + + | + * </pre> |
+ +95 + | ++ + + + + + | + * <p> |
+ +96 + | ++ + + + + + | + * To specify period symbol at the end of first javadoc sentence: |
+ +97 + | ++ + + + + + | + * </p> |
+ +98 + | ++ + + + + + | + * <pre> |
+ +99 + | ++ + + + + + | + * <module name="SummaryJavadocCheck"> |
+ +100 + | ++ + + + + + | + * <property name="period" value="。"/> |
+ +101 + | ++ + + + + + | + * </module> |
+ +102 + | ++ + + + + + | + * </pre> |
+ +103 + | ++ + + + + + | + * <p> |
+ +104 + | ++ + + + + + | + * Example of period property. |
+ +105 + | ++ + + + + + | + * </p> |
+ +106 + | ++ + + + + + | + * <pre> |
+ +107 + | ++ + + + + + | + * public class TestClass { |
+ +108 + | ++ + + + + + | + * /** |
+ +109 + | ++ + + + + + | + * * This is invalid java doc. |
+ +110 + | ++ + + + + + | + * */ |
+ +111 + | ++ + + + + + | + * void invalidJavaDocMethod() { |
+ +112 + | ++ + + + + + | + * } |
+ +113 + | ++ + + + + + | + * /** |
+ +114 + | ++ + + + + + | + * * This is valid java doc。 |
+ +115 + | ++ + + + + + | + * */ |
+ +116 + | ++ + + + + + | + * void validJavaDocMethod() { |
+ +117 + | ++ + + + + + | + * } |
+ +118 + | ++ + + + + + | + * } |
+ +119 + | ++ + + + + + | + * </pre> |
+ +120 + | ++ + + + + + | + * |
+ +121 + | ++ + + + + + | + * @since 6.0 |
+ +122 + | ++ + + + + + | + */ |
+ +123 + | ++ + + + + + | +@StatelessCheck |
+ +124 + | ++ + + + + + | +public class SummaryJavadocCheck extends AbstractJavadocCheck { |
+ +125 + | ++ + + + + + | +|
+ +126 + | ++ + + + + + | + /** |
+ +127 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +128 + | ++ + + + + + | + * file. |
+ +129 + | ++ + + + + + | + */ |
+ +130 + | ++ + + + + + | + public static final String MSG_SUMMARY_FIRST_SENTENCE = "summary.first.sentence"; |
+ +131 + | ++ + + + + + | +|
+ +132 + | ++ + + + + + | + /** |
+ +133 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +134 + | ++ + + + + + | + * file. |
+ +135 + | ++ + + + + + | + */ |
+ +136 + | ++ + + + + + | + public static final String MSG_SUMMARY_JAVADOC = "summary.javaDoc"; |
+ +137 + | ++ + + + + + | + /** |
+ +138 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +139 + | ++ + + + + + | + * file. |
+ +140 + | ++ + + + + + | + */ |
+ +141 + | ++ + + + + + | + public static final String MSG_SUMMARY_JAVADOC_MISSING = "summary.javaDoc.missing"; |
+ +142 + | ++ + + + + + | + /** |
+ +143 + | ++ + + + + + | + * This regexp is used to convert multiline javadoc to single line without stars. |
+ +144 + | ++ + + + + + | + */ |
+ +145 + | ++ + + + + + | + private static final Pattern JAVADOC_MULTILINE_TO_SINGLELINE_PATTERN = |
+ +146 + | ++ + + + + + | + Pattern.compile("\n[ ]+(\\*)|^[ ]+(\\*)"); |
+ +147 + | ++ + + + + + | +|
+ +148 + | ++ + + + + + | + /** Period literal. */ |
+ +149 + | ++ + + + + + | + private static final String PERIOD = "."; |
+ +150 + | ++ + + + + + | +|
+ +151 + | ++ + + + + + | + /** Set of allowed Tokens tags in summary java doc. */ |
+ +152 + | ++ + + + + + | + private static final Set<Integer> ALLOWED_TYPES = Collections.unmodifiableSet( |
+ +153 + | ++ + + + + + | + new HashSet<>(Arrays.asList(JavadocTokenTypes.TEXT, |
+ +154 + | ++ + + + + + | + JavadocTokenTypes.WS)) |
+ +155 + | ++ + + + + + | + ); |
+ +156 + | ++ + + + + + | +|
+ +157 + | ++ + + + + + | + /** Specify the regexp for forbidden summary fragments. */ |
+ +158 + | ++ + + + + + | + private Pattern forbiddenSummaryFragments = CommonUtil.createPattern("^$"); |
+ +159 + | ++ + + + + + | +|
+ +160 + | ++ + + + + + | + /** Specify the period symbol at the end of first javadoc sentence. */ |
+ +161 + | ++ + + + + + | + private String period = PERIOD; |
+ +162 + | ++ + + + + + | +|
+ +163 + | ++ + + + + + | + /** |
+ +164 + | ++ + + + + + | + * Setter to specify the regexp for forbidden summary fragments. |
+ +165 + | ++ + + + + + | + * |
+ +166 + | ++ + + + + + | + * @param pattern a pattern. |
+ +167 + | ++ + + + + + | + */ |
+ +168 + | ++ + + + + + | + public void setForbiddenSummaryFragments(Pattern pattern) { |
+ +169 + | ++ + + + + + | + forbiddenSummaryFragments = pattern; |
+ +170 + | ++ + + + + + | + } |
+ +171 + | ++ + + + + + | +|
+ +172 + | ++ + + + + + | + /** |
+ +173 + | ++ + + + + + | + * Setter to specify the period symbol at the end of first javadoc sentence. |
+ +174 + | ++ + + + + + | + * |
+ +175 + | ++ + + + + + | + * @param period period's value. |
+ +176 + | ++ + + + + + | + */ |
+ +177 + | ++ + + + + + | + public void setPeriod(String period) { |
+ +178 + | ++ + + + + + | + this.period = period; |
+ +179 + | ++ + + + + + | + } |
+ +180 + | ++ + + + + + | +|
+ +181 + | ++ + + + + + | + @Override |
+ +182 + | ++ + + + + + | + public int[] getDefaultJavadocTokens() { |
+ +183 + | +
+
+1
+
+
+1. getDefaultJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::getDefaultJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] { |
+ +184 + | ++ + + + + + | + JavadocTokenTypes.JAVADOC, |
+ +185 + | ++ + + + + + | + }; |
+ +186 + | ++ + + + + + | + } |
+ +187 + | ++ + + + + + | +|
+ +188 + | ++ + + + + + | + @Override |
+ +189 + | ++ + + + + + | + public int[] getRequiredJavadocTokens() { |
+ +190 + | +
+
+1
+
+
+1. getRequiredJavadocTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::getRequiredJavadocTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return getAcceptableJavadocTokens(); |
+ +191 + | ++ + + + + + | + } |
+ +192 + | ++ + + + + + | +|
+ +193 + | ++ + + + + + | + @Override |
+ +194 + | ++ + + + + + | + public void visitJavadocToken(DetailNode ast) { |
+ +195 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!startsWithInheritDoc(ast)) { |
+ +196 + | ++ + + + + + | + final String summaryDoc = getSummarySentence(ast); |
+ +197 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (summaryDoc.isEmpty()) { |
+ +198 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_SUMMARY_JAVADOC_MISSING); |
+ +199 + | ++ + + + + + | + } |
+ +200 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ else if (!period.isEmpty()) { |
+ +201 + | ++ + + + + + | + final String firstSentence = getFirstSentence(ast); |
+ +202 + | ++ + + + + + | + final int endOfSentence = firstSentence.lastIndexOf(period); |
+ +203 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (!summaryDoc.contains(period)) { |
+ +204 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_SUMMARY_FIRST_SENTENCE); |
+ +205 + | ++ + + + + + | + } |
+ +206 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ if (endOfSentence != -1 |
+ +207 + | +
+
+1
+
+
+1. visitJavadocToken : negated conditional → KILLED + + + + |
+ && containsForbiddenFragment(firstSentence.substring(0, endOfSentence))) { |
+ +208 + | +
+
+1
+
+
+1. visitJavadocToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::log → KILLED + + + + |
+ log(ast.getLineNumber(), MSG_SUMMARY_JAVADOC); |
+ +209 + | ++ + + + + + | + } |
+ +210 + | ++ + + + + + | + } |
+ +211 + | ++ + + + + + | + } |
+ +212 + | ++ + + + + + | + } |
+ +213 + | ++ + + + + + | +|
+ +214 + | ++ + + + + + | + /** |
+ +215 + | ++ + + + + + | + * Checks if the node starts with an {@inheritDoc}. |
+ +216 + | ++ + + + + + | + * |
+ +217 + | ++ + + + + + | + * @param root The root node to examine. |
+ +218 + | ++ + + + + + | + * @return {@code true} if the javadoc starts with an {@inheritDoc}. |
+ +219 + | ++ + + + + + | + */ |
+ +220 + | ++ + + + + + | + private static boolean startsWithInheritDoc(DetailNode root) { |
+ +221 + | ++ + + + + + | + boolean found = false; |
+ +222 + | ++ + + + + + | + final DetailNode[] children = root.getChildren(); |
+ +223 + | ++ + + + + + | +|
+ +224 + | +
+
+2
+
+
+1. startsWithInheritDoc : Changed increment from 1 to -1 → KILLED + +2. startsWithInheritDoc : negated conditional → KILLED + + + + |
+ for (int i = 0; !found; i++) { |
+ +225 + | ++ + + + + + | + final DetailNode child = children[i]; |
+ +226 + | +
+
+1
+
+
+1. startsWithInheritDoc : negated conditional → KILLED + + + + |
+ if (child.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG |
+ +227 + | +
+
+1
+
+
+1. startsWithInheritDoc : negated conditional → KILLED + + + + |
+ && child.getChildren()[1].getType() == JavadocTokenTypes.INHERIT_DOC_LITERAL) { |
+ +228 + | ++ + + + + + | + found = true; |
+ +229 + | ++ + + + + + | + } |
+ +230 + | +
+
+1
+
+
+1. startsWithInheritDoc : negated conditional → KILLED + + + + |
+ else if (child.getType() != JavadocTokenTypes.LEADING_ASTERISK |
+ +231 + | +
+
+1
+
+
+1. startsWithInheritDoc : negated conditional → KILLED + + + + |
+ && !CommonUtil.isBlank(child.getText())) { |
+ +232 + | ++ + + + + + | + break; |
+ +233 + | ++ + + + + + | + } |
+ +234 + | ++ + + + + + | + } |
+ +235 + | ++ + + + + + | +|
+ +236 + | +
+
+3
+
+
+1. startsWithInheritDoc : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::startsWithInheritDoc → KILLED + +2. startsWithInheritDoc : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::startsWithInheritDoc → KILLED + +3. startsWithInheritDoc : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return found; |
+ +237 + | ++ + + + + + | + } |
+ +238 + | ++ + + + + + | +|
+ +239 + | ++ + + + + + | + /** |
+ +240 + | ++ + + + + + | + * Checks if period is at the end of sentence. |
+ +241 + | ++ + + + + + | + * |
+ +242 + | ++ + + + + + | + * @param ast Javadoc root node. |
+ +243 + | ++ + + + + + | + * @return violation string |
+ +244 + | ++ + + + + + | + */ |
+ +245 + | ++ + + + + + | + private static String getSummarySentence(DetailNode ast) { |
+ +246 + | ++ + + + + + | + boolean flag = true; |
+ +247 + | +
+
+1
+
+
+1. getSummarySentence : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder result = new StringBuilder(256); |
+ +248 + | ++ + + + + + | + for (DetailNode child : ast.getChildren()) { |
+ +249 + | +
+
+1
+
+
+1. getSummarySentence : negated conditional → KILLED + + + + |
+ if (ALLOWED_TYPES.contains(child.getType())) { |
+ +250 + | ++ + + + + + | + result.append(child.getText()); |
+ +251 + | ++ + + + + + | + } |
+ +252 + | +
+
+1
+
+
+1. getSummarySentence : negated conditional → KILLED + + + + |
+ else if (child.getType() == JavadocTokenTypes.HTML_ELEMENT |
+ +253 + | +
+
+1
+
+
+1. getSummarySentence : negated conditional → KILLED + + + + |
+ && CommonUtil.isBlank(result.toString().trim())) { |
+ +254 + | ++ + + + + + | + result.append(getStringInsideTag(result.toString(), |
+ +255 + | ++ + + + + + | + child.getChildren()[0].getChildren()[0])); |
+ +256 + | ++ + + + + + | + } |
+ +257 + | +
+
+1
+
+
+1. getSummarySentence : negated conditional → KILLED + + + + |
+ else if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) { |
+ +258 + | ++ + + + + + | + flag = false; |
+ +259 + | ++ + + + + + | + } |
+ +260 + | +
+
+1
+
+
+1. getSummarySentence : negated conditional → KILLED + + + + |
+ if (!flag) { |
+ +261 + | ++ + + + + + | + break; |
+ +262 + | ++ + + + + + | + } |
+ +263 + | ++ + + + + + | + } |
+ +264 + | +
+
+1
+
+
+1. getSummarySentence : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::getSummarySentence to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result.toString().trim(); |
+ +265 + | ++ + + + + + | + } |
+ +266 + | ++ + + + + + | +|
+ +267 + | ++ + + + + + | + /** |
+ +268 + | ++ + + + + + | + * Concatenates string within text of html tags. |
+ +269 + | ++ + + + + + | + * |
+ +270 + | ++ + + + + + | + * @param result javadoc string |
+ +271 + | ++ + + + + + | + * @param detailNode javadoc tag node |
+ +272 + | ++ + + + + + | + * @return java doc tag content appended in result |
+ +273 + | ++ + + + + + | + */ |
+ +274 + | ++ + + + + + | + private static String getStringInsideTag(String result, DetailNode detailNode) { |
+ +275 + | +
+
+1
+
+
+1. getStringInsideTag : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder contents = new StringBuilder(result); |
+ +276 + | ++ + + + + + | + DetailNode tempNode = detailNode; |
+ +277 + | +
+
+1
+
+
+1. getStringInsideTag : negated conditional → KILLED + + + + |
+ while (tempNode != null) { |
+ +278 + | +
+
+1
+
+
+1. getStringInsideTag : negated conditional → KILLED + + + + |
+ if (tempNode.getType() == JavadocTokenTypes.TEXT) { |
+ +279 + | ++ + + + + + | + contents.append(tempNode.getText()); |
+ +280 + | ++ + + + + + | + } |
+ +281 + | ++ + + + + + | + tempNode = JavadocUtil.getNextSibling(tempNode); |
+ +282 + | ++ + + + + + | + } |
+ +283 + | +
+
+1
+
+
+1. getStringInsideTag : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::getStringInsideTag to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return contents.toString(); |
+ +284 + | ++ + + + + + | + } |
+ +285 + | ++ + + + + + | +|
+ +286 + | ++ + + + + + | + /** |
+ +287 + | ++ + + + + + | + * Finds and returns first sentence. |
+ +288 + | ++ + + + + + | + * |
+ +289 + | ++ + + + + + | + * @param ast Javadoc root node. |
+ +290 + | ++ + + + + + | + * @return first sentence. |
+ +291 + | ++ + + + + + | + */ |
+ +292 + | ++ + + + + + | + private static String getFirstSentence(DetailNode ast) { |
+ +293 + | +
+
+1
+
+
+1. getFirstSentence : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder result = new StringBuilder(256); |
+ +294 + | ++ + + + + + | + final String periodSuffix = PERIOD + ' '; |
+ +295 + | ++ + + + + + | + for (DetailNode child : ast.getChildren()) { |
+ +296 + | ++ + + + + + | + final String text; |
+ +297 + | +
+
+1
+
+
+1. getFirstSentence : negated conditional → KILLED + + + + |
+ if (child.getChildren().length == 0) { |
+ +298 + | ++ + + + + + | + text = child.getText(); |
+ +299 + | ++ + + + + + | + } |
+ +300 + | ++ + + + + + | + else { |
+ +301 + | ++ + + + + + | + text = getFirstSentence(child); |
+ +302 + | ++ + + + + + | + } |
+ +303 + | ++ + + + + + | +|
+ +304 + | +
+
+1
+
+
+1. getFirstSentence : negated conditional → KILLED + + + + |
+ if (text.contains(periodSuffix)) { |
+ +305 + | +
+
+1
+
+
+1. getFirstSentence : Replaced integer addition with subtraction → KILLED + + + + |
+ result.append(text, 0, text.indexOf(periodSuffix) + 1); |
+ +306 + | ++ + + + + + | + break; |
+ +307 + | ++ + + + + + | + } |
+ +308 + | ++ + + + + + | +|
+ +309 + | ++ + + + + + | + result.append(text); |
+ +310 + | ++ + + + + + | + } |
+ +311 + | +
+
+1
+
+
+1. getFirstSentence : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::getFirstSentence to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result.toString(); |
+ +312 + | ++ + + + + + | + } |
+ +313 + | ++ + + + + + | +|
+ +314 + | ++ + + + + + | + /** |
+ +315 + | ++ + + + + + | + * Tests if first sentence contains forbidden summary fragment. |
+ +316 + | ++ + + + + + | + * |
+ +317 + | ++ + + + + + | + * @param firstSentence String with first sentence. |
+ +318 + | ++ + + + + + | + * @return true, if first sentence contains forbidden summary fragment. |
+ +319 + | ++ + + + + + | + */ |
+ +320 + | ++ + + + + + | + private boolean containsForbiddenFragment(String firstSentence) { |
+ +321 + | ++ + + + + + | + final String javadocText = JAVADOC_MULTILINE_TO_SINGLELINE_PATTERN |
+ +322 + | ++ + + + + + | + .matcher(firstSentence).replaceAll(" ").trim(); |
+ +323 + | +
+
+3
+
+
+1. containsForbiddenFragment : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::containsForbiddenFragment → KILLED + +2. containsForbiddenFragment : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::containsForbiddenFragment → KILLED + +3. containsForbiddenFragment : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return forbiddenSummaryFragments.matcher(trimExcessWhitespaces(javadocText)).find(); |
+ +324 + | ++ + + + + + | + } |
+ +325 + | ++ + + + + + | +|
+ +326 + | ++ + + + + + | + /** |
+ +327 + | ++ + + + + + | + * Trims the given {@code text} of duplicate whitespaces. |
+ +328 + | ++ + + + + + | + * |
+ +329 + | ++ + + + + + | + * @param text The text to transform. |
+ +330 + | ++ + + + + + | + * @return The finalized form of the text. |
+ +331 + | ++ + + + + + | + */ |
+ +332 + | ++ + + + + + | + private static String trimExcessWhitespaces(String text) { |
+ +333 + | +
+
+1
+
+
+1. trimExcessWhitespaces : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ final StringBuilder result = new StringBuilder(100); |
+ +334 + | ++ + + + + + | + boolean previousWhitespace = true; |
+ +335 + | ++ + + + + + | +|
+ +336 + | ++ + + + + + | + for (char letter : text.toCharArray()) { |
+ +337 + | ++ + + + + + | + final char print; |
+ +338 + | +
+
+1
+
+
+1. trimExcessWhitespaces : negated conditional → KILLED + + + + |
+ if (Character.isWhitespace(letter)) { |
+ +339 + | +
+
+1
+
+
+1. trimExcessWhitespaces : negated conditional → KILLED + + + + |
+ if (previousWhitespace) { |
+ +340 + | ++ + + + + + | + continue; |
+ +341 + | ++ + + + + + | + } |
+ +342 + | ++ + + + + + | +|
+ +343 + | ++ + + + + + | + previousWhitespace = true; |
+ +344 + | ++ + + + + + | + print = ' '; |
+ +345 + | ++ + + + + + | + } |
+ +346 + | ++ + + + + + | + else { |
+ +347 + | ++ + + + + + | + previousWhitespace = false; |
+ +348 + | ++ + + + + + | + print = letter; |
+ +349 + | ++ + + + + + | + } |
+ +350 + | ++ + + + + + | +|
+ +351 + | ++ + + + + + | + result.append(print); |
+ +352 + | ++ + + + + + | + } |
+ +353 + | ++ + + + + + | +|
+ +354 + | +
+
+1
+
+
+1. trimExcessWhitespaces : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheck::trimExcessWhitespaces to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return result.toString(); |
+ +355 + | ++ + + + + + | + } |
+ +356 + | ++ + + + + + | +|
+ +357 + | ++ + + + + + | +} |
Mutations | ||
183 | ++ |
+
+
+
+ 1.1 |
+
190 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 |
+
197 | ++ |
+
+
+
+ 1.1 |
+
198 | ++ |
+
+
+
+ 1.1 |
+
200 | ++ |
+
+
+
+ 1.1 |
+
203 | ++ |
+
+
+
+ 1.1 |
+
204 | ++ |
+
+
+
+ 1.1 |
+
206 | ++ |
+
+
+
+ 1.1 |
+
207 | ++ |
+
+
+
+ 1.1 |
+
208 | ++ |
+
+
+
+ 1.1 |
+
224 | ++ |
+
+
+
+ 1.1 2.2 |
+
226 | ++ |
+
+
+
+ 1.1 |
+
227 | ++ |
+
+
+
+ 1.1 |
+
230 | ++ |
+
+
+
+ 1.1 |
+
231 | ++ |
+
+
+
+ 1.1 |
+
236 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
247 | ++ |
+
+
+
+ 1.1 |
+
249 | ++ |
+
+
+
+ 1.1 |
+
252 | ++ |
+
+
+
+ 1.1 |
+
253 | ++ |
+
+
+
+ 1.1 |
+
257 | ++ |
+
+
+
+ 1.1 |
+
260 | ++ |
+
+
+
+ 1.1 |
+
264 | ++ |
+
+
+
+ 1.1 |
+
275 | ++ |
+
+
+
+ 1.1 |
+
277 | ++ |
+
+
+
+ 1.1 |
+
278 | ++ |
+
+
+
+ 1.1 |
+
283 | ++ |
+
+
+
+ 1.1 |
+
293 | ++ |
+
+
+
+ 1.1 |
+
297 | ++ |
+
+
+
+ 1.1 |
+
304 | ++ |
+
+
+
+ 1.1 |
+
305 | ++ |
+
+
+
+ 1.1 |
+
311 | ++ |
+
+
+
+ 1.1 |
+
323 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
333 | ++ |
+
+
+
+ 1.1 |
+
338 | ++ |
+
+
+
+ 1.1 |
+
339 | ++ |
+
+
+
+ 1.1 |
+
354 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.LinkedList; |
+ +23 + | ++ + + + + + | +import java.util.List; |
+ +24 + | ++ + + + + + | +|
+ +25 + | ++ + + + + + | +/** |
+ +26 + | ++ + + + + + | + * <p> |
+ +27 + | ++ + + + + + | + * Helper class used to parse HTML tags or generic type identifiers |
+ +28 + | ++ + + + + + | + * from a single line of text. Just the beginning of the HTML tag |
+ +29 + | ++ + + + + + | + * is located. No attempt is made to parse out the complete tag, |
+ +30 + | ++ + + + + + | + * particularly since some of the tag parameters could be located |
+ +31 + | ++ + + + + + | + * on the following line of text. The {@code hasNextTag} and |
+ +32 + | ++ + + + + + | + * {@code nextTag} methods are used to iterate through the HTML |
+ +33 + | ++ + + + + + | + * tags or generic type identifiers that were found on the line of text. |
+ +34 + | ++ + + + + + | + * </p> |
+ +35 + | ++ + + + + + | + * |
+ +36 + | ++ + + + + + | + * <p> |
+ +37 + | ++ + + + + + | + * This class isn't really specific to HTML tags. Currently the only HTML |
+ +38 + | ++ + + + + + | + * tag that this class looks specifically for is the HTML comment tag. |
+ +39 + | ++ + + + + + | + * This class helps figure out if a tag exists and if it is well-formed. |
+ +40 + | ++ + + + + + | + * It does not know whether it is valid HTML. This class is also used for |
+ +41 + | ++ + + + + + | + * generics types which looks like opening HTML tags ex: {@code <T>, <E>, <V>, |
+ +42 + | ++ + + + + + | + * <MY_FOO_TYPE>}, etc. According to this class they are valid tags. |
+ +43 + | ++ + + + + + | + * </p> |
+ +44 + | ++ + + + + + | + * |
+ +45 + | ++ + + + + + | + */ |
+ +46 + | ++ + + + + + | +class TagParser { |
+ +47 + | ++ + + + + + | +|
+ +48 + | ++ + + + + + | + /** List of HtmlTags found on the input line of text. */ |
+ +49 + | +
+
+1
+
+
+1. + + |
+ private final List<HtmlTag> tags = new LinkedList<>(); |
+ +50 + | ++ + + + + + | +|
+ +51 + | ++ + + + + + | + /** |
+ +52 + | ++ + + + + + | + * Constructs a TagParser and finds the first tag if any. |
+ +53 + | ++ + + + + + | + * |
+ +54 + | ++ + + + + + | + * @param text the line of text to parse. |
+ +55 + | ++ + + + + + | + * @param lineNo the source line number. |
+ +56 + | ++ + + + + + | + */ |
+ +57 + | ++ + + + + + | + /* package */ TagParser(String[] text, int lineNo) { |
+ +58 + | +
+
+1
+
+
+1. + + |
+ parseTags(text, lineNo); |
+ +59 + | ++ + + + + + | + } |
+ +60 + | ++ + + + + + | +|
+ +61 + | ++ + + + + + | + /** |
+ +62 + | ++ + + + + + | + * Returns the next available HtmlTag. |
+ +63 + | ++ + + + + + | + * |
+ +64 + | ++ + + + + + | + * @return a HtmlTag or {@code null} if none available. |
+ +65 + | ++ + + + + + | + * @throws IndexOutOfBoundsException if there are no HtmlTags |
+ +66 + | ++ + + + + + | + * left to return. |
+ +67 + | ++ + + + + + | + */ |
+ +68 + | ++ + + + + + | + public HtmlTag nextTag() { |
+ +69 + | +
+
+1
+
+
+1. nextTag : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::nextTag to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tags.remove(0); |
+ +70 + | ++ + + + + + | + } |
+ +71 + | ++ + + + + + | +|
+ +72 + | ++ + + + + + | + /** |
+ +73 + | ++ + + + + + | + * Indicates if there are any more HtmlTag to retrieve. |
+ +74 + | ++ + + + + + | + * |
+ +75 + | ++ + + + + + | + * @return {@code true} if there are more tags. |
+ +76 + | ++ + + + + + | + */ |
+ +77 + | ++ + + + + + | + public boolean hasNextTag() { |
+ +78 + | +
+
+3
+
+
+1. hasNextTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::hasNextTag → KILLED + +2. hasNextTag : negated conditional → KILLED + +3. hasNextTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return !tags.isEmpty(); |
+ +79 + | ++ + + + + + | + } |
+ +80 + | ++ + + + + + | +|
+ +81 + | ++ + + + + + | + /** |
+ +82 + | ++ + + + + + | + * Performs lazy initialization on the internal tags List |
+ +83 + | ++ + + + + + | + * and adds the tag. |
+ +84 + | ++ + + + + + | + * |
+ +85 + | ++ + + + + + | + * @param tag the HtmlTag to add. |
+ +86 + | ++ + + + + + | + */ |
+ +87 + | ++ + + + + + | + private void add(HtmlTag tag) { |
+ +88 + | ++ + + + + + | + tags.add(tag); |
+ +89 + | ++ + + + + + | + } |
+ +90 + | ++ + + + + + | +|
+ +91 + | ++ + + + + + | + /** |
+ +92 + | ++ + + + + + | + * Parses the text line for any HTML tags and adds them to the internal |
+ +93 + | ++ + + + + + | + * List of tags. |
+ +94 + | ++ + + + + + | + * |
+ +95 + | ++ + + + + + | + * @param text the source line to parse. |
+ +96 + | ++ + + + + + | + * @param lineNo the source line number. |
+ +97 + | ++ + + + + + | + */ |
+ +98 + | ++ + + + + + | + private void parseTags(String[] text, int lineNo) { |
+ +99 + | ++ + + + + + | + final int nLines = text.length; |
+ +100 + | +
+
+1
+
+
+1. parseTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser$Point::<init> → KILLED + + + + |
+ Point position = findChar(text, '<', new Point(0, 0)); |
+ +101 + | +
+
+2
+
+
+1. parseTags : changed conditional boundary → KILLED + +2. parseTags : negated conditional → KILLED + + + + |
+ while (position.getLineNo() < nLines) { |
+ +102 + | ++ + + + + + | + // if this is html comment then skip it |
+ +103 + | +
+
+1
+
+
+1. parseTags : negated conditional → KILLED + + + + |
+ if (isCommentTag(text, position)) { |
+ +104 + | ++ + + + + + | + position = skipHtmlComment(text, position); |
+ +105 + | ++ + + + + + | + } |
+ +106 + | +
+
+1
+
+
+1. parseTags : negated conditional → KILLED + + + + |
+ else if (isTag(text, position)) { |
+ +107 + | ++ + + + + + | + position = parseTag(text, lineNo, nLines, position); |
+ +108 + | ++ + + + + + | + } |
+ +109 + | ++ + + + + + | + else { |
+ +110 + | ++ + + + + + | + position = getNextCharPos(text, position); |
+ +111 + | ++ + + + + + | + } |
+ +112 + | ++ + + + + + | + position = findChar(text, '<', position); |
+ +113 + | ++ + + + + + | + } |
+ +114 + | ++ + + + + + | + } |
+ +115 + | ++ + + + + + | +|
+ +116 + | ++ + + + + + | + /** |
+ +117 + | ++ + + + + + | + * Parses the tag and return position after it. |
+ +118 + | ++ + + + + + | + * |
+ +119 + | ++ + + + + + | + * @param text the source line to parse. |
+ +120 + | ++ + + + + + | + * @param lineNo the source line number. |
+ +121 + | ++ + + + + + | + * @param nLines line length |
+ +122 + | ++ + + + + + | + * @param position start position for parsing |
+ +123 + | ++ + + + + + | + * @return position after tag |
+ +124 + | ++ + + + + + | + */ |
+ +125 + | ++ + + + + + | + private Point parseTag(String[] text, int lineNo, final int nLines, Point position) { |
+ +126 + | ++ + + + + + | + // find end of tag |
+ +127 + | ++ + + + + + | + final Point endTag = findChar(text, '>', position); |
+ +128 + | +
+
+2
+
+
+1. parseTag : changed conditional boundary → KILLED + +2. parseTag : negated conditional → KILLED + + + + |
+ final boolean incompleteTag = endTag.getLineNo() >= nLines; |
+ +129 + | ++ + + + + + | + // get tag id (one word) |
+ +130 + | ++ + + + + + | + final String tagId; |
+ +131 + | ++ + + + + + | +|
+ +132 + | +
+
+1
+
+
+1. parseTag : negated conditional → KILLED + + + + |
+ if (incompleteTag) { |
+ +133 + | ++ + + + + + | + tagId = ""; |
+ +134 + | ++ + + + + + | + } |
+ +135 + | ++ + + + + + | + else { |
+ +136 + | ++ + + + + + | + tagId = getTagId(text, position); |
+ +137 + | ++ + + + + + | + } |
+ +138 + | ++ + + + + + | + // is this closed tag |
+ +139 + | ++ + + + + + | + final boolean closedTag = |
+ +140 + | +
+
+2
+
+
+1. parseTag : changed conditional boundary → KILLED + +2. parseTag : negated conditional → KILLED + + + + |
+ endTag.getLineNo() < nLines |
+ +141 + | ++ + + + + + | + && text[endTag.getLineNo()] |
+ +142 + | +
+
+2
+
+
+1. parseTag : Replaced integer subtraction with addition → KILLED + +2. parseTag : negated conditional → KILLED + + + + |
+ .charAt(endTag.getColumnNo() - 1) == '/'; |
+ +143 + | ++ + + + + + | + // add new tag |
+ +144 + | +
+
+1
+
+
+1. parseTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::add → KILLED + + + + |
+ add(new HtmlTag(tagId, |
+ +145 + | +
+
+1
+
+
+1. parseTag : Replaced integer addition with subtraction → KILLED + + + + |
+ position.getLineNo() + lineNo, |
+ +146 + | ++ + + + + + | + position.getColumnNo(), |
+ +147 + | ++ + + + + + | + closedTag, |
+ +148 + | ++ + + + + + | + incompleteTag, |
+ +149 + | +
+
+1
+
+
+1. parseTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/HtmlTag::<init> → KILLED + + + + |
+ text[position.getLineNo()])); |
+ +150 + | +
+
+1
+
+
+1. parseTag : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::parseTag to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return endTag; |
+ +151 + | ++ + + + + + | + } |
+ +152 + | ++ + + + + + | +|
+ +153 + | ++ + + + + + | + /** |
+ +154 + | ++ + + + + + | + * Checks if the given position is start one for HTML tag. |
+ +155 + | ++ + + + + + | + * |
+ +156 + | ++ + + + + + | + * @param javadocText text of javadoc comments. |
+ +157 + | ++ + + + + + | + * @param pos position to check. |
+ +158 + | ++ + + + + + | + * @return {@code true} some HTML tag starts from given position. |
+ +159 + | ++ + + + + + | + */ |
+ +160 + | ++ + + + + + | + private static boolean isTag(String[] javadocText, Point pos) { |
+ +161 + | +
+
+1
+
+
+1. isTag : Replaced integer addition with subtraction → KILLED + + + + |
+ final int column = pos.getColumnNo() + 1; |
+ +162 + | ++ + + + + + | + final String text = javadocText[pos.getLineNo()]; |
+ +163 + | ++ + + + + + | +|
+ +164 + | ++ + + + + + | + // Character.isJavaIdentifier... may not be a valid HTML |
+ +165 + | ++ + + + + + | + // identifier but is valid for generics |
+ +166 + | +
+
+4
+
+
+1. isTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::isTag → KILLED + +2. isTag : changed conditional boundary → KILLED + +3. isTag : negated conditional → KILLED + +4. isTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return column >= text.length() |
+ +167 + | +
+
+1
+
+
+1. isTag : negated conditional → KILLED + + + + |
+ || Character.isJavaIdentifierStart(text.charAt(column)) |
+ +168 + | +
+
+1
+
+
+1. isTag : negated conditional → KILLED + + + + |
+ || text.charAt(column) == '/'; |
+ +169 + | ++ + + + + + | + } |
+ +170 + | ++ + + + + + | +|
+ +171 + | ++ + + + + + | + /** |
+ +172 + | ++ + + + + + | + * Parse tag id. |
+ +173 + | ++ + + + + + | + * |
+ +174 + | ++ + + + + + | + * @param javadocText text of javadoc comments. |
+ +175 + | ++ + + + + + | + * @param tagStart start position of the tag |
+ +176 + | ++ + + + + + | + * @return id for given tag |
+ +177 + | ++ + + + + + | + */ |
+ +178 + | ++ + + + + + | + private static String getTagId(String[] javadocText, Point tagStart) { |
+ +179 + | ++ + + + + + | + String tagId = ""; |
+ +180 + | +
+
+1
+
+
+1. getTagId : Replaced integer addition with subtraction → KILLED + + + + |
+ int column = tagStart.getColumnNo() + 1; |
+ +181 + | ++ + + + + + | + String text = javadocText[tagStart.getLineNo()]; |
+ +182 + | +
+
+2
+
+
+1. getTagId : changed conditional boundary → KILLED + +2. getTagId : negated conditional → KILLED + + + + |
+ if (column < text.length()) { |
+ +183 + | +
+
+1
+
+
+1. getTagId : negated conditional → KILLED + + + + |
+ if (text.charAt(column) == '/') { |
+ +184 + | +
+
+1
+
+
+1. getTagId : Changed increment from 1 to -1 → KILLED + + + + |
+ column++; |
+ +185 + | ++ + + + + + | + } |
+ +186 + | ++ + + + + + | +|
+ +187 + | ++ + + + + + | + text = text.substring(column).trim(); |
+ +188 + | ++ + + + + + | + int position = 0; |
+ +189 + | ++ + + + + + | +|
+ +190 + | ++ + + + + + | + // Character.isJavaIdentifier... may not be a valid HTML |
+ +191 + | ++ + + + + + | + // identifier but is valid for generics |
+ +192 + | +
+
+2
+
+
+1. getTagId : changed conditional boundary → KILLED + +2. getTagId : negated conditional → KILLED + + + + |
+ while (position < text.length() |
+ +193 + | +
+
+1
+
+
+1. getTagId : negated conditional → KILLED + + + + |
+ && (Character.isJavaIdentifierStart(text.charAt(position)) |
+ +194 + | +
+
+1
+
+
+1. getTagId : negated conditional → KILLED + + + + |
+ || Character.isJavaIdentifierPart(text.charAt(position)))) { |
+ +195 + | +
+
+1
+
+
+1. getTagId : Changed increment from 1 to -1 → KILLED + + + + |
+ position++; |
+ +196 + | ++ + + + + + | + } |
+ +197 + | ++ + + + + + | +|
+ +198 + | ++ + + + + + | + tagId = text.substring(0, position); |
+ +199 + | ++ + + + + + | + } |
+ +200 + | +
+
+1
+
+
+1. getTagId : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::getTagId to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return tagId; |
+ +201 + | ++ + + + + + | + } |
+ +202 + | ++ + + + + + | +|
+ +203 + | ++ + + + + + | + /** |
+ +204 + | ++ + + + + + | + * If this is a HTML-comments. |
+ +205 + | ++ + + + + + | + * |
+ +206 + | ++ + + + + + | + * @param text text of javadoc comments |
+ +207 + | ++ + + + + + | + * @param pos position to check |
+ +208 + | ++ + + + + + | + * @return {@code true} if HTML-comments |
+ +209 + | ++ + + + + + | + * starts form given position. |
+ +210 + | ++ + + + + + | + */ |
+ +211 + | ++ + + + + + | + private static boolean isCommentTag(String[] text, Point pos) { |
+ +212 + | +
+
+3
+
+
+1. isCommentTag : replaced boolean return with false for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::isCommentTag → KILLED + +2. isCommentTag : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::isCommentTag → KILLED + +3. isCommentTag : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return text[pos.getLineNo()].startsWith("<!--", pos.getColumnNo()); |
+ +213 + | ++ + + + + + | + } |
+ +214 + | ++ + + + + + | +|
+ +215 + | ++ + + + + + | + /** |
+ +216 + | ++ + + + + + | + * Skips HTML comments. |
+ +217 + | ++ + + + + + | + * |
+ +218 + | ++ + + + + + | + * @param text text of javadoc comments. |
+ +219 + | ++ + + + + + | + * @param fromPoint start position of HTML-comments |
+ +220 + | ++ + + + + + | + * @return position after HTML-comments |
+ +221 + | ++ + + + + + | + */ |
+ +222 + | ++ + + + + + | + private static Point skipHtmlComment(String[] text, Point fromPoint) { |
+ +223 + | ++ + + + + + | + Point toPoint = fromPoint; |
+ +224 + | ++ + + + + + | + toPoint = findChar(text, '>', toPoint); |
+ +225 + | +
+
+2
+
+
+1. skipHtmlComment : changed conditional boundary → KILLED + +2. skipHtmlComment : negated conditional → KILLED + + + + |
+ while (toPoint.getLineNo() < text.length && !text[toPoint.getLineNo()] |
+ +226 + | +
+
+2
+
+
+1. skipHtmlComment : Replaced integer addition with subtraction → KILLED + +2. skipHtmlComment : negated conditional → KILLED + + + + |
+ .substring(0, toPoint.getColumnNo() + 1).endsWith("-->")) { |
+ +227 + | ++ + + + + + | + toPoint = findChar(text, '>', getNextCharPos(text, toPoint)); |
+ +228 + | ++ + + + + + | + } |
+ +229 + | +
+
+1
+
+
+1. skipHtmlComment : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::skipHtmlComment to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return toPoint; |
+ +230 + | ++ + + + + + | + } |
+ +231 + | ++ + + + + + | +|
+ +232 + | ++ + + + + + | + /** |
+ +233 + | ++ + + + + + | + * Finds next occurrence of given character. |
+ +234 + | ++ + + + + + | + * |
+ +235 + | ++ + + + + + | + * @param text text to search |
+ +236 + | ++ + + + + + | + * @param character character to search |
+ +237 + | ++ + + + + + | + * @param from position to start search |
+ +238 + | ++ + + + + + | + * @return position of next occurrence of given character |
+ +239 + | ++ + + + + + | + */ |
+ +240 + | ++ + + + + + | + private static Point findChar(String[] text, char character, Point from) { |
+ +241 + | +
+
+1
+
+
+1. findChar : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser$Point::<init> → KILLED + + + + |
+ Point curr = new Point(from.getLineNo(), from.getColumnNo()); |
+ +242 + | +
+
+2
+
+
+1. findChar : negated conditional → TIMED_OUT + +2. findChar : changed conditional boundary → KILLED + + + + |
+ while (curr.getLineNo() < text.length |
+ +243 + | +
+
+1
+
+
+1. findChar : negated conditional → TIMED_OUT + + + + |
+ && text[curr.getLineNo()].charAt(curr.getColumnNo()) != character) { |
+ +244 + | ++ + + + + + | + curr = getNextCharPos(text, curr); |
+ +245 + | ++ + + + + + | + } |
+ +246 + | ++ + + + + + | +|
+ +247 + | +
+
+1
+
+
+1. findChar : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::findChar to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return curr; |
+ +248 + | ++ + + + + + | + } |
+ +249 + | ++ + + + + + | +|
+ +250 + | ++ + + + + + | + /** |
+ +251 + | ++ + + + + + | + * Returns position of next comment character, skips |
+ +252 + | ++ + + + + + | + * whitespaces and asterisks. |
+ +253 + | ++ + + + + + | + * |
+ +254 + | ++ + + + + + | + * @param text to search. |
+ +255 + | ++ + + + + + | + * @param from location to search from |
+ +256 + | ++ + + + + + | + * @return location of the next character. |
+ +257 + | ++ + + + + + | + */ |
+ +258 + | ++ + + + + + | + private static Point getNextCharPos(String[] text, Point from) { |
+ +259 + | ++ + + + + + | + int line = from.getLineNo(); |
+ +260 + | +
+
+1
+
+
+1. getNextCharPos : Replaced integer addition with subtraction → KILLED + + + + |
+ int column = from.getColumnNo() + 1; |
+ +261 + | +
+
+4
+
+
+1. getNextCharPos : changed conditional boundary → KILLED + +2. getNextCharPos : changed conditional boundary → KILLED + +3. getNextCharPos : negated conditional → KILLED + +4. getNextCharPos : negated conditional → KILLED + + + + |
+ while (line < text.length && column >= text[line].length()) { |
+ +262 + | ++ + + + + + | + // go to the next line |
+ +263 + | +
+
+1
+
+
+1. getNextCharPos : Changed increment from 1 to -1 → KILLED + + + + |
+ line++; |
+ +264 + | ++ + + + + + | + column = 0; |
+ +265 + | +
+
+2
+
+
+1. getNextCharPos : changed conditional boundary → KILLED + +2. getNextCharPos : negated conditional → KILLED + + + + |
+ if (line < text.length) { |
+ +266 + | ++ + + + + + | + // skip beginning spaces and stars |
+ +267 + | ++ + + + + + | + final String currentLine = text[line]; |
+ +268 + | +
+
+2
+
+
+1. getNextCharPos : negated conditional → SURVIVED + +2. getNextCharPos : changed conditional boundary → KILLED + + + + |
+ while (column < currentLine.length() |
+ +269 + | +
+
+1
+
+
+1. getNextCharPos : negated conditional → KILLED + + + + |
+ && (Character.isWhitespace(currentLine.charAt(column)) |
+ +270 + | +
+
+1
+
+
+1. getNextCharPos : negated conditional → KILLED + + + + |
+ || currentLine.charAt(column) == '*')) { |
+ +271 + | +
+
+1
+
+
+1. getNextCharPos : Changed increment from 1 to -1 → KILLED + + + + |
+ column++; |
+ +272 + | +
+
+3
+
+
+1. getNextCharPos : changed conditional boundary → KILLED + +2. getNextCharPos : Replaced integer subtraction with addition → KILLED + +3. getNextCharPos : negated conditional → KILLED + + + + |
+ if (column < currentLine.length() |
+ +273 + | +
+
+1
+
+
+1. getNextCharPos : negated conditional → KILLED + + + + |
+ && currentLine.charAt(column - 1) == '*' |
+ +274 + | +
+
+1
+
+
+1. getNextCharPos : negated conditional → KILLED + + + + |
+ && currentLine.charAt(column) == '/') { |
+ +275 + | ++ + + + + + | + // this is end of comment |
+ +276 + | ++ + + + + + | + column = currentLine.length(); |
+ +277 + | ++ + + + + + | + } |
+ +278 + | ++ + + + + + | + } |
+ +279 + | ++ + + + + + | + } |
+ +280 + | ++ + + + + + | + } |
+ +281 + | ++ + + + + + | +|
+ +282 + | +
+
+2
+
+
+1. getNextCharPos : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser$Point::<init> → KILLED + +2. getNextCharPos : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/TagParser::getNextCharPos to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new Point(line, column); |
+ +283 + | ++ + + + + + | + } |
+ +284 + | ++ + + + + + | +|
+ +285 + | ++ + + + + + | + /** |
+ +286 + | ++ + + + + + | + * Represents current position in the text. |
+ +287 + | ++ + + + + + | + */ |
+ +288 + | ++ + + + + + | + private static final class Point { |
+ +289 + | ++ + + + + + | +|
+ +290 + | ++ + + + + + | + /** Line number. */ |
+ +291 + | ++ + + + + + | + private final int lineNo; |
+ +292 + | ++ + + + + + | + /** Column number.*/ |
+ +293 + | ++ + + + + + | + private final int columnNo; |
+ +294 + | ++ + + + + + | +|
+ +295 + | ++ + + + + + | + /** |
+ +296 + | ++ + + + + + | + * Creates new {@code Point} instance. |
+ +297 + | ++ + + + + + | + * |
+ +298 + | ++ + + + + + | + * @param lineNo line number |
+ +299 + | ++ + + + + + | + * @param columnNo column number |
+ +300 + | ++ + + + + + | + */ |
+ +301 + | ++ + + + + + | + /* package */ Point(int lineNo, int columnNo) { |
+ +302 + | ++ + + + + + | + this.lineNo = lineNo; |
+ +303 + | ++ + + + + + | + this.columnNo = columnNo; |
+ +304 + | ++ + + + + + | + } |
+ +305 + | ++ + + + + + | +|
+ +306 + | ++ + + + + + | + /** |
+ +307 + | ++ + + + + + | + * Getter for line number. |
+ +308 + | ++ + + + + + | + * |
+ +309 + | ++ + + + + + | + * @return line number of the position. |
+ +310 + | ++ + + + + + | + */ |
+ +311 + | ++ + + + + + | + public int getLineNo() { |
+ +312 + | +
+
+1
+
+
+1. getLineNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED + + + + |
+ return lineNo; |
+ +313 + | ++ + + + + + | + } |
+ +314 + | ++ + + + + + | +|
+ +315 + | ++ + + + + + | + /** |
+ +316 + | ++ + + + + + | + * Getter for column number. |
+ +317 + | ++ + + + + + | + * |
+ +318 + | ++ + + + + + | + * @return column number of the position. |
+ +319 + | ++ + + + + + | + */ |
+ +320 + | ++ + + + + + | + public int getColumnNo() { |
+ +321 + | +
+
+1
+
+
+1. getColumnNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → TIMED_OUT + + + + |
+ return columnNo; |
+ +322 + | ++ + + + + + | + } |
+ +323 + | ++ + + + + + | +|
+ +324 + | ++ + + + + + | + } |
+ +325 + | ++ + + + + + | +|
+ +326 + | ++ + + + + + | +} |
Mutations | ||
49 | ++ |
+
+
+
+ 1.1 |
+
58 | ++ |
+
+
+
+ 1.1 |
+
69 | ++ |
+
+
+
+ 1.1 |
+
78 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
100 | ++ |
+
+
+
+ 1.1 |
+
101 | ++ |
+
+
+
+ 1.1 2.2 |
+
103 | ++ |
+
+
+
+ 1.1 |
+
106 | ++ |
+
+
+
+ 1.1 |
+
128 | ++ |
+
+
+
+ 1.1 2.2 |
+
132 | ++ |
+
+
+
+ 1.1 |
+
140 | ++ |
+
+
+
+ 1.1 2.2 |
+
142 | ++ |
+
+
+
+ 1.1 2.2 |
+
144 | ++ |
+
+
+
+ 1.1 |
+
145 | ++ |
+
+
+
+ 1.1 |
+
149 | ++ |
+
+
+
+ 1.1 |
+
150 | ++ |
+
+
+
+ 1.1 |
+
161 | ++ |
+
+
+
+ 1.1 |
+
166 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
167 | ++ |
+
+
+
+ 1.1 |
+
168 | ++ |
+
+
+
+ 1.1 |
+
180 | ++ |
+
+
+
+ 1.1 |
+
182 | ++ |
+
+
+
+ 1.1 2.2 |
+
183 | ++ |
+
+
+
+ 1.1 |
+
184 | ++ |
+
+
+
+ 1.1 |
+
192 | ++ |
+
+
+
+ 1.1 2.2 |
+
193 | ++ |
+
+
+
+ 1.1 |
+
194 | ++ |
+
+
+
+ 1.1 |
+
195 | ++ |
+
+
+
+ 1.1 |
+
200 | ++ |
+
+
+
+ 1.1 |
+
212 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
225 | ++ |
+
+
+
+ 1.1 2.2 |
+
226 | ++ |
+
+
+
+ 1.1 2.2 |
+
229 | ++ |
+
+
+
+ 1.1 |
+
241 | ++ |
+
+
+
+ 1.1 |
+
242 | ++ |
+
+
+
+ 1.1 2.2 |
+
243 | ++ |
+
+
+
+ 1.1 |
+
247 | ++ |
+
+
+
+ 1.1 |
+
260 | ++ |
+
+
+
+ 1.1 |
+
261 | ++ |
+
+
+
+ 1.1 2.2 3.3 4.4 |
+
263 | ++ |
+
+
+
+ 1.1 |
+
265 | ++ |
+
+
+
+ 1.1 2.2 |
+
268 | ++ |
+
+
+
+ 1.1 2.2 |
+
269 | ++ |
+
+
+
+ 1.1 |
+
270 | ++ |
+
+
+
+ 1.1 |
+
271 | ++ |
+
+
+
+ 1.1 |
+
272 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
273 | ++ |
+
+
+
+ 1.1 |
+
274 | ++ |
+
+
+
+ 1.1 |
+
282 | ++ |
+
+
+
+ 1.1 2.2 |
+
312 | ++ |
+
+
+
+ 1.1 |
+
321 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +2 + | ++ + + + + + | +// checkstyle: Checks Java source code for adherence to a set of rules. |
+ +3 + | ++ + + + + + | +// Copyright (C) 2001-2020 the original author or authors. |
+ +4 + | ++ + + + + + | +// |
+ +5 + | ++ + + + + + | +// This library is free software; you can redistribute it and/or |
+ +6 + | ++ + + + + + | +// modify it under the terms of the GNU Lesser General Public |
+ +7 + | ++ + + + + + | +// License as published by the Free Software Foundation; either |
+ +8 + | ++ + + + + + | +// version 2.1 of the License, or (at your option) any later version. |
+ +9 + | ++ + + + + + | +// |
+ +10 + | ++ + + + + + | +// This library is distributed in the hope that it will be useful, |
+ +11 + | ++ + + + + + | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ +12 + | ++ + + + + + | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+ +13 + | ++ + + + + + | +// Lesser General Public License for more details. |
+ +14 + | ++ + + + + + | +// |
+ +15 + | ++ + + + + + | +// You should have received a copy of the GNU Lesser General Public |
+ +16 + | ++ + + + + + | +// License along with this library; if not, write to the Free Software |
+ +17 + | ++ + + + + + | +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ +18 + | ++ + + + + + | +//////////////////////////////////////////////////////////////////////////////// |
+ +19 + | ++ + + + + + | +|
+ +20 + | ++ + + + + + | +package com.puppycrawl.tools.checkstyle.checks.javadoc; |
+ +21 + | ++ + + + + + | +|
+ +22 + | ++ + + + + + | +import java.util.regex.Matcher; |
+ +23 + | ++ + + + + + | +import java.util.regex.Pattern; |
+ +24 + | ++ + + + + + | +|
+ +25 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.StatelessCheck; |
+ +26 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; |
+ +27 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.DetailAST; |
+ +28 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.FileContents; |
+ +29 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.SeverityLevel; |
+ +30 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TextBlock; |
+ +31 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.api.TokenTypes; |
+ +32 + | ++ + + + + + | +import com.puppycrawl.tools.checkstyle.utils.CommonUtil; |
+ +33 + | ++ + + + + + | +|
+ +34 + | ++ + + + + + | +/** |
+ +35 + | ++ + + + + + | + * <p> |
+ +36 + | ++ + + + + + | + * Requires user defined Javadoc tag to be present in Javadoc comment with defined format. |
+ +37 + | ++ + + + + + | + * To define the format for a tag, set property tagFormat to a regular expression. |
+ +38 + | ++ + + + + + | + * Property tagSeverity is used for severity of events when the tag exists. |
+ +39 + | ++ + + + + + | + * </p> |
+ +40 + | ++ + + + + + | + * <ul> |
+ +41 + | ++ + + + + + | + * <li> |
+ +42 + | ++ + + + + + | + * Property {@code tag} - Specify the name of tag. |
+ +43 + | ++ + + + + + | + * Default value is {@code null}. |
+ +44 + | ++ + + + + + | + * </li> |
+ +45 + | ++ + + + + + | + * <li> |
+ +46 + | ++ + + + + + | + * Property {@code tagFormat} - Specify the regexp to match tag content. |
+ +47 + | ++ + + + + + | + * Default value is {@code null}. |
+ +48 + | ++ + + + + + | + * </li> |
+ +49 + | ++ + + + + + | + * <li> |
+ +50 + | ++ + + + + + | + * Property {@code tagSeverity} - Specify the severity level when tag is found and printed. |
+ +51 + | ++ + + + + + | + * Default value is {@code info}. |
+ +52 + | ++ + + + + + | + * </li> |
+ +53 + | ++ + + + + + | + * <li> |
+ +54 + | ++ + + + + + | + * Property {@code tokens} - tokens to check |
+ +55 + | ++ + + + + + | + * Default value is: |
+ +56 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF"> |
+ +57 + | ++ + + + + + | + * INTERFACE_DEF</a>, |
+ +58 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF"> |
+ +59 + | ++ + + + + + | + * CLASS_DEF</a>, |
+ +60 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF"> |
+ +61 + | ++ + + + + + | + * ENUM_DEF</a>, |
+ +62 + | ++ + + + + + | + * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF"> |
+ +63 + | ++ + + + + + | + * ANNOTATION_DEF</a>. |
+ +64 + | ++ + + + + + | + * </li> |
+ +65 + | ++ + + + + + | + * </ul> |
+ +66 + | ++ + + + + + | + * <p> |
+ +67 + | ++ + + + + + | + * To configure the check for printing author name: |
+ +68 + | ++ + + + + + | + * </p> |
+ +69 + | ++ + + + + + | + * <pre> |
+ +70 + | ++ + + + + + | + * <module name="WriteTag"> |
+ +71 + | ++ + + + + + | + * <property name="tag" value="@author"/> |
+ +72 + | ++ + + + + + | + * <property name="tagFormat" value="\S"/> |
+ +73 + | ++ + + + + + | + * </module> |
+ +74 + | ++ + + + + + | + * </pre> |
+ +75 + | ++ + + + + + | + * <p> |
+ +76 + | ++ + + + + + | + * To configure the check to print warnings if an "@incomplete" tag is found, |
+ +77 + | ++ + + + + + | + * and not print anything if it is not found: |
+ +78 + | ++ + + + + + | + * </p> |
+ +79 + | ++ + + + + + | + * <pre> |
+ +80 + | ++ + + + + + | + * <module name="WriteTag"> |
+ +81 + | ++ + + + + + | + * <property name="tag" value="@incomplete"/> |
+ +82 + | ++ + + + + + | + * <property name="tagFormat" value="\S"/> |
+ +83 + | ++ + + + + + | + * <property name="severity" value="ignore"/> |
+ +84 + | ++ + + + + + | + * <property name="tagSeverity" value="warning"/> |
+ +85 + | ++ + + + + + | + * </module> |
+ +86 + | ++ + + + + + | + * </pre> |
+ +87 + | ++ + + + + + | + * |
+ +88 + | ++ + + + + + | + * @since 4.2 |
+ +89 + | ++ + + + + + | + */ |
+ +90 + | ++ + + + + + | +@StatelessCheck |
+ +91 + | ++ + + + + + | +public class WriteTagCheck |
+ +92 + | ++ + + + + + | + extends AbstractCheck { |
+ +93 + | ++ + + + + + | +|
+ +94 + | ++ + + + + + | + /** |
+ +95 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +96 + | ++ + + + + + | + * file. |
+ +97 + | ++ + + + + + | + */ |
+ +98 + | ++ + + + + + | + public static final String MSG_MISSING_TAG = "type.missingTag"; |
+ +99 + | ++ + + + + + | +|
+ +100 + | ++ + + + + + | + /** |
+ +101 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +102 + | ++ + + + + + | + * file. |
+ +103 + | ++ + + + + + | + */ |
+ +104 + | ++ + + + + + | + public static final String MSG_WRITE_TAG = "javadoc.writeTag"; |
+ +105 + | ++ + + + + + | +|
+ +106 + | ++ + + + + + | + /** |
+ +107 + | ++ + + + + + | + * A key is pointing to the warning message text in "messages.properties" |
+ +108 + | ++ + + + + + | + * file. |
+ +109 + | ++ + + + + + | + */ |
+ +110 + | ++ + + + + + | + public static final String MSG_TAG_FORMAT = "type.tagFormat"; |
+ +111 + | ++ + + + + + | +|
+ +112 + | ++ + + + + + | + /** Compiled regexp to match tag. */ |
+ +113 + | ++ + + + + + | + private Pattern tagRegExp; |
+ +114 + | ++ + + + + + | + /** Specify the regexp to match tag content. */ |
+ +115 + | ++ + + + + + | + private Pattern tagFormat; |
+ +116 + | ++ + + + + + | +|
+ +117 + | ++ + + + + + | + /** Specify the name of tag. */ |
+ +118 + | ++ + + + + + | + private String tag; |
+ +119 + | ++ + + + + + | + /** Specify the severity level when tag is found and printed. */ |
+ +120 + | ++ + + + + + | + private SeverityLevel tagSeverity = SeverityLevel.INFO; |
+ +121 + | ++ + + + + + | +|
+ +122 + | ++ + + + + + | + /** |
+ +123 + | ++ + + + + + | + * Setter to specify the name of tag. |
+ +124 + | ++ + + + + + | + * |
+ +125 + | ++ + + + + + | + * @param tag tag to check |
+ +126 + | ++ + + + + + | + */ |
+ +127 + | ++ + + + + + | + public void setTag(String tag) { |
+ +128 + | ++ + + + + + | + this.tag = tag; |
+ +129 + | +
+
+1
+
+
+1. setTag : removed call to java/lang/StringBuilder::<init> → KILLED + + + + |
+ tagRegExp = CommonUtil.createPattern(tag + "\\s*(.*$)"); |
+ +130 + | ++ + + + + + | + } |
+ +131 + | ++ + + + + + | +|
+ +132 + | ++ + + + + + | + /** |
+ +133 + | ++ + + + + + | + * Setter to specify the regexp to match tag content. |
+ +134 + | ++ + + + + + | + * |
+ +135 + | ++ + + + + + | + * @param pattern a {@code String} value |
+ +136 + | ++ + + + + + | + */ |
+ +137 + | ++ + + + + + | + public void setTagFormat(Pattern pattern) { |
+ +138 + | ++ + + + + + | + tagFormat = pattern; |
+ +139 + | ++ + + + + + | + } |
+ +140 + | ++ + + + + + | +|
+ +141 + | ++ + + + + + | + /** |
+ +142 + | ++ + + + + + | + * Setter to specify the severity level when tag is found and printed. |
+ +143 + | ++ + + + + + | + * |
+ +144 + | ++ + + + + + | + * @param severity The new severity level |
+ +145 + | ++ + + + + + | + * @see SeverityLevel |
+ +146 + | ++ + + + + + | + */ |
+ +147 + | ++ + + + + + | + public final void setTagSeverity(SeverityLevel severity) { |
+ +148 + | ++ + + + + + | + tagSeverity = severity; |
+ +149 + | ++ + + + + + | + } |
+ +150 + | ++ + + + + + | +|
+ +151 + | ++ + + + + + | + @Override |
+ +152 + | ++ + + + + + | + public int[] getDefaultTokens() { |
+ +153 + | +
+
+1
+
+
+1. getDefaultTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::getDefaultTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] {TokenTypes.INTERFACE_DEF, |
+ +154 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +155 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +156 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +157 + | ++ + + + + + | + }; |
+ +158 + | ++ + + + + + | + } |
+ +159 + | ++ + + + + + | +|
+ +160 + | ++ + + + + + | + @Override |
+ +161 + | ++ + + + + + | + public int[] getAcceptableTokens() { |
+ +162 + | +
+
+1
+
+
+1. getAcceptableTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::getAcceptableTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return new int[] {TokenTypes.INTERFACE_DEF, |
+ +163 + | ++ + + + + + | + TokenTypes.CLASS_DEF, |
+ +164 + | ++ + + + + + | + TokenTypes.ENUM_DEF, |
+ +165 + | ++ + + + + + | + TokenTypes.ANNOTATION_DEF, |
+ +166 + | ++ + + + + + | + TokenTypes.METHOD_DEF, |
+ +167 + | ++ + + + + + | + TokenTypes.CTOR_DEF, |
+ +168 + | ++ + + + + + | + TokenTypes.ENUM_CONSTANT_DEF, |
+ +169 + | ++ + + + + + | + TokenTypes.ANNOTATION_FIELD_DEF, |
+ +170 + | ++ + + + + + | + }; |
+ +171 + | ++ + + + + + | + } |
+ +172 + | ++ + + + + + | +|
+ +173 + | ++ + + + + + | + @Override |
+ +174 + | ++ + + + + + | + public int[] getRequiredTokens() { |
+ +175 + | +
+
+1
+
+
+1. getRequiredTokens : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::getRequiredTokens to ( if (x != null) null else throw new RuntimeException ) → KILLED + + + + |
+ return CommonUtil.EMPTY_INT_ARRAY; |
+ +176 + | ++ + + + + + | + } |
+ +177 + | ++ + + + + + | +|
+ +178 + | ++ + + + + + | + @Override |
+ +179 + | ++ + + + + + | + public void visitToken(DetailAST ast) { |
+ +180 + | ++ + + + + + | + final FileContents contents = getFileContents(); |
+ +181 + | ++ + + + + + | + final int lineNo = ast.getLineNo(); |
+ +182 + | ++ + + + + + | + final TextBlock cmt = |
+ +183 + | ++ + + + + + | + contents.getJavadocBefore(lineNo); |
+ +184 + | +
+
+1
+
+
+1. visitToken : negated conditional → KILLED + + + + |
+ if (cmt == null) { |
+ +185 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::log → KILLED + + + + |
+ log(lineNo, MSG_MISSING_TAG, tag); |
+ +186 + | ++ + + + + + | + } |
+ +187 + | ++ + + + + + | + else { |
+ +188 + | +
+
+1
+
+
+1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::checkTag → KILLED + + + + |
+ checkTag(lineNo, cmt.getText()); |
+ +189 + | ++ + + + + + | + } |
+ +190 + | ++ + + + + + | + } |
+ +191 + | ++ + + + + + | +|
+ +192 + | ++ + + + + + | + /** |
+ +193 + | ++ + + + + + | + * Verifies that a type definition has a required tag. |
+ +194 + | ++ + + + + + | + * |
+ +195 + | ++ + + + + + | + * @param lineNo the line number for the type definition. |
+ +196 + | ++ + + + + + | + * @param comment the Javadoc comment for the type definition. |
+ +197 + | ++ + + + + + | + */ |
+ +198 + | ++ + + + + + | + private void checkTag(int lineNo, String... comment) { |
+ +199 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (tagRegExp != null) { |
+ +200 + | ++ + + + + + | + boolean hasTag = false; |
+ +201 + | +
+
+3
+
+
+1. checkTag : changed conditional boundary → KILLED + +2. checkTag : Changed increment from 1 to -1 → KILLED + +3. checkTag : negated conditional → KILLED + + + + |
+ for (int i = 0; i < comment.length; i++) { |
+ +202 + | ++ + + + + + | + final String commentValue = comment[i]; |
+ +203 + | ++ + + + + + | + final Matcher matcher = tagRegExp.matcher(commentValue); |
+ +204 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (matcher.find()) { |
+ +205 + | ++ + + + + + | + hasTag = true; |
+ +206 + | ++ + + + + + | + final int contentStart = matcher.start(1); |
+ +207 + | ++ + + + + + | + final String content = commentValue.substring(contentStart); |
+ +208 + | +
+
+2
+
+
+1. checkTag : negated conditional → KILLED + +2. checkTag : negated conditional → KILLED + + + + |
+ if (tagFormat == null || tagFormat.matcher(content).find()) { |
+ +209 + | +
+
+3
+
+
+1. checkTag : Replaced integer addition with subtraction → KILLED + +2. checkTag : Replaced integer subtraction with addition → KILLED + +3. checkTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::logTag → KILLED + + + + |
+ logTag(lineNo + i - comment.length, tag, content); |
+ +210 + | ++ + + + + + | + } |
+ +211 + | ++ + + + + + | + else { |
+ +212 + | +
+
+3
+
+
+1. checkTag : Replaced integer addition with subtraction → KILLED + +2. checkTag : Replaced integer subtraction with addition → KILLED + +3. checkTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::log → KILLED + + + + |
+ log(lineNo + i - comment.length, MSG_TAG_FORMAT, tag, tagFormat.pattern()); |
+ +213 + | ++ + + + + + | + } |
+ +214 + | ++ + + + + + | + } |
+ +215 + | ++ + + + + + | + } |
+ +216 + | +
+
+1
+
+
+1. checkTag : negated conditional → KILLED + + + + |
+ if (!hasTag) { |
+ +217 + | +
+
+1
+
+
+1. checkTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::log → KILLED + + + + |
+ log(lineNo, MSG_MISSING_TAG, tag); |
+ +218 + | ++ + + + + + | + } |
+ +219 + | ++ + + + + + | + } |
+ +220 + | ++ + + + + + | + } |
+ +221 + | ++ + + + + + | +|
+ +222 + | ++ + + + + + | + /** |
+ +223 + | ++ + + + + + | + * Log a message. |
+ +224 + | ++ + + + + + | + * |
+ +225 + | ++ + + + + + | + * @param line the line number where the violation was found |
+ +226 + | ++ + + + + + | + * @param tagName the javadoc tag to be logged |
+ +227 + | ++ + + + + + | + * @param tagValue the contents of the tag |
+ +228 + | ++ + + + + + | + * |
+ +229 + | ++ + + + + + | + * @see java.text.MessageFormat |
+ +230 + | ++ + + + + + | + */ |
+ +231 + | ++ + + + + + | + private void logTag(int line, String tagName, String tagValue) { |
+ +232 + | ++ + + + + + | + final String originalSeverity = getSeverity(); |
+ +233 + | +
+
+1
+
+
+1. logTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::setSeverity → KILLED + + + + |
+ setSeverity(tagSeverity.getName()); |
+ +234 + | ++ + + + + + | +|
+ +235 + | +
+
+1
+
+
+1. logTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::log → KILLED + + + + |
+ log(line, MSG_WRITE_TAG, tagName, tagValue); |
+ +236 + | ++ + + + + + | +|
+ +237 + | +
+
+1
+
+
+1. logTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheck::setSeverity → KILLED + + + + |
+ setSeverity(originalSeverity); |
+ +238 + | ++ + + + + + | + } |
+ +239 + | ++ + + + + + | +|
+ +240 + | ++ + + + + + | +} |
Mutations | ||
129 | ++ |
+
+
+
+ 1.1 |
+
153 | ++ |
+
+
+
+ 1.1 |
+
162 | ++ |
+
+
+
+ 1.1 |
+
175 | ++ |
+
+
+
+ 1.1 |
+
184 | ++ |
+
+
+
+ 1.1 |
+
185 | ++ |
+
+
+
+ 1.1 |
+
188 | ++ |
+
+
+
+ 1.1 |
+
199 | ++ |
+
+
+
+ 1.1 |
+
201 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
204 | ++ |
+
+
+
+ 1.1 |
+
208 | ++ |
+
+
+
+ 1.1 2.2 |
+
209 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
212 | ++ |
+
+
+
+ 1.1 2.2 3.3 |
+
216 | ++ |
+
+
+
+ 1.1 |
+
217 | ++ |
+
+
+
+ 1.1 |
+
233 | ++ |
+
+
+
+ 1.1 |
+
235 | ++ |
+
+
+
+ 1.1 |
+
237 | ++ |
+
+
+
+ 1.1 |
+
Number of Classes | +Line Coverage | +Mutation Coverage | +
---|---|---|
27 | +100% | +99% | +
Number of Classes | +Line Coverage | +Mutation Coverage | +
---|---|---|
30 | +100% | +99% | +
Name | +Number of Classes | +Line Coverage | +Mutation Coverage | +
---|---|---|---|
com.puppycrawl.tools.checkstyle.checks.javadoc | +27 | +100% |
+ 99% |
+
com.puppycrawl.tools.checkstyle.checks.javadoc.utils | +3 | +100% |
+ 100% |
+