Discovered in #17675
These two methods essentially do the same thing, except getDescriptionFromJavadocForXdoc also processes extracted description for Xdoc.
Reusing getFirstParagraphFromJavadoc for getDescriptionFromJavadocForXdoc just with addition of xdoc wrapping would make functionality easier.
Class Data Abstraction Coupling is 8 (max allowed is 7) classes [ArrayDeque, Checker, DefaultConfiguration, DetailNode, LinkedHashMap, MacroExecutionException, PackageObjectFactory, Pattern]. [ClassDataAbstractionCoupling]
Fixing it, potentially with the side-effect of integratinggetFirstParagraphFromJavadoc to getDescriptionFromJavadocForXdoc would also make functionality easier and project better.
Remove coverage suppressions for MetadataGeneratorUtil and XmlMetaWriter, most of which, if not all, will be removed once migration of simplified javadocs to all modules is complete
XmlMetaWriter coverage used to be 0.77
Complains about coverage in
|
if (defaultValue != null && !"null".equals(defaultValue)) { |
Currently, MetadataGeneratorUtil has 0.95 of true coverage.
Complains about coverage for such catch statements:
|
catch (TransformerException | ParserConfigurationException example) { |
|
throw new CheckstyleException( |
|
"Failed to write metadata into XML file for module: " |
|
+ moduleDetails.getName(), example); |
|
} |
|
catch (MacroExecutionException macroException) { |
|
throw new CheckstyleException(macroException.getMessage(), macroException); |
|
} |
Decided to keep the same coverage for XmlMetaWriter because without complained part, the xml files are going to be rewritten significantly with newly added `default-value = 'null'`` statement
Meanwhile, stopped fixing coverage for MetadataGeneratorUtil at 0.95 because what is left is those catch statements shown above which could be useful in the future, but are very problematic to be tested to fix the coverage.
Current idea inspection suppression:
|
<!-- Until #17746 --> |
|
<inspection_tool class="CheckTagEmptyBody" enabled="false" level="ERROR" |
|
enabled_by_default="true"/> |
Example inspection error message from ci/circleci: run-inspections:
<problem>
<file>file://$PROJECT_DIR$/src/site/xdoc/checks/coding/matchxpath.xml</file>
<line>51</line>
<module>project</module>
<entry_point TYPE="file" FQNAME="file://$PROJECT_DIR$/src/site/xdoc/checks/coding/matchxpath.xml"/>
<problem_class id="CheckTagEmptyBody" severity="ERROR" attribute_key="ERRORS_ATTRIBUTES">Empty element content</problem_class>
<description>XML tag has empty body</description>
<highlighted_element><code></code></highlighted_element>
<language>XML</language>
<offset>18</offset>
<length>13</length>
</problem>
Revise the implementation of finding end of description so it will be more universal and reliable, and won't depend solely on @since ending tag. Probably nail it to the last line separator in the module's javadoc.
Consider following code for getDescriptionEndNode:
|
/** |
|
* Gets the end node of the description. |
|
* |
|
* @param moduleJavadoc javadoc of module. |
|
* @return the end index. |
|
*/ |
|
public static DetailNode getDescriptionEndNode(DetailNode moduleJavadoc) { |
|
final DetailNode descriptionEndNode; |
|
|
|
final DetailNode notesStartingNode = |
|
getNotesSectionStartNode(moduleJavadoc); |
|
|
|
if (notesStartingNode != null) { |
|
descriptionEndNode = notesStartingNode.getPreviousSibling(); |
|
} |
|
else { |
|
descriptionEndNode = getModuleSinceVersionTagStartNode( |
|
moduleJavadoc).getPreviousSibling(); |
|
} |
|
|
|
return descriptionEndNode; |
|
} |
and consider following Example:
|
* @since 3.4 |
|
* @noinspection HtmlTagCanBeJavadocTag |
|
* @noinspectionreason HtmlTagCanBeJavadocTag - encoded symbols were not decoded |
|
* when replaced with Javadoc tag |
As far as I recall, getDescriptionEndNode would take both @noinspection tags if @since tag would be placed at the most bottom. I believe we have to make it more flexible so @since tag could be placed in any order, but not necessarily first to avoid extra tags
|
/** |
|
* Checks whether property is to contain tokens. |
|
* |
|
* @param propertyField property field. |
|
* @return true if property is to contain tokens, false otherwise. |
|
*/ |
|
public static boolean isPropertySpecialTokenProp(Field propertyField) { |
|
boolean result = false; |
|
|
|
if (propertyField != null) { |
|
final XdocsPropertyType fieldXdocAnnotation = |
|
propertyField.getAnnotation(XdocsPropertyType.class); |
|
|
|
result = fieldXdocAnnotation != null |
|
&& fieldXdocAnnotation.value() == PropertyType.TOKEN_ARRAY; |
|
} |
|
|
|
return result; |
|
} |
|
|
|
} |
Move methods like isPropertySpecialTokenProp to more belonging locations
UPDATE: this step was decided to be left with as is, since it is not being used that much and moving it out would potentially create cyclical dependency.

Discovered in #17675
Consider the following methods:
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
Lines 1457 to 1481 in a4f3688
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java
Lines 1392 to 1449 in a4f3688
These two methods essentially do the same thing, except
getDescriptionFromJavadocForXdocalso processes extracted description for Xdoc.Reusing
getFirstParagraphFromJavadocforgetDescriptionFromJavadocForXdocjust with addition of xdoc wrapping would make functionality easier.As result of new implementation, the following error pops up that is temporarily suppressed:
Class Data Abstraction Coupling is 8 (max allowed is 7) classes [ArrayDeque, Checker, DefaultConfiguration, DetailNode, LinkedHashMap, MacroExecutionException, PackageObjectFactory, Pattern]. [ClassDataAbstractionCoupling]Fixing it, potentially with the side-effect of integrating
getFirstParagraphFromJavadoctogetDescriptionFromJavadocForXdocwould also make functionality easier and project better.Suppressions
Remove coverage suppressions for
MetadataGeneratorUtilandXmlMetaWriter, most of which, if not all, will be removed once migration of simplified javadocs to all modules is completeXmlMetaWriter coverage used to be 0.77
checkstyle/pom.xml
Line 1490 in 2bb01a1
Complains about coverage in
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/meta/XmlMetaWriter.java
Line 131 in 2bb01a1
Currently, MetadataGeneratorUtil has 0.95 of true coverage.
Complains about coverage for such catch statements:
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtil.java
Lines 231 to 235 in 2bb01a1
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtil.java
Lines 81 to 83 in 2bb01a1
Decided to keep the same coverage for
XmlMetaWriterbecause without complained part, the xml files are going to be rewritten significantly with newly added `default-value = 'null'`` statementMeanwhile, stopped fixing coverage for
MetadataGeneratorUtilat 0.95 because what is left is those catch statements shown above which could be useful in the future, but are very problematic to be tested to fix the coverage.Current idea inspection suppression:
checkstyle/config/intellij-idea-inspections.xml
Lines 1066 to 1068 in ef26680
Example inspection error message from
ci/circleci: run-inspections:Revise the implementation of finding end of description so it will be more universal and reliable, and won't depend solely on
@sinceending tag. Probably nail it to the last line separator in the module's javadoc.Consider following code for
getDescriptionEndNode:checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/site/ModuleJavadocParsingUtil.java
Lines 178 to 199 in 343cc19
and consider following Example:
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheck.java
Lines 89 to 92 in 343cc19
As far as I recall,
getDescriptionEndNodewould take both@noinspectiontags if@sincetag would be placed at the most bottom. I believe we have to make it more flexible so@since tagcould be placed in any order, but not necessarily first to avoid extra tagscheckstyle/src/main/java/com/puppycrawl/tools/checkstyle/site/ModuleJavadocParsingUtil.java
Lines 293 to 313 in dc514af
Move methods like
isPropertySpecialTokenPropto more belonging locationsUPDATE: this step was decided to be left with as is, since it is not being used that much and moving it out would potentially create cyclical dependency.