CPD Results

The following document contains the results of PMD's CPD 3.7.

Duplications

FileLine
net\objectlab\qalab\m2\BuildStatMergeMojo.java249
net\objectlab\qalab\m2\QALabStatAllMergeMojo.java348
            getLog().warn("\n\nQALab ==> The file " + file.getPath() + " cannot be accessed. SKIPPING....\n\n");
        }
        return false;
    }

    /**
     * Create the Properties object based on the arguments specified to the Mojo
     * in your <code>pom.xml</code> file.
     * 
     * @return the properties for property expansion expansion
     * @throws MojoExecutionException
     *             if anything goes wrong.
     */
    private Properties createOverridingProperties() throws MojoExecutionException {

        final Properties result = new Properties();

        // Load the properties file if specified
        if (propertiesFile != null && propertiesFile.canRead() && propertiesFile.isFile()) {
            FileInputStream inStream = null;
            if (!quiet) {
                getLog().debug("loading " + propertiesFile);
            }

            try {
                inStream = new FileInputStream(propertiesFile);
                result.load(inStream);
            } catch (FileNotFoundException fnfex) {
                throw new MojoExecutionException("Could not find Properties file '" + propertiesFile + "'", fnfex);
            } catch (IOException ioex) {
                throw new MojoExecutionException("Error loading Properties file '" + propertiesFile + "'", ioex);
            } finally {
                try {
                    if (inStream != null) {
                        inStream.close();
                    }
                } catch (IOException ioex) {
                    throw new MojoExecutionException("Error closing Properties file '" + propertiesFile + "'", ioex);
                }
            }
        }

        // override with Maven properties as apropriate.
        final Map projectContext = getPluginContext();

FileLine
net\objectlab\qalab\m2\BuildStatMergeMojo.java171
net\objectlab\qalab\m2\QALabStatAllMergeMojo.java273
            getLog().info("checkstyleInputFile='" + inputFile.getPath());
            getLog().info("outputFile='" + outputFile.getPath());
            getLog().info("srcDir='" + srcDir + "', mergerTimeStamp=" + mergerTimeStamp);
            String proppath = null;
            if (propertiesFile != null) {
                proppath = propertiesFile.getPath();
            }
            getLog().info("quiet='" + quiet + "', propertiesFile='" + proppath + "'.");
            for (final Iterator it = theProperties.entrySet().iterator(); it.hasNext();) {

                final Map.Entry entry = (Map.Entry) it.next();
                final String key = entry.getKey().toString();
                if (key.indexOf("qalab") >= 0) {
                    getLog().info(key + " = '" + entry.getValue() + "'");
                }
            }
        }

        mergeFiles(inputFile, handler);

FileLine
net\objectlab\qalab\m2\report\MainReport.java155
net\objectlab\qalab\m2\report\MergeAndChartReport.java400
        getLog().info("Output Directory: " + getOutputDirectory());

        final File outdir = new File(getOutputDirectory());
        if (!outdir.exists()) {
            outdir.mkdirs();
        }
        assert outdir.isDirectory() : "the output directory was not a directory";

        final File output;
        try {
            output = File.createTempFile("qalab", null, outdir);
            assert output != null : "the temp file is null.";

        } catch (IOException ioex) {
            throw new MavenReportException("could not create temp file.", ioex);
        }

        final XmlTransformer t = new XmlTransformer(theXmlStream, theStyleSheetStream, output);
        t.addParameter("targetdir", getOutputDirectory());
        t.addParameter("type", types);
        t.addParameter("offset", theOffset);
        try {
            t.transform();
        } catch (TransformerException tex) {
            throw new MavenReportException("transformation failed.", tex);
        }

        // clean up the temp file when the plugin is done.
        output.deleteOnExit();
    }

