Coverage Report - net.objectlab.qalab.parser.PMDCPDStatMerge
 
Classes in this File Line Coverage Branch Coverage Complexity
PMDCPDStatMerge
100%
13/13
100%
3/3
2.5
 
 1  
 ////////////////////////////////////////////////////////////////////////////////
 2  
 //
 3  
 //                  ObjectLab is sponsoring QALab
 4  
 // 
 5  
 // Based in London, we are world leaders in the design and development 
 6  
 // of bespoke applications for the Securities Financing markets.
 7  
 // 
 8  
 // <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
 9  
 //           ___  _     _           _   _          _
 10  
 //          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
 11  
 //         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
 12  
 //         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
 13  
 //          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
 14  
 //                   |__/
 15  
 //
 16  
 //                   http://www.ObjectLab.co.uk
 17  
 // ---------------------------------------------------------------------------
 18  
 //
 19  
 //QALab is released under the GNU General Public License.
 20  
 //
 21  
 //QALab: Collects QA Statistics from your build over time.
 22  
 //2005+, ObjectLab Ltd
 23  
 //
 24  
 //This library is free software; you can redistribute it and/or
 25  
 //modify it under the terms of the GNU General Public
 26  
 //License as published by the Free Software Foundation; either
 27  
 //version 2.1 of the License, or (at your option) any later version.
 28  
 //
 29  
 //This library is distributed in the hope that it will be useful,
 30  
 //but WITHOUT ANY WARRANTY; without even the implied warranty of
 31  
 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 32  
 //General Public License for more details.
 33  
 //
 34  
 //You should have received a copy of the GNU General Public
 35  
 //License along with this library; if not, write to the Free Software
 36  
 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 37  
 //
 38  
 ////////////////////////////////////////////////////////////////////////////////
 39  
 package net.objectlab.qalab.parser;
 40  
 
 41  
 import net.objectlab.qalab.util.Util;
 42  
 
 43  
 import org.xml.sax.Attributes;
 44  
 import org.xml.sax.SAXException;
 45  
 
 46  
 /**
 47  
  * This class is able to read the XML output from PMD CPD (Copy Paste Detector)
 48  
  * and integrate the violation results into our "qalab" xml format.
 49  
  *
 50  
  * @author Benoit Xhenseval
 51  
  * @version $Revision: 153 $
 52  
  */
 53  18
 public class PMDCPDStatMerge extends BaseStatMerge {
 54  
     // ~ Static fields/initializers
 55  
     // ------------------------------------------------------------------------
 56  
 
 57  
     /**
 58  
      * summary tag.
 59  
      */
 60  
     private static final String BUGINSTANCE_TAG = "duplication";
 61  
 
 62  
     // ~ Methods
 63  
     // ------------------------------------------------------------------------
 64  
 
 65  
     /**
 66  
      * @return simian
 67  
      */
 68  
     public final String getType() {
 69  15
         return "pmd-cpd";
 70  
     }
 71  
 
 72  
     /**
 73  
      * At the start of a new element, capture the filename and if the element
 74  
      * is a result one, create a SingleStat to store for the given type.
 75  
      * @param ignoreNamespaceURI ignore (present for interface implementation).
 76  
      * @param localname name of the current element.
 77  
      * @param qualifiedname element name.
 78  
      * @param attrs the XML attribute of the current element.
 79  
      * @throws SAXException any SAX issue
 80  
      */
 81  
     public final void startElement(final String ignoreNamespaceURI, // NOPMD
 82  
         final String localname, final String qualifiedname,
 83  
         final Attributes attrs)
 84  
         throws SAXException {
 85  114
         String local = localname;
 86  
 
 87  114
         if ("".equals(local)) {
 88  114
             local = qualifiedname;
 89  
         }
 90  
 
 91  114
         if (BUGINSTANCE_TAG.equals(local)) {
 92  24
             final String dupLines = Util.getAttributeValue(attrs,
 93  
                     "lines", isQuiet(), getTaskLogger());
 94  
 //            final String dupFileCount = 2; 
 95  
 //            Util.getAttributeValue(attrs,
 96  
 //                    "duplicateFileCount", isQuiet(), getTaskLogger());
 97  
 
 98  24
             if (!isQuiet()) {
 99  24
                 getTaskLogger().log("dupLineCount=" + dupLines);
 100  
 //                    + " dupFileCount=" + dupFileCount);
 101  
             }
 102  
 
 103  24
             addTotalStatistics(Integer.parseInt(dupLines));
 104  24
             incrementFileCount(2);
 105  24
             addNewResults();
 106  
         }
 107  114
     }
 108  
 }
 109  
 /*
 110  
  *                   ObjectLab is sponsoring QALab
 111  
  * 
 112  
  * Based in London, we are world leaders in the design and development 
 113  
  * of bespoke applications for the securities financing markets.
 114  
  * 
 115  
  * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
 116  
  *           ___  _     _           _   _          _
 117  
  *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
 118  
  *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
 119  
  *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
 120  
  *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
 121  
  *                   |__/
 122  
  *
 123  
  *                     www.ObjectLab.co.uk
 124  
  */