Search in sources :

Example 11 with FullFileModel

use of hudson.plugins.violations.model.FullFileModel in project violations-plugin by jenkinsci.

the class CssLintParser method parseFileElement.

private void parseFileElement() throws IOException, XmlPullParserException {
    String absoluteFileName = fixAbsolutePath(checkNotBlank("name"));
    // consume "file" tag
    getParser().next();
    FullFileModel fileModel = getFileModel(absoluteFileName);
    // loop thru the child elements, getting the "issue" ones
    while (skipToTag("issue")) {
        fileModel.addViolation(parseIssueElement());
    }
    endElement();
}
Also used : FullFileModel(hudson.plugins.violations.model.FullFileModel)

Example 12 with FullFileModel

use of hudson.plugins.violations.model.FullFileModel in project violations-plugin by jenkinsci.

the class AbstractTypeParser method getFileModel.

// -----------------------------------------------
// 
// Utility methods
// 
// -----------------------------------------------
/**
 * Get the full file model for a particular relative name and
 * source file.
 * @param name the relative file name.
 * @param sourceFile the source file for the file.
 * @return the full file model.
 */
protected FullFileModel getFileModel(String name, File sourceFile) {
    FullFileModel fileModel = model.getFileModel(name);
    File other = fileModel.getSourceFile();
    if (sourceFile == null || ((other != null) && (other.equals(sourceFile) || other.exists()))) {
        return fileModel;
    }
    fileModel.setSourceFile(sourceFile);
    fileModel.setLastModified(sourceFile.lastModified());
    return fileModel;
}
Also used : FullFileModel(hudson.plugins.violations.model.FullFileModel) File(java.io.File)

Example 13 with FullFileModel

use of hudson.plugins.violations.model.FullFileModel in project violations-plugin by jenkinsci.

the class ViolationsDOMParser method getFileModel.

// -----------------------------------------------
// 
// Utility methods
// 
// -----------------------------------------------
/**
 * Get the full file model for a particular relative name and
 * source file.
 * @param name the relative file name.
 * @param sourceFile the source file for the file.
 * @return the full file model.
 */
protected FullFileModel getFileModel(String name, File sourceFile) {
    FullFileModel fileModel = model.getFileModel(name);
    File other = fileModel.getSourceFile();
    if (sourceFile == null || ((other != null) && (other.equals(sourceFile) || other.exists()))) {
        return fileModel;
    }
    fileModel.setSourceFile(sourceFile);
    fileModel.setLastModified(sourceFile.lastModified());
    return fileModel;
}
Also used : FullFileModel(hudson.plugins.violations.model.FullFileModel) File(java.io.File)

Example 14 with FullFileModel

use of hudson.plugins.violations.model.FullFileModel in project violations-plugin by jenkinsci.

the class CppLintParser method parseLine.

/**
 * Parses a CppLint line and adding a violation if regex
 * @param model build model to add violations to
 * @param line the line in the file.
 * @param projectPath the path to use to resolve the file.
 */
public void parseLine(FullBuildModel model, String line, File projectPath) {
    CppLintViolation cppLintViolation = getCppLintViolation(line);
    if (cppLintViolation != null) {
        Violation violation = new Violation();
        violation.setType("cpplint");
        violation.setLine(cppLintViolation.getLineStr());
        violation.setMessage(cppLintViolation.getMessage());
        violation.setSource(cppLintViolation.getViolationId());
        setServerityLevel(violation, cppLintViolation.getConfidence());
        FullFileModel fileModel = getFileModel(model, cppLintViolation.getFileName(), absoluteFileFinder.getFileForName(cppLintViolation.getFileName()));
        fileModel.addViolation(violation);
    }
}
Also used : Violation(hudson.plugins.violations.model.Violation) FullFileModel(hudson.plugins.violations.model.FullFileModel)

Example 15 with FullFileModel

use of hudson.plugins.violations.model.FullFileModel in project violations-plugin by jenkinsci.

the class PyflakesParser method parseLine.

/**
 * Parses a Pyflakes line and adding a violation if regex
 *
 * @param model
 *            build model to add violations to
 * @param line
 *            the line in the file.
 * @param projectPath
 *            the path to use to resolve the file.
 */
public void parseLine(FullBuildModel model, String line, File projectPath) {
    PyflakesViolation pyFlakesViolation = getPyflakesViolation(line);
    if (pyFlakesViolation != null) {
        Violation violation = new Violation();
        violation.setType("pyflakes");
        violation.setLine(pyFlakesViolation.getLineStr());
        violation.setMessage(pyFlakesViolation.getMessage());
        violation.setSource(pyFlakesViolation.getViolationId());
        setServerityLevel(violation, pyFlakesViolation.getViolationId());
        FullFileModel fileModel = getFileModel(model, pyFlakesViolation.getFileName(), absoluteFileFinder.getFileForName(pyFlakesViolation.getFileName()));
        fileModel.addViolation(violation);
    }
}
Also used : Violation(hudson.plugins.violations.model.Violation) FullFileModel(hudson.plugins.violations.model.FullFileModel)

Aggregations

FullFileModel (hudson.plugins.violations.model.FullFileModel)32 File (java.io.File)15 Violation (hudson.plugins.violations.model.Violation)12 ViolationsParserTest (hudson.plugins.violations.ViolationsParserTest)3 FullBuildModel (hudson.plugins.violations.model.FullBuildModel)3 Test (org.junit.Test)3 Element (org.w3c.dom.Element)3 AbsoluteFileFinder (hudson.plugins.violations.util.AbsoluteFileFinder)2 FilePath (hudson.FilePath)1 IOException2 (hudson.util.IOException2)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1