Search in sources :

Example 31 with FullFileModel

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

the class StyleCopParser method findSourceFiles.

/**
 * Go through all violations and see if the source files can be found.
 * @param model model containing all violations
 * @param workspace the workspace
 * @param sourcePaths the optional source paths
 */
private void findSourceFiles(FullBuildModel model, String workspace, String[] sourcePaths) {
    AbsoluteFileFinder finder = new AbsoluteFileFinder();
    finder.addSourcePath(workspace);
    if (sourcePaths != null) {
        finder.addSourcePaths(sourcePaths);
    }
    Map<String, FullFileModel> fileModelMap = model.getFileModelMap();
    for (Map.Entry<String, FullFileModel> entry : fileModelMap.entrySet()) {
        FullFileModel fileModel = entry.getValue();
        File sourceFile = finder.getFileForName(fileModel.getDisplayName());
        if (sourceFile != null) {
            fileModel.setSourceFile(sourceFile);
            fileModel.setLastModified(sourceFile.lastModified());
        }
    }
}
Also used : FullFileModel(hudson.plugins.violations.model.FullFileModel) AbsoluteFileFinder(hudson.plugins.violations.util.AbsoluteFileFinder) Map(java.util.Map) File(java.io.File)

Example 32 with FullFileModel

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

the class XmllintParser method parseLine.

/**
 * Parses a Xmllint 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) {
    XmllintViolation xmllintViolation = getXmllintViolation(line);
    if (xmllintViolation != null) {
        Violation violation = new Violation();
        violation.setType("xmllint");
        violation.setLine(xmllintViolation.getLineStr());
        violation.setMessage(xmllintViolation.getMessage());
        violation.setSource(xmllintViolation.getViolationId());
        setServerityLevel(violation, xmllintViolation.getViolationId());
        FullFileModel fileModel = getFileModel(model, xmllintViolation.getFileName(), absoluteFileFinder.getFileForName(xmllintViolation.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