Search in sources :

Example 6 with ModuleFactory

use of com.puppycrawl.tools.checkstyle.ModuleFactory in project checkstyle by checkstyle.

the class XdocsPagesTest method testAllCheckSectionsEx.

/**
 * Test contains asserts in callstack, but idea does not see them.
 *
 * @noinspection JUnitTestMethodWithNoAssertions
 */
@Test
public void testAllCheckSectionsEx() throws Exception {
    final ModuleFactory moduleFactory = TestUtil.getPackageObjectFactory();
    final Path path = Paths.get(XdocUtil.DIRECTORY_PATH + "/config.xml");
    final String fileName = path.getFileName().toString();
    final String input = Files.readString(path);
    final Document document = XmlUtil.getRawXml(fileName, input, input);
    final NodeList sources = document.getElementsByTagName("section");
    for (int position = 0; position < sources.getLength(); position++) {
        final Node section = sources.item(position);
        final String sectionName = XmlUtil.getNameAttributeOfNode(section);
        if (!"Checker".equals(sectionName) && !"TreeWalker".equals(sectionName)) {
            continue;
        }
        validateCheckSection(moduleFactory, fileName, sectionName, section);
    }
}
Also used : Path(java.nio.file.Path) ModuleFactory(com.puppycrawl.tools.checkstyle.ModuleFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) Test(org.junit.jupiter.api.Test)

Example 7 with ModuleFactory

use of com.puppycrawl.tools.checkstyle.ModuleFactory in project checkstyle by checkstyle.

the class XdocsJavaDocsTest method testAllCheckSectionJavaDocs.

/**
 * Test contains asserts in callstack, but idea does not see them.
 *
 * @noinspection JUnitTestMethodWithNoAssertions
 */
@Test
public void testAllCheckSectionJavaDocs() throws Exception {
    final ModuleFactory moduleFactory = TestUtil.getPackageObjectFactory();
    for (Path path : XdocUtil.getXdocsConfigFilePaths(XdocUtil.getXdocsFilePaths())) {
        final File file = path.toFile();
        final String fileName = file.getName();
        if ("config_system_properties.xml".equals(fileName)) {
            continue;
        }
        final String input = Files.readString(path);
        final Document document = XmlUtil.getRawXml(fileName, input, input);
        final NodeList sources = document.getElementsByTagName("section");
        for (int position = 0; position < sources.getLength(); position++) {
            final Node section = sources.item(position);
            final String sectionName = XmlUtil.getNameAttributeOfNode(section);
            if ("Content".equals(sectionName) || "Overview".equals(sectionName)) {
                continue;
            }
            examineCheckSection(moduleFactory, fileName, sectionName, section);
        }
    }
}
Also used : Path(java.nio.file.Path) ModuleFactory(com.puppycrawl.tools.checkstyle.ModuleFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)7 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)3 CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)3 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)3 Path (java.nio.file.Path)3 Test (org.junit.jupiter.api.Test)3 Document (org.w3c.dom.Document)3 Node (org.w3c.dom.Node)3 NodeList (org.w3c.dom.NodeList)3 Checker (com.puppycrawl.tools.checkstyle.Checker)2 AbstractCheck (com.puppycrawl.tools.checkstyle.api.AbstractCheck)2 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 DependencyInformationConsumerInjector (com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector)1 DependencyInformationConsumer (com.github.sevntu.checkstyle.module.DependencyInformationConsumer)1 MethodCallDependencyCheckstyleModule (com.github.sevntu.checkstyle.module.MethodCallDependencyCheckstyleModule)1 ViolationReporterDependencyInformationConsumer (com.github.sevntu.checkstyle.module.ViolationReporterDependencyInformationConsumer)1 ConfigurationLoader (com.puppycrawl.tools.checkstyle.ConfigurationLoader)1