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 | |
59 | * can be suppressed by defining property {@code allowMissingParamTags}. | |
60 | * Violates methods which return non-void but for which no return tag is present | |
61 | * can be suppressed by defining property {@code allowMissingReturnTag}. | |
62 | * Violates exceptions which are declared to be thrown, but for which no throws | |
63 | * tag is present by activation of property {@code validateThrows}. | |
64 | * </p> | |
65 | * <p> | |
66 | * Javadoc is not required on a method that is tagged with the {@code @Override} | |
67 | * annotation. However under Java 5 it is not possible to mark a method required | |
68 | * for an interface (this was <i>corrected</i> under Java 6). Hence Checkstyle | |
69 | * supports using the convention of using a single {@code {@inheritDoc}} tag | |
70 | * instead of all the other tags. | |
71 | * </p> | |
72 | * <p> | |
73 | * Note that only inheritable items will allow the {@code {@inheritDoc}} | |
74 | * tag to be used in place of comments. Static methods at all visibilities, | |
75 | * private non-static methods and constructors are not inheritable. | |
76 | * </p> | |
77 | * <p> | |
78 | * For example, if the following method is implementing a method required by | |
79 | * an interface, then the Javadoc could be done as: | |
80 | * </p> | |
81 | * <pre> | |
82 | * /** {@inheritDoc} */ | |
83 | * public int checkReturnTag(final int aTagIndex, | |
84 | * JavadocTag[] aTags, | |
85 | * int aLineNo) | |
86 | * </pre> | |
87 | * <ul> | |
88 | * <li> | |
89 | * Property {@code allowedAnnotations} - Specify the list of annotations | |
90 | * that allow missed documentation. | |
91 | * Default value is {@code Override}. | |
92 | * </li> | |
93 | * <li> | |
94 | * Property {@code validateThrows} - Control whether to validate {@code throws} tags. | |
95 | * Default value is {@code false}. | |
96 | * </li> | |
97 | * <li> | |
98 | * Property {@code scope} - Specify the visibility scope where Javadoc comments are checked. | |
99 | * Default value is {@code private}. | |
100 | * </li> | |
101 | * <li> | |
102 | * Property {@code excludeScope} - Specify the visibility scope where Javadoc comments | |
103 | * are not checked. | |
104 | * Default value is {@code null}. | |
105 | * </li> | |
106 | * <li> | |
107 | * Property {@code allowMissingParamTags} - Control whether to ignore violations | |
108 | * when a method has parameters but does not have matching {@code param} tags in the javadoc. | |
109 | * Default value is {@code false}. | |
110 | * </li> | |
111 | * <li> | |
112 | * Property {@code allowMissingReturnTag} - Control whether to ignore violations | |
113 | * when a method returns non-void type and does not have a {@code return} tag in the javadoc. | |
114 | * Default value is {@code false}. | |
115 | * </li> | |
116 | * <li> | |
117 | * Property {@code tokens} - tokens to check Default value is: | |
118 | * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF"> | |
119 | * METHOD_DEF</a>, | |
120 | * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF"> | |
121 | * CTOR_DEF</a>, | |
122 | * <a href="https://checkstyle.org/apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_FIELD_DEF"> | |
123 | * ANNOTATION_FIELD_DEF</a>. | |
124 | * </li> | |
125 | * </ul> | |
126 | * <p> | |
127 | * To configure the default check: | |
128 | * </p> | |
129 | * <pre> | |
130 | * <module name="JavadocMethod"/> | |
131 | * </pre> | |
132 | * <p> | |
133 | * To configure the check for {@code public} scope, ignoring any missing param tags is: | |
134 | * </p> | |
135 | * <pre> | |
136 | * <module name="JavadocMethod"> | |
137 | * <property name="scope" value="public"/> | |
138 | * <property name="allowMissingParamTags" value="true"/> | |
139 | * </module> | |
140 | * </pre> | |
141 | * <p> | |
142 | * To configure the check for methods which are in {@code private}, | |
143 | * but not in {@code protected} scope: | |
144 | * </p> | |
145 | * <pre> | |
146 | * <module name="JavadocMethod"> | |
147 | * <property name="scope" value="private"/> | |
148 | * <property name="excludeScope" value="protected"/> | |
149 | * </module> | |
150 | * </pre> | |
151 | * <p> | |
152 | * To configure the check to validate {@code throws} tags, you can use following config. | |
153 | * ATTENTION: Checkstyle does not have information about hierarchy of exception types so usage | |
154 | * of base class is considered as separate exception type. As workaround you need to | |
155 | * specify both types in javadoc (parent and exact type). | |
156 | * </p> | |
157 | * <pre> | |
158 | * <module name="JavadocMethod"> | |
159 | * <property name="validateThrows" value="true"/> | |
160 | * </module> | |
161 | * </pre> | |
162 | * <pre> | |
163 | * /** | |
164 | * * Actual exception thrown is child class of class that is declared in throws. | |
165 | * * It is limitation of checkstyle (as checkstyle does not know type hierarchy). | |
166 | * * Javadoc is valid not declaring FileNotFoundException | |
167 | * * BUT checkstyle can not distinguish relationship between exceptions. | |
168 | * * @param file some file | |
169 | * * @throws IOException if some problem | |
170 | * */ | |
171 | * public void doSomething8(File file) throws IOException { | |
172 | * if (file == null) { | |
173 | * throw new FileNotFoundException(); // violation | |
174 | * } | |
175 | * } | |
176 | * | |
177 | * /** | |
178 | * * Exact throw type referencing in javadoc even first is parent of second type. | |
179 | * * It is a limitation of checkstyle (as checkstyle does not know type hierarchy). | |
180 | * * This javadoc is valid for checkstyle and for javadoc tool. | |
181 | * * @param file some file | |
182 | * * @throws IOException if some problem | |
183 | * * @throws FileNotFoundException if file is not found | |
184 | * */ | |
185 | * public void doSomething9(File file) throws IOException { | |
186 | * if (file == null) { | |
187 | * throw new FileNotFoundException(); | |
188 | * } | |
189 | * } | |
190 | * </pre> | |
191 | * | |
192 | * @since 3.0 | |
193 | */ | |
194 | @FileStatefulCheck | |
195 | public class JavadocMethodCheck extends AbstractCheck { | |
196 | ||
197 | /** | |
198 | * A key is pointing to the warning message text in "messages.properties" | |
199 | * file. | |
200 | */ | |
201 | public static final String MSG_CLASS_INFO = "javadoc.classInfo"; | |
202 | ||
203 | /** | |
204 | * A key is pointing to the warning message text in "messages.properties" | |
205 | * file. | |
206 | */ | |
207 | public static final String MSG_UNUSED_TAG_GENERAL = "javadoc.unusedTagGeneral"; | |
208 | ||
209 | /** | |
210 | * A key is pointing to the warning message text in "messages.properties" | |
211 | * file. | |
212 | */ | |
213 | public static final String MSG_INVALID_INHERIT_DOC = "javadoc.invalidInheritDoc"; | |
214 | ||
215 | /** | |
216 | * A key is pointing to the warning message text in "messages.properties" | |
217 | * file. | |
218 | */ | |
219 | public static final String MSG_UNUSED_TAG = "javadoc.unusedTag"; | |
220 | ||
221 | /** | |
222 | * A key is pointing to the warning message text in "messages.properties" | |
223 | * file. | |
224 | */ | |
225 | public static final String MSG_EXPECTED_TAG = "javadoc.expectedTag"; | |
226 | ||
227 | /** | |
228 | * A key is pointing to the warning message text in "messages.properties" | |
229 | * file. | |
230 | */ | |
231 | public static final String MSG_RETURN_EXPECTED = "javadoc.return.expected"; | |
232 | ||
233 | /** | |
234 | * A key is pointing to the warning message text in "messages.properties" | |
235 | * file. | |
236 | */ | |
237 | public static final String MSG_DUPLICATE_TAG = "javadoc.duplicateTag"; | |
238 | ||
239 | /** Compiled regexp to match Javadoc tags that take an argument. */ | |
240 | private static final Pattern MATCH_JAVADOC_ARG = CommonUtil.createPattern( | |
241 | "^\\s*(?>\\*|\\/\\*\\*)?\\s*@(throws|exception|param)\\s+(\\S+)\\s+\\S*"); | |
242 | /** Compiled regexp to match Javadoc tags with argument but with missing description. */ | |
243 | private static final Pattern MATCH_JAVADOC_ARG_MISSING_DESCRIPTION = | |
244 | CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(throws|exception|param)\\s+" | |
245 | + "(\\S[^*]*)(?:(\\s+|\\*\\/))?"); | |
246 | ||
247 | /** Compiled regexp to look for a continuation of the comment. */ | |
248 | private static final Pattern MATCH_JAVADOC_MULTILINE_CONT = | |
249 | CommonUtil.createPattern("(\\*\\/|@|[^\\s\\*])"); | |
250 | ||
251 | /** Multiline finished at end of comment. */ | |
252 | private static final String END_JAVADOC = "*/"; | |
253 | /** Multiline finished at next Javadoc. */ | |
254 | private static final String NEXT_TAG = "@"; | |
255 | ||
256 | /** Compiled regexp to match Javadoc tags with no argument. */ | |
257 | private static final Pattern MATCH_JAVADOC_NOARG = | |
258 | CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(return|see)\\s+\\S"); | |
259 | /** Compiled regexp to match first part of multilineJavadoc tags. */ | |
260 | private static final Pattern MATCH_JAVADOC_NOARG_MULTILINE_START = | |
261 | CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(return|see)\\s*$"); | |
262 | /** Compiled regexp to match Javadoc tags with no argument and {}. */ | |
263 | private static final Pattern MATCH_JAVADOC_NOARG_CURLY = | |
264 | CommonUtil.createPattern("\\{\\s*@(inheritDoc)\\s*\\}"); | |
265 | ||
266 | /** Stack of maps for type params. */ | |
267 |
1
1. |
private final Deque<Map<String, ClassInfo>> currentTypeParams = new ArrayDeque<>(); |
268 | ||
269 | /** Name of current class. */ | |
270 | private String currentClassName; | |
271 | ||
272 | /** Specify the visibility scope where Javadoc comments are checked. */ | |
273 | private Scope scope = Scope.PRIVATE; | |
274 | ||
275 | /** Specify the visibility scope where Javadoc comments are not checked. */ | |
276 | private Scope excludeScope; | |
277 | ||
278 | /** | |
279 | * Control whether to validate {@code throws} tags. | |
280 | */ | |
281 | private boolean validateThrows; | |
282 | ||
283 | /** | |
284 | * Control whether to ignore violations when a method has parameters but does | |
285 | * not have matching {@code param} tags in the javadoc. | |
286 | */ | |
287 | private boolean allowMissingParamTags; | |
288 | ||
289 | /** | |
290 | * Control whether to ignore violations when a method returns non-void type | |
291 | * and does not have a {@code return} tag in the javadoc. | |
292 | */ | |
293 | private boolean allowMissingReturnTag; | |
294 | ||
295 | /** Specify the list of annotations that allow missed documentation. */ | |
296 | private List<String> allowedAnnotations = Collections.singletonList("Override"); | |
297 | ||
298 | /** | |
299 | * Setter to control whether to validate {@code throws} tags. | |
300 | * | |
301 | * @param value user's value. | |
302 | */ | |
303 | public void setValidateThrows(boolean value) { | |
304 | validateThrows = value; | |
305 | } | |
306 | ||
307 | /** | |
308 | * Setter to specify the list of annotations that allow missed documentation. | |
309 | * | |
310 | * @param userAnnotations user's value. | |
311 | */ | |
312 | public void setAllowedAnnotations(String... userAnnotations) { | |
313 | allowedAnnotations = Arrays.asList(userAnnotations); | |
314 | } | |
315 | ||
316 | /** | |
317 | * Setter to specify the visibility scope where Javadoc comments are checked. | |
318 | * | |
319 | * @param scope a scope. | |
320 | */ | |
321 | public void setScope(Scope scope) { | |
322 | this.scope = scope; | |
323 | } | |
324 | ||
325 | /** | |
326 | * Setter to specify the visibility scope where Javadoc comments are not checked. | |
327 | * | |
328 | * @param excludeScope a scope. | |
329 | */ | |
330 | public void setExcludeScope(Scope excludeScope) { | |
331 | this.excludeScope = excludeScope; | |
332 | } | |
333 | ||
334 | /** | |
335 | * Setter to control whether to ignore violations when a method has parameters | |
336 | * but does not have matching {@code param} tags in the javadoc. | |
337 | * | |
338 | * @param flag a {@code Boolean} value | |
339 | */ | |
340 | public void setAllowMissingParamTags(boolean flag) { | |
341 | allowMissingParamTags = flag; | |
342 | } | |
343 | ||
344 | /** | |
345 | * Setter to control whether to ignore violations when a method returns non-void type | |
346 | * and does not have a {@code return} tag in the javadoc. | |
347 | * | |
348 | * @param flag a {@code Boolean} value | |
349 | */ | |
350 | public void setAllowMissingReturnTag(boolean flag) { | |
351 | allowMissingReturnTag = flag; | |
352 | } | |
353 | ||
354 | @Override | |
355 | public final int[] getRequiredTokens() { | |
356 |
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[] { |
357 | TokenTypes.CLASS_DEF, | |
358 | TokenTypes.INTERFACE_DEF, | |
359 | TokenTypes.ENUM_DEF, | |
360 | }; | |
361 | } | |
362 | ||
363 | @Override | |
364 | public int[] getDefaultTokens() { | |
365 |
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(); |
366 | } | |
367 | ||
368 | @Override | |
369 | public int[] getAcceptableTokens() { | |
370 |
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[] { |
371 | TokenTypes.CLASS_DEF, | |
372 | TokenTypes.ENUM_DEF, | |
373 | TokenTypes.INTERFACE_DEF, | |
374 | TokenTypes.METHOD_DEF, | |
375 | TokenTypes.CTOR_DEF, | |
376 | TokenTypes.ANNOTATION_FIELD_DEF, | |
377 | }; | |
378 | } | |
379 | ||
380 | @Override | |
381 | public void beginTree(DetailAST rootAST) { | |
382 | currentClassName = ""; | |
383 |
1
1. beginTree : removed call to java/util/Deque::clear → SURVIVED |
currentTypeParams.clear(); |
384 | } | |
385 | ||
386 | @Override | |
387 | public final void visitToken(DetailAST ast) { | |
388 |
1
1. visitToken : negated conditional → KILLED |
if (ast.getType() == TokenTypes.CLASS_DEF |
389 |
1
1. visitToken : negated conditional → KILLED |
|| ast.getType() == TokenTypes.INTERFACE_DEF |
390 |
1
1. visitToken : negated conditional → KILLED |
|| ast.getType() == TokenTypes.ENUM_DEF) { |
391 |
1
1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processClass → KILLED |
processClass(ast); |
392 | } | |
393 | else { | |
394 |
1
1. visitToken : negated conditional → KILLED |
if (ast.getType() == TokenTypes.METHOD_DEF) { |
395 |
1
1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processTypeParams → KILLED |
processTypeParams(ast); |
396 | } | |
397 |
1
1. visitToken : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processAST → KILLED |
processAST(ast); |
398 | } | |
399 | } | |
400 | ||
401 | @Override | |
402 | public final void leaveToken(DetailAST ast) { | |
403 |
1
1. leaveToken : negated conditional → KILLED |
if (ast.getType() == TokenTypes.CLASS_DEF |
404 |
1
1. leaveToken : negated conditional → KILLED |
|| ast.getType() == TokenTypes.INTERFACE_DEF |
405 |
1
1. leaveToken : negated conditional → KILLED |
|| ast.getType() == TokenTypes.ENUM_DEF) { |
406 | // perhaps it was inner class | |
407 | int dotIdx = currentClassName.lastIndexOf('$'); | |
408 |
1
1. leaveToken : negated conditional → SURVIVED |
if (dotIdx == -1) { |
409 | // perhaps just a class | |
410 | dotIdx = currentClassName.lastIndexOf('.'); | |
411 | } | |
412 |
1
1. leaveToken : negated conditional → KILLED |
if (dotIdx == -1) { |
413 | // looks like a topmost class | |
414 | currentClassName = ""; | |
415 | } | |
416 | else { | |
417 | currentClassName = currentClassName.substring(0, dotIdx); | |
418 | } | |
419 | currentTypeParams.pop(); | |
420 | } | |
421 |
1
1. leaveToken : negated conditional → KILLED |
else if (ast.getType() == TokenTypes.METHOD_DEF) { |
422 | currentTypeParams.pop(); | |
423 | } | |
424 | } | |
425 | ||
426 | /** | |
427 | * Called to process an AST when visiting it. | |
428 | * @param ast the AST to process. Guaranteed to not be PACKAGE_DEF or | |
429 | * IMPORT tokens. | |
430 | */ | |
431 | private void processAST(DetailAST ast) { | |
432 | final Scope theScope = calculateScope(ast); | |
433 |
1
1. processAST : negated conditional → KILLED |
if (shouldCheck(ast, theScope)) { |
434 | final FileContents contents = getFileContents(); | |
435 | final TextBlock textBlock = contents.getJavadocBefore(ast.getLineNo()); | |
436 | ||
437 |
1
1. processAST : negated conditional → KILLED |
if (textBlock != null) { |
438 |
1
1. processAST : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkComment → KILLED |
checkComment(ast, textBlock); |
439 | } | |
440 | } | |
441 | } | |
442 | ||
443 | /** | |
444 | * Whether we should check this node. | |
445 | * | |
446 | * @param ast a given node. | |
447 | * @param nodeScope the scope of the node. | |
448 | * @return whether we should check a given node. | |
449 | */ | |
450 | private boolean shouldCheck(final DetailAST ast, final Scope nodeScope) { | |
451 | final Scope surroundingScope = ScopeUtil.getSurroundingScope(ast); | |
452 | ||
453 |
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 |
454 | || nodeScope != excludeScope | |
455 | && surroundingScope != excludeScope) | |
456 |
1
1. shouldCheck : negated conditional → KILLED |
&& nodeScope.isIn(scope) |
457 |
1
1. shouldCheck : negated conditional → KILLED |
&& surroundingScope.isIn(scope); |
458 | } | |
459 | ||
460 | /** | |
461 | * Checks the Javadoc for a method. | |
462 | * | |
463 | * @param ast the token for the method | |
464 | * @param comment the Javadoc comment | |
465 | */ | |
466 | private void checkComment(DetailAST ast, TextBlock comment) { | |
467 | final List<JavadocTag> tags = getMethodTags(comment); | |
468 | ||
469 |
1
1. checkComment : negated conditional → KILLED |
if (!hasShortCircuitTag(ast, tags)) { |
470 |
1
1. checkComment : negated conditional → KILLED |
if (ast.getType() == TokenTypes.ANNOTATION_FIELD_DEF) { |
471 |
1
1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkReturnTag → KILLED |
checkReturnTag(tags, ast.getLineNo(), true); |
472 | } | |
473 | else { | |
474 | final Iterator<JavadocTag> it = tags.iterator(); | |
475 | // Check for inheritDoc | |
476 | boolean hasInheritDocTag = false; | |
477 |
2
1. checkComment : negated conditional → KILLED 2. checkComment : negated conditional → KILLED |
while (!hasInheritDocTag && it.hasNext()) { |
478 | hasInheritDocTag = it.next().isInheritDocTag(); | |
479 | } | |
480 |
1
1. checkComment : negated conditional → KILLED |
final boolean reportExpectedTags = !hasInheritDocTag |
481 |
1
1. checkComment : negated conditional → KILLED |
&& !AnnotationUtil.containsAnnotation(ast, allowedAnnotations); |
482 | ||
483 |
1
1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkParamTags → KILLED |
checkParamTags(tags, ast, reportExpectedTags); |
484 | final List<ExceptionInfo> throwed = | |
485 | combineExceptionInfo(getThrows(ast), getThrowed(ast)); | |
486 |
1
1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkThrowsTags → KILLED |
checkThrowsTags(tags, throwed, reportExpectedTags); |
487 |
1
1. checkComment : negated conditional → KILLED |
if (CheckUtil.isNonVoidMethod(ast)) { |
488 |
1
1. checkComment : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::checkReturnTag → KILLED |
checkReturnTag(tags, ast.getLineNo(), reportExpectedTags); |
489 | } | |
490 | } | |
491 | ||
492 | // Dump out all unused tags | |
493 |
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()) |
494 |
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)); |
495 | } | |
496 | } | |
497 | ||
498 | /** | |
499 | * Validates whether the Javadoc has a short circuit tag. Currently this is | |
500 | * the inheritTag. Any violations are logged. | |
501 | * | |
502 | * @param ast the construct being checked | |
503 | * @param tags the list of Javadoc tags associated with the construct | |
504 | * @return true if the construct has a short circuit tag. | |
505 | */ | |
506 | private boolean hasShortCircuitTag(final DetailAST ast, final List<JavadocTag> tags) { | |
507 | boolean result = true; | |
508 | // Check if it contains {@inheritDoc} tag | |
509 |
1
1. hasShortCircuitTag : negated conditional → KILLED |
if (tags.size() == 1 |
510 |
1
1. hasShortCircuitTag : negated conditional → KILLED |
&& tags.get(0).isInheritDocTag()) { |
511 | // Invalid if private, a constructor, or a static method | |
512 |
1
1. hasShortCircuitTag : negated conditional → KILLED |
if (!JavadocTagInfo.INHERIT_DOC.isValidOn(ast)) { |
513 |
1
1. hasShortCircuitTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(ast, MSG_INVALID_INHERIT_DOC); |
514 | } | |
515 | } | |
516 | else { | |
517 | result = false; | |
518 | } | |
519 |
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; |
520 | } | |
521 | ||
522 | /** | |
523 | * Returns the scope for the method/constructor at the specified AST. If | |
524 | * the method is in an interface or annotation block, the scope is assumed | |
525 | * to be public. | |
526 | * | |
527 | * @param ast the token of the method/constructor | |
528 | * @return the scope of the method/constructor | |
529 | */ | |
530 | private static Scope calculateScope(final DetailAST ast) { | |
531 | final Scope scope; | |
532 | ||
533 |
1
1. calculateScope : negated conditional → KILLED |
if (ScopeUtil.isInInterfaceOrAnnotationBlock(ast)) { |
534 | scope = Scope.PUBLIC; | |
535 | } | |
536 | else { | |
537 | final DetailAST mods = ast.findFirstToken(TokenTypes.MODIFIERS); | |
538 | scope = ScopeUtil.getScopeFromMods(mods); | |
539 | } | |
540 |
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; |
541 | } | |
542 | ||
543 | /** | |
544 | * Returns the tags in a javadoc comment. Only finds throws, exception, | |
545 | * param, return and see tags. | |
546 | * | |
547 | * @param comment the Javadoc comment | |
548 | * @return the tags found | |
549 | */ | |
550 | private static List<JavadocTag> getMethodTags(TextBlock comment) { | |
551 | final String[] lines = comment.getText(); | |
552 |
1
1. getMethodTags : removed call to java/util/ArrayList::<init> → KILLED |
final List<JavadocTag> tags = new ArrayList<>(); |
553 |
1
1. getMethodTags : Replaced integer subtraction with addition → KILLED |
int currentLine = comment.getStartLineNo() - 1; |
554 | final int startColumnNumber = comment.getStartColNo(); | |
555 | ||
556 |
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++) { |
557 |
1
1. getMethodTags : Changed increment from 1 to -1 → KILLED |
currentLine++; |
558 | final Matcher javadocArgMatcher = | |
559 | MATCH_JAVADOC_ARG.matcher(lines[i]); | |
560 | final Matcher javadocArgMissingDescriptionMatcher = | |
561 | MATCH_JAVADOC_ARG_MISSING_DESCRIPTION.matcher(lines[i]); | |
562 | final Matcher javadocNoargMatcher = | |
563 | MATCH_JAVADOC_NOARG.matcher(lines[i]); | |
564 | final Matcher noargCurlyMatcher = | |
565 | MATCH_JAVADOC_NOARG_CURLY.matcher(lines[i]); | |
566 | final Matcher noargMultilineStart = | |
567 | MATCH_JAVADOC_NOARG_MULTILINE_START.matcher(lines[i]); | |
568 | ||
569 |
1
1. getMethodTags : negated conditional → KILLED |
if (javadocArgMatcher.find()) { |
570 | final int col = calculateTagColumn(javadocArgMatcher, i, startColumnNumber); | |
571 | tags.add(new JavadocTag(currentLine, col, javadocArgMatcher.group(1), | |
572 |
1
1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED |
javadocArgMatcher.group(2))); |
573 | } | |
574 |
1
1. getMethodTags : negated conditional → KILLED |
else if (javadocArgMissingDescriptionMatcher.find()) { |
575 | final int col = calculateTagColumn(javadocArgMissingDescriptionMatcher, i, | |
576 | startColumnNumber); | |
577 | tags.add(new JavadocTag(currentLine, col, | |
578 | javadocArgMissingDescriptionMatcher.group(1), | |
579 |
1
1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED |
javadocArgMissingDescriptionMatcher.group(2))); |
580 | } | |
581 |
1
1. getMethodTags : negated conditional → KILLED |
else if (javadocNoargMatcher.find()) { |
582 | final int col = calculateTagColumn(javadocNoargMatcher, i, startColumnNumber); | |
583 |
1
1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED |
tags.add(new JavadocTag(currentLine, col, javadocNoargMatcher.group(1))); |
584 | } | |
585 |
1
1. getMethodTags : negated conditional → KILLED |
else if (noargCurlyMatcher.find()) { |
586 | final int col = calculateTagColumn(noargCurlyMatcher, i, startColumnNumber); | |
587 |
1
1. getMethodTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED |
tags.add(new JavadocTag(currentLine, col, noargCurlyMatcher.group(1))); |
588 | } | |
589 |
1
1. getMethodTags : negated conditional → KILLED |
else if (noargMultilineStart.find()) { |
590 | tags.addAll(getMultilineNoArgTags(noargMultilineStart, lines, i, currentLine)); | |
591 | } | |
592 | } | |
593 |
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; |
594 | } | |
595 | ||
596 | /** | |
597 | * Calculates column number using Javadoc tag matcher. | |
598 | * @param javadocTagMatcher found javadoc tag matcher | |
599 | * @param lineNumber line number of Javadoc tag in comment | |
600 | * @param startColumnNumber column number of Javadoc comment beginning | |
601 | * @return column number | |
602 | */ | |
603 | private static int calculateTagColumn(Matcher javadocTagMatcher, | |
604 | int lineNumber, int startColumnNumber) { | |
605 |
1
1. calculateTagColumn : Replaced integer subtraction with addition → KILLED |
int col = javadocTagMatcher.start(1) - 1; |
606 |
1
1. calculateTagColumn : negated conditional → KILLED |
if (lineNumber == 0) { |
607 |
1
1. calculateTagColumn : Replaced integer addition with subtraction → KILLED |
col += startColumnNumber; |
608 | } | |
609 |
1
1. calculateTagColumn : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return col; |
610 | } | |
611 | ||
612 | /** | |
613 | * Gets multiline Javadoc tags with no arguments. | |
614 | * @param noargMultilineStart javadoc tag Matcher | |
615 | * @param lines comment text lines | |
616 | * @param lineIndex line number that contains the javadoc tag | |
617 | * @param tagLine javadoc tag line number in file | |
618 | * @return javadoc tags with no arguments | |
619 | */ | |
620 | private static List<JavadocTag> getMultilineNoArgTags(final Matcher noargMultilineStart, | |
621 | final String[] lines, final int lineIndex, final int tagLine) { | |
622 | int remIndex = lineIndex; | |
623 | Matcher multilineCont; | |
624 | ||
625 | do { | |
626 |
1
1. getMultilineNoArgTags : Changed increment from 1 to -1 → KILLED |
remIndex++; |
627 | multilineCont = MATCH_JAVADOC_MULTILINE_CONT.matcher(lines[remIndex]); | |
628 |
1
1. getMultilineNoArgTags : negated conditional → KILLED |
} while (!multilineCont.find()); |
629 | ||
630 |
1
1. getMultilineNoArgTags : removed call to java/util/ArrayList::<init> → KILLED |
final List<JavadocTag> tags = new ArrayList<>(); |
631 | final String lFin = multilineCont.group(1); | |
632 |
1
1. getMultilineNoArgTags : negated conditional → KILLED |
if (!lFin.equals(NEXT_TAG) |
633 |
1
1. getMultilineNoArgTags : negated conditional → KILLED |
&& !lFin.equals(END_JAVADOC)) { |
634 | final String param1 = noargMultilineStart.group(1); | |
635 |
1
1. getMultilineNoArgTags : Replaced integer subtraction with addition → KILLED |
final int col = noargMultilineStart.start(1) - 1; |
636 | ||
637 |
1
1. getMultilineNoArgTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTag::<init> → KILLED |
tags.add(new JavadocTag(tagLine, col, param1)); |
638 | } | |
639 | ||
640 |
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; |
641 | } | |
642 | ||
643 | /** | |
644 | * Computes the parameter nodes for a method. | |
645 | * | |
646 | * @param ast the method node. | |
647 | * @return the list of parameter nodes for ast. | |
648 | */ | |
649 | private static List<DetailAST> getParameters(DetailAST ast) { | |
650 | final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS); | |
651 |
1
1. getParameters : removed call to java/util/ArrayList::<init> → KILLED |
final List<DetailAST> returnValue = new ArrayList<>(); |
652 | ||
653 | DetailAST child = params.getFirstChild(); | |
654 |
1
1. getParameters : negated conditional → KILLED |
while (child != null) { |
655 |
1
1. getParameters : negated conditional → KILLED |
if (child.getType() == TokenTypes.PARAMETER_DEF) { |
656 | final DetailAST ident = child.findFirstToken(TokenTypes.IDENT); | |
657 |
1
1. getParameters : negated conditional → KILLED |
if (ident != null) { |
658 | returnValue.add(ident); | |
659 | } | |
660 | } | |
661 | child = child.getNextSibling(); | |
662 | } | |
663 |
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; |
664 | } | |
665 | ||
666 | /** | |
667 | * Computes the exception nodes for a method. | |
668 | * | |
669 | * @param ast the method node. | |
670 | * @return the list of exception nodes for ast. | |
671 | */ | |
672 | private List<ExceptionInfo> getThrows(DetailAST ast) { | |
673 |
1
1. getThrows : removed call to java/util/ArrayList::<init> → KILLED |
final List<ExceptionInfo> returnValue = new ArrayList<>(); |
674 | final DetailAST throwsAST = ast | |
675 | .findFirstToken(TokenTypes.LITERAL_THROWS); | |
676 |
1
1. getThrows : negated conditional → KILLED |
if (throwsAST != null) { |
677 | DetailAST child = throwsAST.getFirstChild(); | |
678 |
1
1. getThrows : negated conditional → KILLED |
while (child != null) { |
679 |
1
1. getThrows : negated conditional → KILLED |
if (child.getType() == TokenTypes.IDENT |
680 |
1
1. getThrows : negated conditional → KILLED |
|| child.getType() == TokenTypes.DOT) { |
681 | final FullIdent ident = FullIdent.createFullIdent(child); | |
682 |
1
1. getThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED |
final ExceptionInfo exceptionInfo = new ExceptionInfo( |
683 |
1
1. getThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::<init> → KILLED |
createClassInfo(new Token(ident), currentClassName)); |
684 | returnValue.add(exceptionInfo); | |
685 | } | |
686 | child = child.getNextSibling(); | |
687 | } | |
688 | } | |
689 |
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; |
690 | } | |
691 | ||
692 | /** | |
693 | * Get ExceptionInfo for all exceptions that throws in method code by 'throw new'. | |
694 | * @param methodAst method DetailAST object where to find exceptions | |
695 | * @return list of ExceptionInfo | |
696 | */ | |
697 | private List<ExceptionInfo> getThrowed(DetailAST methodAst) { | |
698 |
1
1. getThrowed : removed call to java/util/ArrayList::<init> → KILLED |
final List<ExceptionInfo> returnValue = new ArrayList<>(); |
699 | final DetailAST blockAst = methodAst.findFirstToken(TokenTypes.SLIST); | |
700 |
1
1. getThrowed : negated conditional → KILLED |
if (blockAst != null) { |
701 | final List<DetailAST> throwLiterals = findTokensInAstByType(blockAst, | |
702 | TokenTypes.LITERAL_THROW); | |
703 | for (DetailAST throwAst : throwLiterals) { | |
704 | final DetailAST newAst = throwAst.getFirstChild().getFirstChild(); | |
705 |
1
1. getThrowed : negated conditional → KILLED |
if (newAst.getType() == TokenTypes.LITERAL_NEW) { |
706 | final FullIdent ident = FullIdent.createFullIdent(newAst.getFirstChild()); | |
707 |
1
1. getThrowed : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED |
final ExceptionInfo exceptionInfo = new ExceptionInfo( |
708 |
1
1. getThrowed : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::<init> → KILLED |
createClassInfo(new Token(ident), currentClassName)); |
709 | returnValue.add(exceptionInfo); | |
710 | } | |
711 | } | |
712 | } | |
713 |
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; |
714 | } | |
715 | ||
716 | /** | |
717 | * Combine ExceptionInfo lists together by matching names. | |
718 | * @param list1 list of ExceptionInfo | |
719 | * @param list2 list of ExceptionInfo | |
720 | * @return combined list of ExceptionInfo | |
721 | */ | |
722 | private static List<ExceptionInfo> combineExceptionInfo(List<ExceptionInfo> list1, | |
723 | List<ExceptionInfo> list2) { | |
724 |
1
1. combineExceptionInfo : removed call to java/util/ArrayList::<init> → KILLED |
final List<ExceptionInfo> result = new ArrayList<>(list1); |
725 | for (ExceptionInfo expectionInfo : list2) { | |
726 |
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, expectionInfo))) { |
727 | result.add(expectionInfo); | |
728 | } | |
729 | } | |
730 |
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; |
731 | } | |
732 | ||
733 | /** | |
734 | * Finds node of specified type among root children, siblings, siblings children | |
735 | * on any deep level. | |
736 | * @param root DetailAST | |
737 | * @param astType value of TokenType | |
738 | * @return {@link List} of {@link DetailAST} nodes which matches the predicate. | |
739 | */ | |
740 | public static List<DetailAST> findTokensInAstByType(DetailAST root, int astType) { | |
741 |
1
1. findTokensInAstByType : removed call to java/util/ArrayList::<init> → KILLED |
final List<DetailAST> result = new ArrayList<>(); |
742 | DetailAST curNode = root; | |
743 |
1
1. findTokensInAstByType : negated conditional → KILLED |
while (curNode != null) { |
744 | DetailAST toVisit = curNode.getFirstChild(); | |
745 |
2
1. findTokensInAstByType : negated conditional → KILLED 2. findTokensInAstByType : negated conditional → KILLED |
while (curNode != null && toVisit == null) { |
746 | toVisit = curNode.getNextSibling(); | |
747 | curNode = curNode.getParent(); | |
748 |
1
1. findTokensInAstByType : negated conditional → KILLED |
if (curNode == root) { |
749 | toVisit = null; | |
750 | break; | |
751 | } | |
752 | } | |
753 | curNode = toVisit; | |
754 |
2
1. findTokensInAstByType : negated conditional → KILLED 2. findTokensInAstByType : negated conditional → KILLED |
if (curNode != null && curNode.getType() == astType) { |
755 | result.add(curNode); | |
756 | } | |
757 | } | |
758 |
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; |
759 | } | |
760 | ||
761 | /** | |
762 | * Checks a set of tags for matching parameters. | |
763 | * | |
764 | * @param tags the tags to check | |
765 | * @param parent the node which takes the parameters | |
766 | * @param reportExpectedTags whether we should report if do not find | |
767 | * expected tag | |
768 | */ | |
769 | private void checkParamTags(final List<JavadocTag> tags, | |
770 | final DetailAST parent, boolean reportExpectedTags) { | |
771 | final List<DetailAST> params = getParameters(parent); | |
772 | final List<DetailAST> typeParams = CheckUtil | |
773 | .getTypeParameters(parent); | |
774 | ||
775 | // Loop over the tags, checking to see they exist in the params. | |
776 | final ListIterator<JavadocTag> tagIt = tags.listIterator(); | |
777 |
1
1. checkParamTags : negated conditional → KILLED |
while (tagIt.hasNext()) { |
778 | final JavadocTag tag = tagIt.next(); | |
779 | ||
780 |
1
1. checkParamTags : negated conditional → KILLED |
if (!tag.isParamTag()) { |
781 | continue; | |
782 | } | |
783 | ||
784 |
1
1. checkParamTags : removed call to java/util/ListIterator::remove → KILLED |
tagIt.remove(); |
785 | ||
786 | final String arg1 = tag.getFirstArg(); | |
787 | boolean found = removeMatchingParam(params, arg1); | |
788 | ||
789 |
2
1. checkParamTags : negated conditional → KILLED 2. checkParamTags : negated conditional → KILLED |
if (CommonUtil.startsWithChar(arg1, '<') && CommonUtil.endsWithChar(arg1, '>')) { |
790 | found = searchMatchingTypeParameter(typeParams, | |
791 |
1
1. checkParamTags : Replaced integer subtraction with addition → KILLED |
arg1.substring(1, arg1.length() - 1)); |
792 | } | |
793 | ||
794 | // Handle extra JavadocTag | |
795 |
1
1. checkParamTags : negated conditional → KILLED |
if (!found) { |
796 |
1
1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(tag.getLineNo(), tag.getColumnNo(), MSG_UNUSED_TAG, |
797 | "@param", arg1); | |
798 | } | |
799 | } | |
800 | ||
801 | // Now dump out all type parameters/parameters without tags :- unless | |
802 | // the user has chosen to suppress these problems | |
803 |
2
1. checkParamTags : negated conditional → KILLED 2. checkParamTags : negated conditional → KILLED |
if (!allowMissingParamTags && reportExpectedTags) { |
804 | for (DetailAST param : params) { | |
805 |
1
1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(param, MSG_EXPECTED_TAG, |
806 | JavadocTagInfo.PARAM.getText(), param.getText()); | |
807 | } | |
808 | ||
809 | for (DetailAST typeParam : typeParams) { | |
810 |
1
1. checkParamTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(typeParam, MSG_EXPECTED_TAG, |
811 |
1
1. checkParamTags : removed call to java/lang/StringBuilder::<init> → KILLED |
JavadocTagInfo.PARAM.getText(), |
812 | "<" + typeParam.findFirstToken(TokenTypes.IDENT).getText() | |
813 | + ">"); | |
814 | } | |
815 | } | |
816 | } | |
817 | ||
818 | /** | |
819 | * Returns true if required type found in type parameters. | |
820 | * @param typeParams | |
821 | * list of type parameters | |
822 | * @param requiredTypeName | |
823 | * name of required type | |
824 | * @return true if required type found in type parameters. | |
825 | */ | |
826 | private static boolean searchMatchingTypeParameter(List<DetailAST> typeParams, | |
827 | String requiredTypeName) { | |
828 | // Loop looking for matching type param | |
829 | final Iterator<DetailAST> typeParamsIt = typeParams.iterator(); | |
830 | boolean found = false; | |
831 |
1
1. searchMatchingTypeParameter : negated conditional → KILLED |
while (typeParamsIt.hasNext()) { |
832 | final DetailAST typeParam = typeParamsIt.next(); | |
833 | if (typeParam.findFirstToken(TokenTypes.IDENT).getText() | |
834 |
1
1. searchMatchingTypeParameter : negated conditional → KILLED |
.equals(requiredTypeName)) { |
835 | found = true; | |
836 |
1
1. searchMatchingTypeParameter : removed call to java/util/Iterator::remove → KILLED |
typeParamsIt.remove(); |
837 | break; | |
838 | } | |
839 | } | |
840 |
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; |
841 | } | |
842 | ||
843 | /** | |
844 | * Remove parameter from params collection by name. | |
845 | * @param params collection of DetailAST parameters | |
846 | * @param paramName name of parameter | |
847 | * @return true if parameter found and removed | |
848 | */ | |
849 | private static boolean removeMatchingParam(List<DetailAST> params, String paramName) { | |
850 | boolean found = false; | |
851 | final Iterator<DetailAST> paramIt = params.iterator(); | |
852 |
1
1. removeMatchingParam : negated conditional → KILLED |
while (paramIt.hasNext()) { |
853 | final DetailAST param = paramIt.next(); | |
854 |
1
1. removeMatchingParam : negated conditional → KILLED |
if (param.getText().equals(paramName)) { |
855 | found = true; | |
856 |
1
1. removeMatchingParam : removed call to java/util/Iterator::remove → KILLED |
paramIt.remove(); |
857 | break; | |
858 | } | |
859 | } | |
860 |
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; |
861 | } | |
862 | ||
863 | /** | |
864 | * Checks for only one return tag. All return tags will be removed from the | |
865 | * supplied list. | |
866 | * | |
867 | * @param tags the tags to check | |
868 | * @param lineNo the line number of the expected tag | |
869 | * @param reportExpectedTags whether we should report if do not find | |
870 | * expected tag | |
871 | */ | |
872 | private void checkReturnTag(List<JavadocTag> tags, int lineNo, | |
873 | boolean reportExpectedTags) { | |
874 | // Loop over tags finding return tags. After the first one, report an | |
875 | // violation. | |
876 | boolean found = false; | |
877 | final ListIterator<JavadocTag> it = tags.listIterator(); | |
878 |
1
1. checkReturnTag : negated conditional → KILLED |
while (it.hasNext()) { |
879 | final JavadocTag javadocTag = it.next(); | |
880 |
1
1. checkReturnTag : negated conditional → KILLED |
if (javadocTag.isReturnTag()) { |
881 |
1
1. checkReturnTag : negated conditional → KILLED |
if (found) { |
882 |
1
1. checkReturnTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(javadocTag.getLineNo(), javadocTag.getColumnNo(), |
883 | MSG_DUPLICATE_TAG, | |
884 | JavadocTagInfo.RETURN.getText()); | |
885 | } | |
886 | found = true; | |
887 |
1
1. checkReturnTag : removed call to java/util/ListIterator::remove → KILLED |
it.remove(); |
888 | } | |
889 | } | |
890 | ||
891 | // Handle there being no @return tags :- unless | |
892 | // the user has chosen to suppress these problems | |
893 |
3
1. checkReturnTag : negated conditional → KILLED 2. checkReturnTag : negated conditional → KILLED 3. checkReturnTag : negated conditional → KILLED |
if (!found && !allowMissingReturnTag && reportExpectedTags) { |
894 |
1
1. checkReturnTag : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(lineNo, MSG_RETURN_EXPECTED); |
895 | } | |
896 | } | |
897 | ||
898 | /** | |
899 | * Checks a set of tags for matching throws. | |
900 | * | |
901 | * @param tags the tags to check | |
902 | * @param throwsList the throws to check | |
903 | * @param reportExpectedTags whether we should report if do not find | |
904 | * expected tag | |
905 | */ | |
906 | private void checkThrowsTags(List<JavadocTag> tags, | |
907 | List<ExceptionInfo> throwsList, boolean reportExpectedTags) { | |
908 | // Loop over the tags, checking to see they exist in the throws. | |
909 | // The foundThrows used for performance only | |
910 |
1
1. checkThrowsTags : removed call to java/util/HashSet::<init> → KILLED |
final Set<String> foundThrows = new HashSet<>(); |
911 | final ListIterator<JavadocTag> tagIt = tags.listIterator(); | |
912 |
1
1. checkThrowsTags : negated conditional → KILLED |
while (tagIt.hasNext()) { |
913 | final JavadocTag tag = tagIt.next(); | |
914 | ||
915 |
1
1. checkThrowsTags : negated conditional → KILLED |
if (!tag.isThrowsTag()) { |
916 | continue; | |
917 | } | |
918 |
1
1. checkThrowsTags : removed call to java/util/ListIterator::remove → KILLED |
tagIt.remove(); |
919 | ||
920 | // Loop looking for matching throw | |
921 | final Token token = new Token(tag.getFirstArg(), tag.getLineNo(), tag | |
922 |
1
1. checkThrowsTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED |
.getColumnNo()); |
923 | final ClassInfo documentedClassInfo = createClassInfo(token, | |
924 | currentClassName); | |
925 |
1
1. checkThrowsTags : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processThrows → KILLED |
processThrows(throwsList, documentedClassInfo, foundThrows); |
926 | } | |
927 | // Now dump out all throws without tags :- unless | |
928 | // the user has chosen to suppress these problems | |
929 |
2
1. checkThrowsTags : negated conditional → KILLED 2. checkThrowsTags : negated conditional → KILLED |
if (validateThrows && reportExpectedTags) { |
930 |
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()) |
931 |
1
1. checkThrowsTags : removed call to java/util/stream/Stream::forEach → KILLED |
.forEach(exceptionInfo -> { |
932 | final Token token = exceptionInfo.getName(); | |
933 |
1
1. lambda$checkThrowsTags$4 : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::log → KILLED |
log(token.getLineNo(), token.getColumnNo(), |
934 | MSG_EXPECTED_TAG, | |
935 | JavadocTagInfo.THROWS.getText(), token.getText()); | |
936 | }); | |
937 | } | |
938 | } | |
939 | ||
940 | /** | |
941 | * Verifies that documented exception is in throws. | |
942 | * | |
943 | * @param throwsList list of throws | |
944 | * @param documentedClassInfo documented exception class info | |
945 | * @param foundThrows previously found throws | |
946 | */ | |
947 | private static void processThrows(List<ExceptionInfo> throwsList, | |
948 | ClassInfo documentedClassInfo, Set<String> foundThrows) { | |
949 | ExceptionInfo foundException = null; | |
950 | ||
951 | // First look for matches on the exception name | |
952 | for (ExceptionInfo exceptionInfo : throwsList) { | |
953 |
1
1. processThrows : negated conditional → KILLED |
if (isClassNamesSame(exceptionInfo.getName().getText(), |
954 | documentedClassInfo.getName().getText())) { | |
955 | foundException = exceptionInfo; | |
956 | break; | |
957 | } | |
958 | } | |
959 | ||
960 |
1
1. processThrows : negated conditional → KILLED |
if (foundException != null) { |
961 |
1
1. processThrows : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ExceptionInfo::access$100 → KILLED |
foundException.setFound(); |
962 | foundThrows.add(documentedClassInfo.getName().getText()); | |
963 | } | |
964 | } | |
965 | ||
966 | /** | |
967 | * Check that ExceptionInfo objects are same by name. | |
968 | * @param info1 ExceptionInfo object | |
969 | * @param info2 ExceptionInfo object | |
970 | * @return true is ExceptionInfo object have the same name | |
971 | */ | |
972 | private static boolean isExceptionInfoSame(ExceptionInfo info1, ExceptionInfo info2) { | |
973 |
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(), |
974 | info2.getName().getText()); | |
975 | } | |
976 | ||
977 | /** | |
978 | * Check that class names are same by short name of class. If some class name is fully | |
979 | * qualified it is cut to short name. | |
980 | * @param class1 class name | |
981 | * @param class2 class name | |
982 | * @return true is ExceptionInfo object have the same name | |
983 | */ | |
984 | private static boolean isClassNamesSame(String class1, String class2) { | |
985 | boolean result = false; | |
986 |
1
1. isClassNamesSame : negated conditional → KILLED |
if (class1.equals(class2)) { |
987 | result = true; | |
988 | } | |
989 | else { | |
990 | final String separator = "."; | |
991 |
2
1. isClassNamesSame : negated conditional → KILLED 2. isClassNamesSame : negated conditional → KILLED |
if (class1.contains(separator) || class2.contains(separator)) { |
992 | final String class1ShortName = class1 | |
993 |
1
1. isClassNamesSame : Replaced integer addition with subtraction → KILLED |
.substring(class1.lastIndexOf('.') + 1); |
994 | final String class2ShortName = class2 | |
995 |
1
1. isClassNamesSame : Replaced integer addition with subtraction → KILLED |
.substring(class2.lastIndexOf('.') + 1); |
996 | result = class1ShortName.equals(class2ShortName); | |
997 | } | |
998 | } | |
999 |
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; |
1000 | } | |
1001 | ||
1002 | /** | |
1003 | * Process type params (if any) for given class, enum or method. | |
1004 | * @param ast class, enum or method to process. | |
1005 | */ | |
1006 | private void processTypeParams(DetailAST ast) { | |
1007 | final DetailAST params = | |
1008 | ast.findFirstToken(TokenTypes.TYPE_PARAMETERS); | |
1009 | ||
1010 |
1
1. processTypeParams : removed call to java/util/HashMap::<init> → KILLED |
final Map<String, ClassInfo> paramsMap = new HashMap<>(); |
1011 |
1
1. processTypeParams : removed call to java/util/Deque::push → KILLED |
currentTypeParams.push(paramsMap); |
1012 | ||
1013 |
1
1. processTypeParams : negated conditional → KILLED |
if (params != null) { |
1014 | for (DetailAST child = params.getFirstChild(); | |
1015 |
1
1. processTypeParams : negated conditional → SURVIVED |
child != null; |
1016 | child = child.getNextSibling()) { | |
1017 |
1
1. processTypeParams : negated conditional → SURVIVED |
if (child.getType() == TokenTypes.TYPE_PARAMETER) { |
1018 | final DetailAST bounds = | |
1019 | child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS); | |
1020 |
1
1. processTypeParams : negated conditional → KILLED |
if (bounds != null) { |
1021 | final FullIdent name = | |
1022 | FullIdent.createFullIdentBelow(bounds); | |
1023 |
1
1. processTypeParams : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$Token::<init> → KILLED |
final ClassInfo classInfo = |
1024 | createClassInfo(new Token(name), currentClassName); | |
1025 | final String alias = | |
1026 | child.findFirstToken(TokenTypes.IDENT).getText(); | |
1027 | paramsMap.put(alias, classInfo); | |
1028 | } | |
1029 | } | |
1030 | } | |
1031 | } | |
1032 | } | |
1033 | ||
1034 | /** | |
1035 | * Processes class definition. | |
1036 | * @param ast class definition to process. | |
1037 | */ | |
1038 | private void processClass(DetailAST ast) { | |
1039 | final DetailAST ident = ast.findFirstToken(TokenTypes.IDENT); | |
1040 | String innerClass = ident.getText(); | |
1041 | ||
1042 |
1
1. processClass : negated conditional → SURVIVED |
if (!currentClassName.isEmpty()) { |
1043 |
1
1. processClass : removed call to java/lang/StringBuilder::<init> → KILLED |
innerClass = "$" + innerClass; |
1044 | } | |
1045 |
1
1. processClass : removed call to java/lang/StringBuilder::<init> → KILLED |
currentClassName += innerClass; |
1046 |
1
1. processClass : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck::processTypeParams → KILLED |
processTypeParams(ast); |
1047 | } | |
1048 | ||
1049 | /** | |
1050 | * Creates class info for given name. | |
1051 | * @param name name of type. | |
1052 | * @param surroundingClass name of surrounding class. | |
1053 | * @return class info for given name. | |
1054 | */ | |
1055 | private ClassInfo createClassInfo(final Token name, | |
1056 | final String surroundingClass) { | |
1057 | final ClassInfo result; | |
1058 | final ClassInfo classInfo = findClassAlias(name.getText()); | |
1059 |
1
1. createClassInfo : negated conditional → SURVIVED |
if (classInfo == null) { |
1060 |
1
1. createClassInfo : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$RegularClass::<init> → KILLED |
result = new RegularClass(name, surroundingClass, this); |
1061 | } | |
1062 | else { | |
1063 |
1
1. createClassInfo : removed call to com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck$ClassAlias::<init> → KILLED |
result = new ClassAlias(name, classInfo); |
1064 | } | |
1065 |
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; |
1066 | } | |
1067 | ||
1068 | /** | |
1069 | * Looking if a given name is alias. | |
1070 | * @param name given name | |
1071 | * @return ClassInfo for alias if it exists, null otherwise | |
1072 | * @noinspection WeakerAccess | |
1073 | */ | |
1074 | private ClassInfo findClassAlias(final String name) { | |
1075 | ClassInfo classInfo = null; | |
1076 | final Iterator<Map<String, ClassInfo>> iterator = currentTypeParams | |
1077 | .descendingIterator(); | |
1078 |
1
1. findClassAlias : negated conditional → SURVIVED |
while (iterator.hasNext()) { |
1079 | final Map<String, ClassInfo> paramMap = iterator.next(); | |
1080 | classInfo = paramMap.get(name); | |
1081 |
1
1. findClassAlias : negated conditional → SURVIVED |
if (classInfo != null) { |
1082 | break; | |
1083 | } | |
1084 | } | |
1085 |
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; |
1086 | } | |
1087 | ||
1088 | /** | |
1089 | * Contains class's {@code Token}. | |
1090 | */ | |
1091 | private static class ClassInfo { | |
1092 | ||
1093 | /** {@code FullIdent} associated with this class. */ | |
1094 | private final Token name; | |
1095 | ||
1096 | /** | |
1097 | * Creates new instance of class information object. | |
1098 | * @param className token which represents class name. | |
1099 | * @throws IllegalArgumentException when className is nulls | |
1100 | */ | |
1101 | protected ClassInfo(final Token className) { | |
1102 |
1
1. |
if (className == null) { |
1103 |
1
1. |
throw new IllegalArgumentException( |
1104 | "ClassInfo's name should be non-null"); | |
1105 | } | |
1106 | name = className; | |
1107 | } | |
1108 | ||
1109 | /** | |
1110 | * Gets class name. | |
1111 | * @return class name | |
1112 | */ | |
1113 | public final Token getName() { | |
1114 |
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; |
1115 | } | |
1116 | ||
1117 | } | |
1118 | ||
1119 | /** Represents regular classes/enums. */ | |
1120 | private static final class RegularClass extends ClassInfo { | |
1121 | ||
1122 | /** Name of surrounding class. */ | |
1123 | private final String surroundingClass; | |
1124 | /** The check we use to resolve classes. */ | |
1125 | private final JavadocMethodCheck check; | |
1126 | ||
1127 | /** | |
1128 | * Creates new instance of of class information object. | |
1129 | * @param name {@code FullIdent} associated with new object. | |
1130 | * @param surroundingClass name of current surrounding class. | |
1131 | * @param check the check we use to load class. | |
1132 | */ | |
1133 | /* package */ RegularClass(final Token name, | |
1134 | final String surroundingClass, | |
1135 | final JavadocMethodCheck check) { | |
1136 | super(name); | |
1137 | this.surroundingClass = surroundingClass; | |
1138 | this.check = check; | |
1139 | } | |
1140 | ||
1141 | @Override | |
1142 | public String toString() { | |
1143 |
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() |
1144 | + ", in class='" + surroundingClass + '\'' | |
1145 | + ", check=" + check.hashCode() | |
1146 | + ']'; | |
1147 | } | |
1148 | ||
1149 | } | |
1150 | ||
1151 | /** Represents type param which is "alias" for real type. */ | |
1152 | private static class ClassAlias extends ClassInfo { | |
1153 | ||
1154 | /** Class information associated with the alias. */ | |
1155 | private final ClassInfo classInfo; | |
1156 | ||
1157 | /** | |
1158 | * Creates new instance of the class. | |
1159 | * @param name token which represents name of class alias. | |
1160 | * @param classInfo class information associated with the alias. | |
1161 | */ | |
1162 | /* package */ ClassAlias(final Token name, ClassInfo classInfo) { | |
1163 | super(name); | |
1164 | this.classInfo = classInfo; | |
1165 | } | |
1166 | ||
1167 | @Override | |
1168 | public String toString() { | |
1169 |
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() + "]"; |
1170 | } | |
1171 | ||
1172 | } | |
1173 | ||
1174 | /** | |
1175 | * Represents text element with location in the text. | |
1176 | */ | |
1177 | private static class Token { | |
1178 | ||
1179 | /** Token's column number. */ | |
1180 | private final int columnNo; | |
1181 | /** Token's line number. */ | |
1182 | private final int lineNo; | |
1183 | /** Token's text. */ | |
1184 | private final String text; | |
1185 | ||
1186 | /** | |
1187 | * Creates token. | |
1188 | * @param text token's text | |
1189 | * @param lineNo token's line number | |
1190 | * @param columnNo token's column number | |
1191 | */ | |
1192 | /* package */ Token(String text, int lineNo, int columnNo) { | |
1193 | this.text = text; | |
1194 | this.lineNo = lineNo; | |
1195 | this.columnNo = columnNo; | |
1196 | } | |
1197 | ||
1198 | /** | |
1199 | * Converts FullIdent to Token. | |
1200 | * @param fullIdent full ident to convert. | |
1201 | */ | |
1202 | /* package */ Token(FullIdent fullIdent) { | |
1203 | text = fullIdent.getText(); | |
1204 | lineNo = fullIdent.getLineNo(); | |
1205 | columnNo = fullIdent.getColumnNo(); | |
1206 | } | |
1207 | ||
1208 | /** | |
1209 | * Gets line number of the token. | |
1210 | * @return line number of the token | |
1211 | */ | |
1212 | public int getLineNo() { | |
1213 |
1
1. getLineNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return lineNo; |
1214 | } | |
1215 | ||
1216 | /** | |
1217 | * Gets column number of the token. | |
1218 | * @return column number of the token | |
1219 | */ | |
1220 | public int getColumnNo() { | |
1221 |
1
1. getColumnNo : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return columnNo; |
1222 | } | |
1223 | ||
1224 | /** | |
1225 | * Gets text of the token. | |
1226 | * @return text of the token | |
1227 | */ | |
1228 | public String getText() { | |
1229 |
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; |
1230 | } | |
1231 | ||
1232 | @Override | |
1233 | public String toString() { | |
1234 |
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 |
1235 | + "x" + columnNo + ")]"; | |
1236 | } | |
1237 | ||
1238 | } | |
1239 | ||
1240 | /** Stores useful information about declared exception. */ | |
1241 | private static class ExceptionInfo { | |
1242 | ||
1243 | /** Class information associated with this exception. */ | |
1244 | private final ClassInfo classInfo; | |
1245 | /** Does the exception have throws tag associated with. */ | |
1246 | private boolean found; | |
1247 | ||
1248 | /** | |
1249 | * Creates new instance for {@code FullIdent}. | |
1250 | * | |
1251 | * @param classInfo class info | |
1252 | */ | |
1253 | /* package */ ExceptionInfo(ClassInfo classInfo) { | |
1254 | this.classInfo = classInfo; | |
1255 | } | |
1256 | ||
1257 | /** Mark that the exception has associated throws tag. */ | |
1258 | private void setFound() { | |
1259 | found = true; | |
1260 | } | |
1261 | ||
1262 | /** | |
1263 | * Checks that the exception has throws tag associated with it. | |
1264 | * @return whether the exception has throws tag associated with | |
1265 | */ | |
1266 | private boolean isFound() { | |
1267 |
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; |
1268 | } | |
1269 | ||
1270 | /** | |
1271 | * Gets exception name. | |
1272 | * @return exception's name | |
1273 | */ | |
1274 | private Token getName() { | |
1275 |
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(); |
1276 | } | |
1277 | ||
1278 | } | |
1279 | ||
1280 | } | |
Mutations | ||
267 |
1.1 |
|
356 |
1.1 |
|
365 |
1.1 |
|
370 |
1.1 |
|
383 |
1.1 |
|
388 |
1.1 |
|
389 |
1.1 |
|
390 |
1.1 |
|
391 |
1.1 |
|
394 |
1.1 |
|
395 |
1.1 |
|
397 |
1.1 |
|
403 |
1.1 |
|
404 |
1.1 |
|
405 |
1.1 |
|
408 |
1.1 |
|
412 |
1.1 |
|
421 |
1.1 |
|
433 |
1.1 |
|
437 |
1.1 |
|
438 |
1.1 |
|
453 |
1.1 2.2 3.3 4.4 5.5 |
|
456 |
1.1 |
|
457 |
1.1 |
|
469 |
1.1 |
|
470 |
1.1 |
|
471 |
1.1 |
|
477 |
1.1 2.2 |
|
480 |
1.1 |
|
481 |
1.1 |
|
483 |
1.1 |
|
486 |
1.1 |
|
487 |
1.1 |
|
488 |
1.1 |
|
493 |
1.1 2.2 3.3 |
|
494 |
1.1 2.2 |
|
509 |
1.1 |
|
510 |
1.1 |
|
512 |
1.1 |
|
513 |
1.1 |
|
519 |
1.1 2.2 3.3 |
|
533 |
1.1 |
|
540 |
1.1 |
|
552 |
1.1 |
|
553 |
1.1 |
|
556 |
1.1 2.2 3.3 |
|
557 |
1.1 |
|
569 |
1.1 |
|
572 |
1.1 |
|
574 |
1.1 |
|
579 |
1.1 |
|
581 |
1.1 |
|
583 |
1.1 |
|
585 |
1.1 |
|
587 |
1.1 |
|
589 |
1.1 |
|
593 |
1.1 |
|
605 |
1.1 |
|
606 |
1.1 |
|
607 |
1.1 |
|
609 |
1.1 |
|
626 |
1.1 |
|
628 |
1.1 |
|
630 |
1.1 |
|
632 |
1.1 |
|
633 |
1.1 |
|
635 |
1.1 |
|
637 |
1.1 |
|
640 |
1.1 |
|
651 |
1.1 |
|
654 |
1.1 |
|
655 |
1.1 |
|
657 |
1.1 |
|
663 |
1.1 |
|
673 |
1.1 |
|
676 |
1.1 |
|
678 |
1.1 |
|
679 |
1.1 |
|
680 |
1.1 |
|
682 |
1.1 |
|
683 |
1.1 |
|
689 |
1.1 |
|
698 |
1.1 |
|
700 |
1.1 |
|
705 |
1.1 |
|
707 |
1.1 |
|
708 |
1.1 |
|
713 |
1.1 |
|
724 |
1.1 |
|
726 |
1.1 2.2 3.3 4.4 |
|
730 |
1.1 |
|
741 |
1.1 |
|
743 |
1.1 |
|
745 |
1.1 2.2 |
|
748 |
1.1 |
|
754 |
1.1 2.2 |
|
758 |
1.1 |
|
777 |
1.1 |
|
780 |
1.1 |
|
784 |
1.1 |
|
789 |
1.1 2.2 |
|
791 |
1.1 |
|
795 |
1.1 |
|
796 |
1.1 |
|
803 |
1.1 2.2 |
|
805 |
1.1 |
|
810 |
1.1 |
|
811 |
1.1 |
|
831 |
1.1 |
|
834 |
1.1 |
|
836 |
1.1 |
|
840 |
1.1 2.2 3.3 |
|
852 |
1.1 |
|
854 |
1.1 |
|
856 |
1.1 |
|
860 |
1.1 2.2 3.3 |
|
878 |
1.1 |
|
880 |
1.1 |
|
881 |
1.1 |
|
882 |
1.1 |
|
887 |
1.1 |
|
893 |
1.1 2.2 3.3 |
|
894 |
1.1 |
|
910 |
1.1 |
|
912 |
1.1 |
|
915 |
1.1 |
|
918 |
1.1 |
|
922 |
1.1 |
|
925 |
1.1 |
|
929 |
1.1 2.2 |
|
930 |
1.1 2.2 3.3 |
|
931 |
1.1 |
|
933 |
1.1 |
|
953 |
1.1 |
|
960 |
1.1 |
|
961 |
1.1 |
|
973 |
1.1 2.2 3.3 |
|
986 |
1.1 |
|
991 |
1.1 2.2 |
|
993 |
1.1 |
|
995 |
1.1 |
|
999 |
1.1 2.2 3.3 |
|
1010 |
1.1 |
|
1011 |
1.1 |
|
1013 |
1.1 |
|
1015 |
1.1 |
|
1017 |
1.1 |
|
1020 |
1.1 |
|
1023 |
1.1 |
|
1042 |
1.1 |
|
1043 |
1.1 |
|
1045 |
1.1 |
|
1046 |
1.1 |
|
1059 |
1.1 |
|
1060 |
1.1 |
|
1063 |
1.1 |
|
1065 |
1.1 |
|
1078 |
1.1 |
|
1081 |
1.1 |
|
1085 |
1.1 |
|
1102 |
1.1 |
|
1103 |
1.1 |
|
1114 |
1.1 |
|
1143 |
1.1 2.2 |
|
1169 |
1.1 2.2 |
|
1213 |
1.1 |
|
1221 |
1.1 |
|
1229 |
1.1 |
|
1234 |
1.1 2.2 |
|
1267 |
1.1 2.2 3.3 |
|
1275 |
1.1 |