Search in sources :

Example 1 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class PlainResultFormatterTest method testNoEvidence.

/**
     * When there's no evidence, we shouldn't print a blank line or a caret.
     */
@Test
public void testNoEvidence() throws Exception {
    File file = new File("foo/bar.js");
    Issue issue = new IssueBuilder(file.toString(), 1, 1, "fatality").build();
    issues.add(issue);
    runFormatter(file);
    // Build up the expected output in a cross-platform manner.
    String nl = System.getProperty("line.separator");
    StringBuilder sb = new StringBuilder(file.toString());
    sb.append(":1:1: fatality");
    sb.append(nl);
    // NB: We use platform encoding here, as that's what we expect the
    // formatter to produce.
    assertThat(out.toString(), is(sb.toString()));
}
Also used : Issue(com.googlecode.jslint4java.Issue) File(java.io.File) IssueBuilder(com.googlecode.jslint4java.Issue.IssueBuilder) Test(org.junit.Test)

Example 2 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class XmlResultFormatterTest method testXmlOutputBad.

@Test
public void testXmlOutputBad() throws Exception {
    String name = "main.js";
    Issue issue = new Issue.IssueBuilder(name, 1, 1, "smelly socks").build();
    JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
    runTest(result);
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Example 3 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class CheckstyleXmlFormatter method format.

public String format(JSLintResult result) {
    StringBuilder sb = new StringBuilder("<file");
    sb.append(attr("name", result.getName()));
    sb.append(">\n");
    for (Issue issue : result.getIssues()) {
        sb.append("<error");
        sb.append(attr("line", Integer.toString(issue.getLine())));
        sb.append(attr("column", Integer.toString(issue.getCharacter())));
        // Based on com.puppycrawl.tools.checkstyle.api.SeverityLevel.
        sb.append(attr("severity", "warning"));
        sb.append(attr("message", issue.getReason()));
        sb.append(attr("source", JSLint.class.getName()));
        sb.append("/>\n");
    }
    sb.append("</file>");
    return sb.toString();
}
Also used : Issue(com.googlecode.jslint4java.Issue)

Example 4 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class JSLintXmlFormatter method format.

public String format(JSLintResult result) {
    StringBuilder sb = new StringBuilder("<file");
    sb.append(attr("name", result.getName()));
    sb.append(">" + NEWLINE);
    List<Issue> issues = result.getIssues();
    for (Issue issue : issues) {
        sb.append("<issue");
        sb.append(attr("line", Integer.toString(issue.getLine())));
        sb.append(attr("char", Integer.toString(issue.getCharacter())));
        sb.append(attr("reason", issue.getReason()));
        sb.append(attr("evidence", issue.getEvidence()));
        sb.append("/>" + NEWLINE);
    }
    sb.append("</file>");
    return sb.toString();
}
Also used : Issue(com.googlecode.jslint4java.Issue)

Example 5 with Issue

use of com.googlecode.jslint4java.Issue in project jslint4java by happygiraffe.

the class CheckstyleXmlFormatterTest method shouldHaveOneProblem.

@Test
public void shouldHaveOneProblem() throws Exception {
    String name = "bad.js";
    Issue issue = new Issue.IssueBuilder(name, 1, 1, "this is not a daffodil").build();
    JSLintResult result = new JSLintResult.ResultBuilder(name).addIssue(issue).build();
    String expected = "<file name=\"bad.js\">" + "<error line='1' column='1' severity='warning' message='this is not a daffodil'" + " source='com.googlecode.jslint4java.JSLint' />" + "</file>";
    XMLAssert.assertXMLEqual(expected, form.format(result));
}
Also used : Issue(com.googlecode.jslint4java.Issue) JSLintResult(com.googlecode.jslint4java.JSLintResult) Test(org.junit.Test)

Aggregations

Issue (com.googlecode.jslint4java.Issue)16 Test (org.junit.Test)11 JSLintResult (com.googlecode.jslint4java.JSLintResult)9 IssueBuilder (com.googlecode.jslint4java.Issue.IssueBuilder)5 File (java.io.File)2 ResultBuilder (com.googlecode.jslint4java.JSLintResult.ResultBuilder)1