All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.pmd.renderers.VBHTMLRenderer Maven / Gradle / Ivy

Go to download

PMD is an extensible multilanguage static code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It's mainly concerned with Java and Apex, but supports 16 other languages. It comes with 400+ built-in rules. It can be extended with custom rules. It uses JavaCC and Antlr to parse source files into abstract syntax trees (AST) and runs rules against them to find violations. Rules can be written in Java or using a XPath query. Currently, PMD supports Java, JavaScript, Salesforce.com Apex and Visualforce, Kotlin, Swift, Modelica, PLSQL, Apache Velocity, JSP, WSDL, Maven POM, HTML, XML and XSL. Scala is supported, but there are currently no Scala rules available. Additionally, it includes CPD, the copy-paste-detector. CPD finds duplicated code in Coco, C/C++, C#, Dart, Fortran, Gherkin, Go, Groovy, HTML, Java, JavaScript, JSP, Julia, Kotlin, Lua, Matlab, Modelica, Objective-C, Perl, PHP, PLSQL, Python, Ruby, Salesforce.com Apex and Visualforce, Scala, Swift, T-SQL, Typescript, Apache Velocity, WSDL, XML and XSL.

The newest version!
/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.renderers;

import java.io.IOException;
import java.util.Iterator;

import net.sourceforge.pmd.reporting.Report;
import net.sourceforge.pmd.reporting.RuleViolation;

/**
 * Renderer to another HTML format.
 *
 * @author Vladimir
 */
public class VBHTMLRenderer extends AbstractIncrementingRenderer {

    public static final String NAME = "vbhtml";

    public VBHTMLRenderer() {
        super(NAME, "Vladimir Bossicard HTML format.");
    }

    @Override
    public String defaultFileExtension() {
        return "vb.html";
    }

    @Override
    public void start() throws IOException {
        getWriter().write(header());
    }

    @Override
    public void renderFileViolations(Iterator violations) throws IOException {
        if (!violations.hasNext()) {
            return;
        }

        StringBuilder sb = new StringBuilder(500);
        String filename = null;
        String lineSep = System.lineSeparator();

        boolean colorize = false;
        while (violations.hasNext()) {
            sb.setLength(0);
            RuleViolation rv = violations.next();
            String nextFilename = determineFileName(rv.getFileId());
            if (!nextFilename.equals(filename)) { // New File
                if (filename != null) {
                    sb.append("
"); colorize = false; } filename = nextFilename; sb.append(""); sb.append(""); sb.append(lineSep); } if (colorize) { sb.append(""); } else { sb.append(""); } colorize = !colorize; sb.append(""); sb.append(""); sb.append(""); sb.append(lineSep); writer.write(sb.toString()); } if (filename != null) { writer.write("
 ").append(filename) .append("
").append(rv.getBeginLine()).append("   ").append(rv.getDescription()).append("
"); } } @Override public void end() throws IOException { StringBuilder sb = new StringBuilder(); writer.write("
"); // output the problems if (!errors.isEmpty()) { sb.setLength(0); sb.append(""); sb.append(""); boolean colorize = false; for (Report.ProcessingError error : errors) { if (colorize) { sb.append(""); } else { sb.append(""); } colorize = !colorize; sb.append(""); sb.append(""); } sb.append("
 Problems found
").append(determineFileName(error.getFileId())).append("
").append(error.getDetail()).append("
"); writer.write(sb.toString()); } if (!configErrors.isEmpty()) { sb.setLength(0); sb.append(""); sb.append(""); boolean colorize = false; for (Report.ConfigurationError error : configErrors) { if (colorize) { sb.append(""); } else { sb.append(""); } colorize = !colorize; sb.append(""); sb.append(""); } sb.append("
 Configuration problems found
").append(error.rule().getName()).append("").append(error.issue()).append("
"); writer.write(sb.toString()); } writer.write(footer()); } private String header() { return "PMD" + "" + "
"; } private String footer() { return "
" + System.lineSeparator(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy