Search in sources :

Example 16 with Violation

use of hudson.plugins.violations.model.Violation 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 17 with Violation

use of hudson.plugins.violations.model.Violation 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)

Example 18 with Violation

use of hudson.plugins.violations.model.Violation 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 19 with Violation

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

the class SimianParser method createViolation.

/**
 * Create a violation from the duplication block
 * @param block the block to create a violation from
 * @return a violation
 */
private Violation createViolation(DuplicationBlock block) {
    Violation violation = new Violation();
    violation.setType(TYPE_NAME);
    violation.setSource("duplication");
    int startLineNumber = block.startLineNumber;
    int endLineNumber = block.endLineNumber;
    int lineCount = endLineNumber - startLineNumber + 1;
    violation.setLine(startLineNumber);
    setViolationSeverity(violation, (lineCount < LOW_LIMIT) ? Severity.LOW : (lineCount < MEDIUM_LIMIT) ? Severity.MEDIUM : Severity.HIGH);
    return violation;
}
Also used : Violation(hudson.plugins.violations.model.Violation)

Example 20 with Violation

use of hudson.plugins.violations.model.Violation 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)

Aggregations

Violation (hudson.plugins.violations.model.Violation)41 FullFileModel (hudson.plugins.violations.model.FullFileModel)12 ViolationsParserTest (hudson.plugins.violations.ViolationsParserTest)8 FullBuildModel (hudson.plugins.violations.model.FullBuildModel)8 Test (org.junit.Test)8 File (java.io.File)6 Map (java.util.Map)3 Element (org.w3c.dom.Element)3 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 FilePath (hudson.FilePath)1 AbsoluteFileFinder (hudson.plugins.violations.util.AbsoluteFileFinder)1 IOException2 (hudson.util.IOException2)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Matcher (java.util.regex.Matcher)1