Search in sources :

Example 16 with FullFileModel

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

the class PyLintParser method parseLine.

/**
 * Parses a PyLint 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) {
    PyLintViolation pyLintViolation = getPyLintViolation(line);
    if (pyLintViolation != null) {
        Violation violation = new Violation();
        violation.setType("pylint");
        violation.setLine(pyLintViolation.getLineStr());
        violation.setMessage(pyLintViolation.getMessage());
        violation.setSource(pyLintViolation.getViolationId());
        setServerityLevel(violation, pyLintViolation.getViolationId());
        FullFileModel fileModel = getFileModel(model, pyLintViolation.getFileName(), absoluteFileFinder.getFileForName(pyLintViolation.getFileName()));
        fileModel.addViolation(violation);
    }
}
Also used : Violation(hudson.plugins.violations.model.Violation) FullFileModel(hudson.plugins.violations.model.FullFileModel)

Example 17 with FullFileModel

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

the class ZptlintParser method parseLine.

/**
 * Parses a Zptlint 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) {
    ZptlintViolation zptlintViolation = getZptlintViolation(line);
    if (zptlintViolation != null) {
        Violation violation = new Violation();
        violation.setType("zptlint");
        violation.setLine(zptlintViolation.getLineStr());
        violation.setMessage(zptlintViolation.getMessage());
        violation.setSource(zptlintViolation.getViolationId());
        setServerityLevel(violation, zptlintViolation.getViolationId());
        FullFileModel fileModel = getFileModel(model, zptlintViolation.getFileName(), absoluteFileFinder.getFileForName(zptlintViolation.getFileName()));
        fileModel.addViolation(violation);
    }
}
Also used : Violation(hudson.plugins.violations.model.Violation) FullFileModel(hudson.plugins.violations.model.FullFileModel)

Example 18 with FullFileModel

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

the class Pep8Parser method getFileModel.

private FullFileModel getFileModel(FullBuildModel model, 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 19 with FullFileModel

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

the class XmllintParser method getFileModel.

private FullFileModel getFileModel(FullBuildModel model, 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 20 with FullFileModel

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

the class CppLintParser method getFileModel.

private FullFileModel getFileModel(FullBuildModel model, 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)

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