Search in sources :

Example 1 with DependencyInformationConsumerInjector

use of com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector 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 DependencyInformationConsumerInjector

use of com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector in project methods-distance by sevntu-checkstyle.

the class MethodCallDependenciesModuleTestSupport method createChecker.

protected final Checker createChecker(Configuration checkConfig) throws Exception {
    final DefaultConfiguration dc = createCheckerConfig(checkConfig);
    final Checker checker = new Checker();
    // make sure the tests always run with default error messages (language-invariant)
    // so the tests don't fail in supported locales like German
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    // following line is the only difference to super-class implementation of this method.
    checker.setModuleFactory(new DependencyInformationConsumerInjector(collector));
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(dc);
    checker.addListener(new BaseCheckTestSupport.BriefLogger(stream));
    return checker;
}
Also used : Locale(java.util.Locale) BaseCheckTestSupport(com.github.sevntu.checkstyle.domain.BaseCheckTestSupport) Checker(com.puppycrawl.tools.checkstyle.Checker) DependencyInformationConsumerInjector(com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration)

Aggregations

DependencyInformationConsumerInjector (com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector)2 Checker (com.puppycrawl.tools.checkstyle.Checker)2 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)2 BaseCheckTestSupport (com.github.sevntu.checkstyle.domain.BaseCheckTestSupport)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 DefaultLogger (com.puppycrawl.tools.checkstyle.DefaultLogger)1 ModuleFactory (com.puppycrawl.tools.checkstyle.ModuleFactory)1 TreeWalker (com.puppycrawl.tools.checkstyle.TreeWalker)1 AuditListener (com.puppycrawl.tools.checkstyle.api.AuditListener)1 File (java.io.File)1 Locale (java.util.Locale)1