Project Report: fawkez

Packagesummary org.jcoderz.phoenix.report

org.jcoderz.phoenix.report.HTMLRenderAntTask

LineHitsNoteSource
1  /*
2   * $Id: HTMLRenderAntTask.java 1496 2009-06-07 17:28:52Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.phoenix.report;
34  
35  import java.io.File;
36  import java.nio.charset.Charset;
37  import java.util.ArrayList;
38  import java.util.List;
39  import java.util.logging.Logger;
40  
41  import org.apache.tools.ant.BuildException;
42  import org.apache.tools.ant.taskdefs.MatchingTask;
43  import org.jcoderz.commons.util.FileUtils;
44  
45  /**
46   * Ant Task rendering <code>jcoderz-report.xml</code> files
47   * into HTML files.
48   *
49   * @author Michael Rumpf (Michael.Rumpf@jcoderz.org)
50   */
510 public final class HTMLRenderAntTask
52        extends MatchingTask
53  {
540    private static final String CLASSNAME = HTMLRenderAntTask.class.getName();
550    private static final Logger logger = Logger.getLogger(CLASSNAME);
56  
570    private File mBaseDir = null;
58     /** Output directory for XML/HTML report. */
590    private File mOut = null;
60     /** The report name. */
610    private String mName = null;
62     /** The base package name. */
630    private String mPackageBase = null;
640    private Charset mSourceEncoding = null;
65  
66     /**
67      * Sets the output directory to given <code>dir</code>.
68      * This directory is used to store the XML/HTML report file(s).
69      *
70      * @param dir The output directory to set
71      */
72     public void setOut (File dir)
73     {
740       mOut = dir;
750    }
76  
77 (1)   public void setBaseDir (File dir)
78     {
790       mBaseDir = dir;
800    }
81  
82 (2)   public void setName (String name)
83     {
840       mName = name;
850    }
86  
87 (3)   public void setPackageBase (String pkgBase)
88     {
890      mPackageBase = pkgBase;
900    }
91  
92 (4)   public void setSourceEncoding (String srcEncoding)
93     {
940      mSourceEncoding = Charset.forName(srcEncoding);
950    }
96  
97     /**
98      * Execute this task.
99      *
100      * @throws BuildException An building exception occurred
101      */
102     public void execute ()
103           throws BuildException
104     {
105        try
106        {
1070          final List<String> argList = new ArrayList<String>();
108  
109 (5)         // FIXME: . is not correct if the build process was started from a
110           // different dir (which is true in cc build)
1110          final File outDir = mOut == null
112                 ? new File(mBaseDir , "build/report-" + mName) : mOut;
1130          FileUtils.mkdirs(outDir);
1140          argList.add("-outDir");
1150          argList.add(outDir.getCanonicalPath());
116  
1170          argList.add("-report");
1180          final File reportFile
119               = new File(outDir, "jcoderz-merged-report.xml");
1200          argList.add(reportFile.getCanonicalPath());
121  
122 (6)         // FIXME: . is not correct if the build process was started from a
123           // different dir (which is true in cc build)
1240          argList.add("-projectHome");
1250          argList.add(mBaseDir.getCanonicalPath());
126  
1270          argList.add("-projectName");
1280          argList.add(mName);
129           
1300          if (mPackageBase != null)
131           {
1320            argList.add("-packageBase");
1330            argList.add(mPackageBase);
134           }
135  
1360          if (mSourceEncoding != null)
137           {
1380              argList.add("-sourceEncoding");
1390              argList.add(mSourceEncoding.name());
140           }
1410          logger.fine("Calling Java2Html with args '" + argList + "'");
1420          final String[] java2HtmlArgs
143 (7)            = (String[]) argList.toArray(new String[argList.size()]);
1440          Java2Html.main(java2HtmlArgs);
145        }
1460       catch (Exception ex)
147        {
1480          ex.printStackTrace();
1490          logger.severe("Could not render HTML!");
1500       }
1510    }
152  }

Findings in this File

c (8) Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag 'BuildException'.
c (1) 77 : 4 Missing a Javadoc comment.
c (2) 82 : 4 Missing a Javadoc comment.
c (3) 87 : 4 Missing a Javadoc comment.
c (4) 92 : 4 Missing a Javadoc comment.
i (5) 109 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
i (6) 122 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
c (7) 143 : 15 [cast] redundant cast to java.lang.String[]