Search in sources :

Example 1 with TreeWalker

use of com.puppycrawl.tools.checkstyle.TreeWalker in project methods-distance by sevntu-checkstyle.

the class ReportCli method main.

public static void main(String... args) throws CheckstyleException {
    final DependencyInformationConsumer consumer = new ViolationReporterDependencyInformationConsumer();
    final ModuleFactory moduleFactory = new DependencyInformationConsumerInjector(consumer);
    final DefaultConfiguration moduleConfig = new DefaultConfiguration(MethodCallDependencyCheckstyleModule.class.getCanonicalName());
    moduleConfig.addAttribute("screenLinesCount", "50");
    final TreeWalker tw = new TreeWalker();
    tw.setModuleFactory(moduleFactory);
    tw.finishLocalSetup();
    tw.setupChild(moduleConfig);
    final AuditListener listener = new DefaultLogger(System.out, false);
    final Checker checker = new Checker();
    checker.setModuleFactory(moduleFactory);
    checker.addFileSetCheck(tw);
    checker.addListener(listener);
    final List<File> files = Collections.singletonList(new File(args[0]));
    checker.process(files);
}
Also used : ModuleFactory(com.puppycrawl.tools.checkstyle.ModuleFactory) Checker(com.puppycrawl.tools.checkstyle.Checker) ViolationReporterDependencyInformationConsumer(com.github.sevntu.checkstyle.module.ViolationReporterDependencyInformationConsumer) DependencyInformationConsumerInjector(com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector) TreeWalker(com.puppycrawl.tools.checkstyle.TreeWalker) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) MethodCallDependencyCheckstyleModule(com.github.sevntu.checkstyle.module.MethodCallDependencyCheckstyleModule) AuditListener(com.puppycrawl.tools.checkstyle.api.AuditListener) ViolationReporterDependencyInformationConsumer(com.github.sevntu.checkstyle.module.ViolationReporterDependencyInformationConsumer) DependencyInformationConsumer(com.github.sevntu.checkstyle.module.DependencyInformationConsumer) DefaultLogger(com.puppycrawl.tools.checkstyle.DefaultLogger) File(java.io.File)

Example 2 with TreeWalker

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

the class TestInputConfiguration method createConfigurationWithoutFilters.

public DefaultConfiguration createConfigurationWithoutFilters() {
    final DefaultConfiguration root = new DefaultConfiguration(ROOT_MODULE_NAME);
    final DefaultConfiguration treeWalker = new DefaultConfiguration(TreeWalker.class.getName());
    root.addProperty("charset", StandardCharsets.UTF_8.name());
    childrenModules.stream().map(ModuleInputConfiguration::createConfiguration).filter(moduleConfig -> !moduleConfig.getName().endsWith("Filter")).forEach(moduleConfig -> {
        if (CHECKER_CHILDREN.contains(moduleConfig.getName())) {
            root.addChild(moduleConfig);
        } else {
            treeWalker.addChild(moduleConfig);
        }
    });
    root.addChild(treeWalker);
    return root;
}
Also used : HashSet(java.util.HashSet) Arrays(java.util.Arrays) List(java.util.List) Set(java.util.Set) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) TreeWalker(com.puppycrawl.tools.checkstyle.TreeWalker) Collections(java.util.Collections) StandardCharsets(java.nio.charset.StandardCharsets) ArrayList(java.util.ArrayList) TreeWalker(com.puppycrawl.tools.checkstyle.TreeWalker) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration)

Example 3 with TreeWalker

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

the class TestInputConfiguration method createConfiguration.

public DefaultConfiguration createConfiguration() {
    final DefaultConfiguration root = new DefaultConfiguration(ROOT_MODULE_NAME);
    final DefaultConfiguration treeWalker = new DefaultConfiguration(TreeWalker.class.getName());
    root.addProperty("charset", StandardCharsets.UTF_8.name());
    childrenModules.stream().map(ModuleInputConfiguration::createConfiguration).forEach(moduleConfig -> {
        if (CHECKER_CHILDREN.contains(moduleConfig.getName())) {
            root.addChild(moduleConfig);
        } else {
            treeWalker.addChild(moduleConfig);
        }
    });
    root.addChild(treeWalker);
    return root;
}
Also used : TreeWalker(com.puppycrawl.tools.checkstyle.TreeWalker) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration)

Aggregations

DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)3 TreeWalker (com.puppycrawl.tools.checkstyle.TreeWalker)3 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 Checker (com.puppycrawl.tools.checkstyle.Checker)1 DefaultLogger (com.puppycrawl.tools.checkstyle.DefaultLogger)1 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)1 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)1 File (java.io.File)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1