Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCB9910728 for ; Mon, 1 Jul 2013 11:01:53 +0000 (UTC) Received: (qmail 25695 invoked by uid 500); 1 Jul 2013 11:01:53 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 25505 invoked by uid 500); 1 Jul 2013 11:01:52 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 25488 invoked by uid 99); 1 Jul 2013 11:01:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jul 2013 11:01:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jul 2013 11:01:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E74CD238888A; Mon, 1 Jul 2013 11:01:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1498366 - in /maven/plugins/trunk/maven-pmd-plugin/src: it/mpmd-168-empty-report/ it/mpmd-168-empty-report/src/ it/mpmd-168-empty-report/src/main/ it/mpmd-168-empty-report/src/main/java/ it/mpmd-168-empty-report/src/main/java/def/ it/mpmd-... Date: Mon, 01 Jul 2013 11:01:21 -0000 To: commits@maven.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130701110121.E74CD238888A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olamy Date: Mon Jul 1 11:01:20 2013 New Revision: 1498366 URL: http://svn.apache.org/r1498366 Log: [MPMD-168] missed to add files Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy (with props) maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/ maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java (with props) maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml (with props) maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java (with props) maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml (with props) Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties Mon Jul 1 11:01:20 2013 @@ -0,0 +1 @@ +invoker.goals = clean verify site Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,74 @@ + + + + + + 4.0.0 + + org.apache.maven.plugin.pmd.its + mpmd-168-empty-report + 1.0-SNAPSHOT + + MPMD-168 do not skip empty report + + Verify the "skipEmptyReport" parameter. + + + + + + maven-pmd-plugin + @project.version@ + + + + check + cpd-check + + + + + true + 25 + UTF-8 + false + + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + @project.version@ + + false + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java Mon Jul 1 11:01:20 2013 @@ -0,0 +1,28 @@ +package def; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/src/main/java/def/Hello.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy Mon Jul 1 11:01:20 2013 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File targetDir = new File( basedir, "target" ); +File siteDir = new File( targetDir, "site" ); + +File projectReports = new File( siteDir, "project-reports.html" ) +assert projectReports.getText( "UTF-8" ).contains( "pmd.html" ) +assert projectReports.getText( "UTF-8" ).contains( "cpd.html" ) + +File pmdReportInSite = new File( siteDir, "pmd.html" ) +assert pmdReportInSite.exists() + +File pmdXmlInTarget = new File( targetDir, "pmd.xml" ) +assert pmdXmlInTarget.exists() + +File cpdReportInSite = new File( siteDir, "cpd.html" ) +assert cpdReportInSite.exists() + +File cpdXmlInTarget = new File( targetDir, "cpd.xml" ) +assert cpdXmlInTarget.exists() Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168-empty-report/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties Mon Jul 1 11:01:20 2013 @@ -0,0 +1 @@ +invoker.goals = clean verify site Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,74 @@ + + + + + + 4.0.0 + + org.apache.maven.plugin.pmd.its + mpmd-168-empty-report-skipped + 1.0-SNAPSHOT + + MPMD-168 skip empty report + + Verify the "skipEmptyReport" parameter. + + + + + + maven-pmd-plugin + @project.version@ + + + + check + cpd-check + + + + + true + 25 + UTF-8 + false + + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + @project.version@ + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java Mon Jul 1 11:01:20 2013 @@ -0,0 +1,28 @@ +package def; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/src/main/java/def/Hello.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy Mon Jul 1 11:01:20 2013 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +File targetDir = new File( basedir, "target" ); +File siteDir = new File( targetDir, "site" ); + +File projectReports = new File( siteDir, "project-reports.html" ) +assert !projectReports.getText( "UTF-8" ).contains( "pmd.html" ) +assert !projectReports.getText( "UTF-8" ).contains( "cpd.html" ) + +File pmdReportInSite = new File( siteDir, "pmd.html" ) +assert !pmdReportInSite.exists() + +File pmdXmlInTarget = new File( targetDir, "pmd.xml" ) +assert pmdXmlInTarget.exists() + +File cpdReportInSite = new File( siteDir, "cpd.html" ) +assert !cpdReportInSite.exists() + +File cpdXmlInTarget = new File( targetDir, "cpd.xml" ) +assert cpdXmlInTarget.exists() Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/mpmd-168/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,11 @@ + + + + The relative path of this ruleset matches the built-in ruleset "basic". + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/it/multi-module/mod-2/rulesets/java/basic.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java Mon Jul 1 11:01:20 2013 @@ -0,0 +1,365 @@ +package org.apache.maven.plugin.pmd; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; + +import net.sourceforge.pmd.RuleViolation; + +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.plugin.logging.Log; +import org.codehaus.plexus.util.StringUtils; + +/** + * Render the PMD violations into Doxia events. + * + * @author Brett Porter + * @version $Id$ + */ +public class PmdReportGenerator { + private Log log; + + private Sink sink; + + private String currentFilename; + + private ResourceBundle bundle; + + private HashSet violations = new HashSet(); + + private boolean aggregate; + + // The number of erroneous files + private int fileCount = 0; + + private Map files; + +// private List metrics = new ArrayList(); + + public PmdReportGenerator( Log log, Sink sink, ResourceBundle bundle, boolean aggregate ) + { + this.log = log; + this.sink = sink; + this.bundle = bundle; + this.aggregate = aggregate; + } + + private String getTitle() + { + return bundle.getString( "report.pmd.title" ); + } + + public void setViolations( Collection violations ) + { + this.violations = new HashSet( violations ); + } + + public List getViolations() + { + return new ArrayList( violations ); + } + +// public List getMetrics() +// { +// return metrics; +// } +// +// public void setMetrics( List metrics ) +// { +// this.metrics = metrics; +// } + + private void startFileSection( String currentFilename, PmdFileInfo fileInfo ) + { + sink.section2(); + sink.sectionTitle2(); + + // prepare the filename + this.currentFilename = currentFilename; + if ( fileInfo != null && fileInfo.getSourceDirectory() != null ) + { + this.currentFilename = + StringUtils.substring( currentFilename, fileInfo.getSourceDirectory().getAbsolutePath().length() + 1 ); + } + this.currentFilename = StringUtils.replace( this.currentFilename, "\\", "/" ); + + String title = this.currentFilename; + if ( aggregate && fileInfo != null && fileInfo.getProject() != null ) + { + title = fileInfo.getProject().getName() + " - " + this.currentFilename; + } + sink.text( title ); + sink.sectionTitle2_(); + + sink.table(); + sink.tableRow(); + sink.tableHeaderCell(); + sink.text( bundle.getString( "report.pmd.column.violation" ) ); + sink.tableHeaderCell_(); + sink.tableHeaderCell(); + sink.text( bundle.getString( "report.pmd.column.line" ) ); + sink.tableHeaderCell_(); + sink.tableRow_(); + } + + private void endFileSection() + { + sink.table_(); + sink.section2_(); + } + + private void processSingleRuleViolation( RuleViolation ruleViolation, PmdFileInfo fileInfo ) + { + sink.tableRow(); + sink.tableCell(); + sink.text( ruleViolation.getDescription() ); + sink.tableCell_(); + sink.tableCell(); + + int beginLine = ruleViolation.getBeginLine(); + outputLineLink( beginLine, fileInfo ); + int endLine = ruleViolation.getEndLine(); + if ( endLine != beginLine ) + { + sink.text( " - " ); + outputLineLink( endLine, fileInfo ); + } + + sink.tableCell_(); + sink.tableRow_(); + } + + // PMD might run the analysis multi-threaded, so the violations might be reported + // out of order. We sort them here by filename and line number before writing them to + // the report. + private void processViolations() + throws IOException + { + fileCount = files.size(); + ArrayList violations2 = new ArrayList( violations ); + Collections.sort( violations2, new Comparator() + { + /** {@inheritDoc} */ + public int compare( RuleViolation o1, RuleViolation o2 ) + { + int filenames = o1.getFilename().compareTo( o2.getFilename() ); + if ( filenames == 0 ) + { + return o1.getBeginLine() - o2.getBeginLine(); + } + else + { + return filenames; + } + } + } ); + + boolean fileSectionStarted = false; + String previousFilename = null; + for ( RuleViolation ruleViolation : violations2 ) + { + String currentFn = ruleViolation.getFilename(); + File canonicalFilename = new File( currentFn ).getCanonicalFile(); + PmdFileInfo fileInfo = files.get( canonicalFilename ); + if ( fileInfo == null ) + { + log.warn( "Couldn't determine PmdFileInfo for file " + currentFn + " (canonical: " + canonicalFilename + + "). XRef links won't be available." ); + } + + if ( !currentFn.equalsIgnoreCase( previousFilename ) && fileSectionStarted ) + { + endFileSection(); + fileSectionStarted = false; + } + if ( !fileSectionStarted ) + { + startFileSection( currentFn, fileInfo ); + fileSectionStarted = true; + } + + processSingleRuleViolation( ruleViolation, fileInfo ); + + previousFilename = currentFn; + } + + if ( fileSectionStarted ) + { + endFileSection(); + } + } + + private void outputLineLink( int line, PmdFileInfo fileInfo ) + { + String xrefLocation = null; + if ( fileInfo != null ) + { + xrefLocation = fileInfo.getXrefLocation(); + } + + if ( xrefLocation != null ) + { + sink.link( xrefLocation + "/" + currentFilename.replaceAll( "\\.java$", ".html" ) + "#" + line ); + } + sink.text( String.valueOf( line ) ); + if ( xrefLocation != null ) + { + sink.link_(); + } + } + + public void beginDocument() + { + sink.head(); + sink.title(); + sink.text( getTitle() ); + sink.title_(); + sink.head_(); + + sink.body(); + + sink.section1(); + sink.sectionTitle1(); + sink.text( getTitle() ); + sink.sectionTitle1_(); + + sink.paragraph(); + sink.text( bundle.getString( "report.pmd.pmdlink" ) + " " ); + sink.link( "http://pmd.sourceforge.net/" ); + sink.text( "PMD" ); + sink.link_(); + sink.text( " " + AbstractPmdReport.getPmdVersion() + "." ); + sink.paragraph_(); + + sink.section1_(); + + // TODO overall summary + + sink.section1(); + sink.sectionTitle1(); + sink.text( bundle.getString( "report.pmd.files" ) ); + sink.sectionTitle1_(); + + // TODO files summary + } + +/* + private void processMetrics() + { + if ( metrics.size() == 0 ) + { + return; + } + + sink.section1(); + sink.sectionTitle1(); + sink.text( "Metrics" ); + sink.sectionTitle1_(); + + sink.table(); + sink.tableRow(); + sink.tableHeaderCell(); + sink.text( "Name" ); + sink.tableHeaderCell_(); + sink.tableHeaderCell(); + sink.text( "Count" ); + sink.tableHeaderCell_(); + sink.tableHeaderCell(); + sink.text( "High" ); + sink.tableHeaderCell_(); + sink.tableHeaderCell(); + sink.text( "Low" ); + sink.tableHeaderCell_(); + sink.tableHeaderCell(); + sink.text( "Average" ); + sink.tableHeaderCell_(); + sink.tableRow_(); + + for ( Metric met : metrics ) + { + sink.tableRow(); + sink.tableCell(); + sink.text( met.getMetricName() ); + sink.tableCell_(); + sink.tableCell(); + sink.text( String.valueOf( met.getCount() ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( String.valueOf( met.getHighValue() ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( String.valueOf( met.getLowValue() ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( String.valueOf( met.getAverage() ) ); + sink.tableCell_(); + sink.tableRow_(); + } + sink.table_(); + sink.section1_(); + } +*/ + + public void render() + throws IOException + { + processViolations(); + } + + public void endDocument() + throws IOException + { + if ( fileCount == 0 ) + { + sink.paragraph(); + sink.text( bundle.getString( "report.pmd.noProblems" ) ); + sink.paragraph_(); + } + + sink.section1_(); + + // The Metrics report useless with the current PMD metrics impl. + // For instance, run the coupling ruleset and you will get a boatload + // of excessive imports metrics, none of which is really any use. + // TODO Determine if we are going to just ignore metrics. + +// processMetrics(); + + sink.body_(); + + sink.flush(); + + sink.close(); + } + + public void setFiles( Map files ) + { + this.files = files; + } +} Propchange: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportGenerator.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,63 @@ + + + + 4.0.0 + skip-report.configuration + skip-report-configuration + jar + 1.0-SNAPSHOT + 2013 + Maven PMD Plugin Skip Report Configuration Test + http://maven.apache.org + + skip-report-configuration + + + org.apache.maven.plugins + maven-pmd-plugin + + + ${basedir}/target/test/unit/empty-report/target/site + ${basedir}/target/test/unit/empty-report/target + + ${basedir}/src/test/resources/unit/empty-report/java/ + + UTF-8 + 100 + + + + pmd + pmd + 5.0.4 + + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,64 @@ + + + + 4.0.0 + skip-report.configuration + skip-report-configuration + jar + 1.0-SNAPSHOT + 2013 + Maven PMD Plugin Skip Report Configuration Test + http://maven.apache.org + + skip-report-configuration + + + org.apache.maven.plugins + maven-pmd-plugin + + + ${basedir}/target/test/unit/empty-report/target/site + ${basedir}/target/test/unit/empty-report/target + + ${basedir}/src/test/resources/unit/empty-report/java/ + + UTF-8 + 100 + true + + + + pmd + pmd + 5.0.4 + + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/cpd-skip-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,62 @@ + + + + 4.0.0 + skip-report.configuration + skip-report-configuration + jar + 1.0-SNAPSHOT + 2013 + Maven PMD Plugin Skip Report Configuration Test + http://maven.apache.org + + skip-report-configuration + + + org.apache.maven.plugins + maven-pmd-plugin + + + ${basedir}/target/test/unit/empty-report/target/site + ${basedir}/target/test/unit/empty-report/target + + ${basedir}/src/test/resources/unit/empty-report/java/ + + UTF-8 + + + + pmd + pmd + 5.0.4 + + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java Mon Jul 1 11:01:20 2013 @@ -0,0 +1,28 @@ +package def; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class Hello +{ + public static void main( String[] args ) + { + System.out.println( args[0] ); + } +} Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/java/def/Hello.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml?rev=1498366&view=auto ============================================================================== --- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml (added) +++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml Mon Jul 1 11:01:20 2013 @@ -0,0 +1,63 @@ + + + + 4.0.0 + skip-report.configuration + skip-report-configuration + jar + 1.0-SNAPSHOT + 2013 + Maven PMD Plugin Skip Report Configuration Test + http://maven.apache.org + + skip-report-configuration + + + org.apache.maven.plugins + maven-pmd-plugin + + + ${basedir}/target/test/unit/empty-report/target/site + ${basedir}/target/test/unit/empty-report/target + + ${basedir}/src/test/resources/unit/empty-report/java/ + + UTF-8 + true + + + + pmd + pmd + 5.0.4 + + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/empty-report/skip-empty-report-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision