Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.selesse.jxlint.linter;
Simple implementation of a Linter. Goes through all the com.selesse.jxlint.model.rules.LintRules and calls com.selesse.jxlint.model.rules.LintRule.validate(). If there are any errors, this class accumulates them. Call getLintErrors() to retrieve them.
public class Linter {
    private static final Logger LOGGER = LoggerFactory.getLogger(Linter.class);
    private static final int NUMBER_OF_THREADS = Runtime.getRuntime().availableProcessors();
    private List<LintRulerules;
    private List<LintErrorlintErrors;
    public Linter(List<LintRulerules) {
        this. = rules;
        this. = Lists.newArrayList();

This validates (or invalidates) every lint rule. com.selesse.jxlint.model.rules.LintErrors may arise through failed validations. For every rule that fails a validation, there should be a corresponding com.selesse.jxlint.model.rules.LintError.
    public void performLintValidations() {
         = Lists.newArrayList();
        try {
            .debug("Initializing pool of {} threads");
            final ListeningExecutorService executorService =
            for (LintRule lintRule : ) {
                ValidationThread validationThread = new ValidationThread(lintRule);
                ListenableFuture<List<LintError>> lintErrorFuture = executorService.submit(validationThread);
            executorService.awaitTermination(24, .);
        catch (InterruptedException e) {
            .error("Thread interrupted while validating"e);
    private FutureCallback<List<LintError>> getFutureCallback(final LintRule lintRule) {
        return new FutureCallback<List<LintError>>() {
            public void onSuccess(@Nullable List<LintErrorresultErrors) {
                if (resultErrors != null) {
                    .info("[{}] found {} errors"lintRule.getName(), resultErrors.size());
                else {
                    .error("[{}] returned null error list"lintRule.getName());
            public void onFailure(Throwable t) {
                .error("Error running validation thread: {}"t.getMessage(), Throwables.getRootCause(t));

Returns all the com.selesse.jxlint.model.rules.LintErrors that have been found through validations performed in performLintValidations().
    public List<LintErrorgetLintErrors() {
        return ;
New to GrepCode? Check out our FAQ X