use of com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck in project checkstyle by checkstyle.
the class XdocsPagesTest method fixCapturedProperties.
private static void fixCapturedProperties(String sectionName, Object instance, Class<?> clss, Set<String> properties) {
// remove global properties that don't need documentation
if (hasParentModule(sectionName)) {
if (AbstractJavadocCheck.class.isAssignableFrom(clss)) {
properties.removeAll(JAVADOC_CHECK_PROPERTIES);
// override
properties.add("violateExecutionOnNonTightHtml");
} else if (AbstractCheck.class.isAssignableFrom(clss)) {
properties.removeAll(CHECK_PROPERTIES);
}
}
if (AbstractFileSetCheck.class.isAssignableFrom(clss)) {
properties.removeAll(FILESET_PROPERTIES);
// override
properties.add("fileExtensions");
}
// remove undocumented properties
new HashSet<>(properties).stream().filter(prop -> UNDOCUMENTED_PROPERTIES.contains(clss.getSimpleName() + "." + prop)).forEach(properties::remove);
if (AbstractCheck.class.isAssignableFrom(clss)) {
final AbstractCheck check = (AbstractCheck) instance;
final int[] acceptableTokens = check.getAcceptableTokens();
Arrays.sort(acceptableTokens);
final int[] defaultTokens = check.getDefaultTokens();
Arrays.sort(defaultTokens);
final int[] requiredTokens = check.getRequiredTokens();
Arrays.sort(requiredTokens);
if (!Arrays.equals(acceptableTokens, defaultTokens) || !Arrays.equals(acceptableTokens, requiredTokens)) {
properties.add("tokens");
}
}
if (AbstractJavadocCheck.class.isAssignableFrom(clss)) {
final AbstractJavadocCheck check = (AbstractJavadocCheck) instance;
final int[] acceptableJavadocTokens = check.getAcceptableJavadocTokens();
Arrays.sort(acceptableJavadocTokens);
final int[] defaultJavadocTokens = check.getDefaultJavadocTokens();
Arrays.sort(defaultJavadocTokens);
final int[] requiredJavadocTokens = check.getRequiredJavadocTokens();
Arrays.sort(requiredJavadocTokens);
if (!Arrays.equals(acceptableJavadocTokens, defaultJavadocTokens) || !Arrays.equals(acceptableJavadocTokens, requiredJavadocTokens)) {
properties.add("javadocTokens");
}
}
}
use of com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck in project checkstyle by checkstyle.
the class XdocsPagesTest method validatePropertySectionProperties.
private static void validatePropertySectionProperties(String fileName, String sectionName, Node table, Object instance, Set<String> properties) throws Exception {
boolean skip = true;
boolean didJavadocTokens = false;
boolean didTokens = false;
for (Node row : XmlUtil.getChildrenElements(table)) {
final List<Node> columns = new ArrayList<>(XmlUtil.getChildrenElements(row));
assertWithMessage(fileName + " section '" + sectionName + "' should have the requested columns").that(columns).hasSize(5);
if (skip) {
assertWithMessage(fileName + " section '" + sectionName + "' should have the specific title").that(columns.get(0).getTextContent()).isEqualTo("name");
assertWithMessage(fileName + " section '" + sectionName + "' should have the specific title").that(columns.get(1).getTextContent()).isEqualTo("description");
assertWithMessage(fileName + " section '" + sectionName + "' should have the specific title").that(columns.get(2).getTextContent()).isEqualTo("type");
assertWithMessage(fileName + " section '" + sectionName + "' should have the specific title").that(columns.get(3).getTextContent()).isEqualTo("default value");
assertWithMessage(fileName + " section '" + sectionName + "' should have the specific title").that(columns.get(4).getTextContent()).isEqualTo("since");
skip = false;
continue;
}
assertWithMessage(fileName + " section '" + sectionName + "' should have token properties last").that(didTokens).isFalse();
final String propertyName = columns.get(0).getTextContent();
assertWithMessage(fileName + " section '" + sectionName + "' should not contain the property: " + propertyName).that(properties.remove(propertyName)).isTrue();
if ("tokens".equals(propertyName)) {
final AbstractCheck check = (AbstractCheck) instance;
validatePropertySectionPropertyTokens(fileName, sectionName, check, columns);
didTokens = true;
} else if ("javadocTokens".equals(propertyName)) {
final AbstractJavadocCheck check = (AbstractJavadocCheck) instance;
validatePropertySectionPropertyJavadocTokens(fileName, sectionName, check, columns);
didJavadocTokens = true;
} else {
assertWithMessage(fileName + " section '" + sectionName + "' should have javadoc token properties next to last, before tokens").that(didJavadocTokens).isFalse();
validatePropertySectionPropertyEx(fileName, sectionName, instance, columns, propertyName);
}
assertWithMessage("%s section '%s' should have a version for %s", fileName, sectionName, propertyName).that(columns.get(4).getTextContent().trim()).isNotEmpty();
assertWithMessage("%s section '%s' should have a valid version for %s", fileName, sectionName, propertyName).that(columns.get(4).getTextContent().trim()).matches(VERSION);
}
}
Aggregations