FileLine
net\objectlab\qalab\m2\BuildStatMergeMojo.java329
net\objectlab\qalab\m2\QALabStatAllMergeMojo.java421
        this.checkstyleInputFile = inputFile;
    }

    public String getMergerTimeStamp() {
        return mergerTimeStamp;
    }

    public void setMergerTimeStamp(String mergerTimeStamp) {
        this.mergerTimeStamp = mergerTimeStamp;
    }

    public File getOutputFile() {
        return outputFile;
    }

    public void setOutputFile(File outputFile) {
        this.outputFile = outputFile;
    }

    public File getPropertiesFile() {
        return propertiesFile;
    }

    public void setPropertiesFile(File propertiesFile) {
        this.propertiesFile = propertiesFile;
    }

    public boolean isQuiet() {
        return quiet;
    }

    public void setQuiet(boolean quiet) {
        this.quiet = quiet;
    }

    public String getSrcDir() {
        return srcDir;
    }

    public void setSrcDir(String srcDir) {
        this.srcDir = srcDir;
    }

    public Properties getTheProperties() {
        return theProperties;
    }

    public void setTheProperties(Properties theProperties) {
        this.theProperties = theProperties;
    }

FileLine
net\objectlab\qalab\m2\BuildStatMergeMojo.java221
net\objectlab\qalab\m2\QALabStatAllMergeMojo.java323
            merger.mergeStats(new InputSource(new FileInputStream(inputFile)), exporter);
            getLog().info("Files: " + merger.getFileCount() + " Violations:" + merger.getTotalStatistics());

            exporter.save();
        } catch (IllegalAccessException e) {
            throw new MojoExecutionException(e.toString());
        } catch (FileNotFoundException e) {
            throw new MojoExecutionException(e.toString());
        } catch (IOException e) {
            throw new MojoExecutionException(e.toString());
        } catch (ClassNotFoundException e) {
            throw new MojoExecutionException(e.toString());
        } catch (InstantiationException e) {
            throw new MojoExecutionException(e.toString());
        }
    }

    /**
     * Validates the parameters supplied by maven 2.
     */
    private boolean validate(final File file) {

FileLine
net\objectlab\qalab\m2\report\MainReport.java182
net\objectlab\qalab\m2\report\MergeAndChartReport.java484
        mojo.execute();
    }

    /**
     * @return "qalab/index"
     * @see org.apache.maven.reporting.MavenReport#getOutputName()
     */
    public final String getOutputName() {
        return "qalab/index";
    }

    /**
     * @return The output directory as configured in your <code>pom.xml</code>.
     * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
     */
    protected final String getOutputDirectory() {
        return outputDirectory;
    }

    /**
     * @return The Maven Project itself. Used internally to get access to Config
     *         params etc.
     * @see org.apache.maven.reporting.AbstractMavenReport#getProject()
     */
    protected final MavenProject getProject() {
        return project;
    }

    /**
     * @return a direct reference to the site renderer.
     * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
     */
    protected final SiteRenderer getSiteRenderer() {
        return siteRenderer;
    }

    /**
     * @param aLocale
     *            The locale.
     * @return The locale specific report name.
     * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
     */
    public final String getName(final Locale aLocale) {
        return getBundle(aLocale).getString("report.qalab.name");
    }

    /**
     * @param aLocale
     *            The locale.
     * @return The locale specific report description.
     * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale)
     */
    public final String getDescription(final Locale aLocale) {
        return getBundle(aLocale).getString("report.qalab.description");
    }

    /**
     * @return true.
     * @see org.apache.maven.reporting.MavenReport#isExternalReport
     */
    public final boolean isExternalReport() {
        return true;
    }

    /**
     * @param aLocale
     *            The locale.
     * @return the resource bundle for this report.
     */
    private static ResourceBundle getBundle(final Locale aLocale) {
        return ResourceBundle.getBundle("qalab-report", aLocale, MergeAndChartReport.class.getClassLoader());

FileLine
net\objectlab\qalab\m2\BuildStatMergeMojo.java295
net\objectlab\qalab\m2\QALabStatAllMergeMojo.java394
            for (final Iterator it = projectContext.entrySet().iterator(); it.hasNext();) {

                final Map.Entry entry = (Map.Entry) it.next();
                final String value = String.valueOf(entry.getValue());
                if (entry.getKey().toString().indexOf("qalab") >= 0) {
                    getLog().info("Adding " + entry.getKey() + " / " + value);
                }
                result.put(entry.getKey(), value);
            }