Search in sources :

Example 1 with LintResults

use of com.uber.jenkins.phabricator.lint.LintResults in project phabricator-jenkins-plugin by uber.

the class BuildResultProcessor method processLintResults.

/**
 * Fetch remote lint violations from the build workspace and process
 *
 * @param lintFile     the path pattern of the file
 * @param lintFileSize maximum number of bytes to read from the remote file
 */
public void processLintResults(String lintFile, String lintFileSize) {
    RemoteFileFetcher lintFetcher = new RemoteFileFetcher(workspace, logger, lintFile, lintFileSize);
    try {
        String input = lintFetcher.getRemoteFile();
        if (input != null && input.length() > 0) {
            lintResults = new LintResults();
            BufferedReader reader = new BufferedReader(new StringReader(input));
            String lint = "";
            String line;
            while ((line = reader.readLine()) != null) {
                lint += line;
                try {
                    JSONObject json = JSONObject.fromObject(lint);
                    lintResults.add(LintResult.fromJsonObject(json));
                    lint = "";
                } catch (JSONException e) {
                    e.printStackTrace(logger.getStream());
                }
            }
        }
    } catch (InterruptedException e) {
        e.printStackTrace(logger.getStream());
    } catch (IOException e) {
        e.printStackTrace(logger.getStream());
    }
}
Also used : JSONObject(net.sf.json.JSONObject) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) JSONException(net.sf.json.JSONException) LintResults(com.uber.jenkins.phabricator.lint.LintResults) IOException(java.io.IOException)

Example 2 with LintResults

use of com.uber.jenkins.phabricator.lint.LintResults in project phabricator-jenkins-plugin by uber.

the class PhabricatorNotifierTest method testPostToHarbormasterValidLint.

@Test
public void testPostToHarbormasterValidLint() throws Exception {
    JSONObject json = new JSONObject();
    LintResults result = new LintResults();
    result.add(new LintResult("test", "testcode", "error", "to/path", 10, 3, "test description"));
    json.element("lint", result);
    FreeStyleBuild build = buildWithConduit(getFetchDiffResponse(), null, json);
    assertEquals(Result.SUCCESS, build.getResult());
}
Also used : JSONObject(net.sf.json.JSONObject) LintResult(com.uber.jenkins.phabricator.lint.LintResult) LintResults(com.uber.jenkins.phabricator.lint.LintResults) FreeStyleBuild(hudson.model.FreeStyleBuild) Test(org.junit.Test)

Aggregations

LintResults (com.uber.jenkins.phabricator.lint.LintResults)2 JSONObject (net.sf.json.JSONObject)2 LintResult (com.uber.jenkins.phabricator.lint.LintResult)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 JSONException (net.sf.json.JSONException)1 Test (org.junit.Test)1