diff --git a/wro4j-maven-plugin/src/main/java/ro/isdc/wro/maven/plugin/JsHintMojo.java b/wro4j-maven-plugin/src/main/java/ro/isdc/wro/maven/plugin/JsHintMojo.java index 4f62200df..f69ae333d 100644 --- a/wro4j-maven-plugin/src/main/java/ro/isdc/wro/maven/plugin/JsHintMojo.java +++ b/wro4j-maven-plugin/src/main/java/ro/isdc/wro/maven/plugin/JsHintMojo.java @@ -7,6 +7,8 @@ import java.io.IOException; import java.io.Reader; import java.io.Writer; +import java.util.Collection; +import java.util.Iterator; import org.apache.commons.io.output.NullWriter; @@ -47,6 +49,22 @@ public class JsHintMojo * @optional */ private String reportFormat = FormatterType.JSLINT.getFormat(); + /** + * Allows mixed tabs and whitespace without reporting them + * + * @parameter expression=${messy} + * @optional + */ + private boolean messy = false; + + /** + * {@inheritDoc} + */ + @Override + protected void onBeforeExecute() { + getLog().info("messy: " + messy); + super.onBeforeExecute(); + } /** * {@inheritDoc} @@ -69,19 +87,42 @@ protected void onException(final WroRuntimeException e) { @Override protected void onLinterException(final LinterException e, final Resource resource) { - final String errorMessage = String.format("%s errors found while processing resource: %s. Errors are: %s", e - .getErrors().size(), resource, e.getErrors()); - getProgressIndicator().addFoundErrors(e.getErrors().size()); - getLog().error(errorMessage); - // collect found errors - addReport(ResourceLintReport.create(resource.getUri(), e.getErrors())); - if (isFailAllowed()) { - throw new WroRuntimeException("Errors found when validating resource: " + resource); + Collection errors; + if (messy) { + errors = removeMixedWhitespaceErrors(e); + } else { + errors = e.getErrors(); + } + + if (errors.size()> 0) { + final String errorMessage = String.format("%s errors found while processing resource: %s. Errors are: %s", e + .getErrors().size(), resource, errors); + getProgressIndicator().addFoundErrors(errors.size()); + getLog().error(errorMessage); + // collect found errors + addReport(ResourceLintReport.create(resource.getUri(), errors)); + if (isFailAllowed()) { + throw new WroRuntimeException("Errors found when validating resource: " + resource); } + } }; }.setOptionsAsString(getOptions()); return processor; } + + private Collection removeMixedWhitespaceErrors(LinterException e) { + Collection errors = e.getErrors(); + Iterator i = errors.iterator(); + + while (i.hasNext()) { + LinterError err = i.next(); + if (err.getReason().equals("Mixed spaces and tabs.")) { + i.remove(); + } + } + + return errors; + } /** * {@inheritDoc}