wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/support/csslint/CssLint.java
public void validate(final String data)
      throws CssLintException {
    final StopWatch watch = new StopWatch();
    watch.start("init");
    final RhinoScriptBuilder builder = initScriptBuilder();
    watch.stop();
    watch.start("cssLint");
    LOG.debug("options: {}", this.options);
    final String script = buildCssLintScript(WroUtil.toJSMultiLineString(data));
    LOG.debug("script: {}", script);
    builder.evaluate(script, "CSSLint.verify").toString();
    final boolean valid = Boolean.parseBoolean(builder.evaluate("result.length == 0", "checkNoErrors").toString());
    if (!valid) {
      final String json = builder.addJSON().evaluate("JSON.stringify(result)", "CssLint messages").toString();
      LOG.debug("json {}", json);
      final Type type = new TypeToken<List<CssLintError>>() {}.getType();
      final List<CssLintError> errors = new Gson().fromJson(json, type);
      LOG.debug("Errors: {}", errors);
      throw new CssLintException().setErrors(errors);
    }
    LOG.debug("isValid: {}", valid);
    watch.stop();
    LOG.debug(watch.prettyPrint());
  }
public void validate(final String data)
      throws CssLintException {
    final StopWatch watch = new StopWatch();
    watch.start("init");
    final RhinoScriptBuilder builder = initScriptBuilder();
    watch.stop();
    watch.start("cssLint");
    LOG.debug("options: {}", this.options);
    final String script = buildCssLintScript(WroUtil.toJSMultiLineString(data));
    LOG.debug("script: {}", script);
    builder.evaluate(script, "CSSLint.verify").toString();
    final boolean valid = Boolean.parseBoolean(builder.evaluate("result.length == 0", "checkNoErrors").toString());
    if (!valid) {
      final String json = builder.addJSON().evaluate("JSON.stringify(result)", "CssLint messages").toString();
      LOG.debug("json {}", json);
      final Type type = new TypeToken<List<CssLintError>>() {}.getType();
      final List<CssLintError> errors = new Gson().fromJson(json, type);
      LOG.debug("Errors: {}", errors);
      throw new CssLintException().setErrors(errors);
    }
    LOG.debug("isValid: {}", valid);
    watch.stop();
    LOG.debug(watch.prettyPrint());
  }
public void validate ( final String data ) throws CssLintException { final StopWatch watch = new StopWatch ( ) ; watch . start ( "init" ) ; final RhinoScriptBuilder builder = initScriptBuilder ( ) ; watch . stop ( ) ; watch . start ( "cssLint" ) ; LOG . debug ( "options: {}" , this . options ) ; final String script = buildCssLintScript ( WroUtil . toJSMultiLineString ( data ) ) ; LOG . debug ( "script: {}" , script ) ; builder . evaluate ( script , "CSSLint.verify" ) . toString ( ) ; final boolean valid = Boolean . parseBoolean ( builder . evaluate ( "result.length == 0" , "checkNoErrors" ) . toString ( ) ) ; if ( ! valid ) { final String json = builder . addJSON ( ) . evaluate ( "JSON.stringify(result)" , "CssLint messages" ) . toString ( ) ; LOG . debug ( "json {}" , json ) ; final Type type = new TypeToken < List < CssLintError > > ( ) { } . getType ( ) ; final List < CssLintError > errors = new Gson ( ) . fromJson ( json , type ) ; LOG . debug ( "Errors: {}" , errors ) ; throw new CssLintException ( ) . setErrors ( errors ) ; } LOG . debug ( "isValid: {}" , valid ) ; watch . stop ( ) ; LOG . debug ( watch . prettyPrint ( ) ) ; }
Validates a css resource using cssLint and throws {@link CssLintException} if the resource is invalid. If no exception is thrown,
the resource is valid.

@param data
css content to process.
@throws CssLintException
when parsed css has some kind of problems.
Validates a css resource using cssLint and throws { @link CssLintException } if the resource is invalid . If no exception is thrown the resource is valid .