1 | package com.reallifedeveloper.maven.jdepend; | |
2 | ||
3 | import java.io.File; | |
4 | import java.util.Locale; | |
5 | import java.util.ResourceBundle; | |
6 | ||
7 | import org.apache.maven.plugins.annotations.Execute; | |
8 | import org.apache.maven.plugins.annotations.LifecyclePhase; | |
9 | import org.apache.maven.plugins.annotations.Mojo; | |
10 | import org.apache.maven.plugins.annotations.Parameter; | |
11 | import org.apache.maven.reporting.AbstractMavenReport; | |
12 | import org.apache.maven.reporting.MavenReportException; | |
13 | ||
14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | |
15 | import jdepend.xmlui.JDepend; | |
16 | import lombok.Setter; | |
17 | ||
18 | import com.reallifedeveloper.maven.jdepend.xml.XmlReport; | |
19 | import com.reallifedeveloper.maven.jdepend.xml.XmlReportParser; | |
20 | ||
21 | /** | |
22 | * Generates a JDepend report. | |
23 | * | |
24 | * @author RealLifeDeveloper | |
25 | */ | |
26 | @Mojo(name = "report", defaultPhase = LifecyclePhase.SITE) | |
27 | @Execute(phase = LifecyclePhase.COMPILE) | |
28 | public class JDependReport extends AbstractMavenReport { | |
29 | ||
30 | private static final String RESOURCE_BUNDLE_BASE_NAME = "com.reallifedeveloper.maven.jdepend.jdepend-report"; | |
31 | private static final String OUTPUT_NAME = "jdepend-report"; | |
32 | private static final String JDEPEND_FILE_ARGUMENT = "-file"; | |
33 | ||
34 | /** | |
35 | * Directory containing the class files to analyze. | |
36 | */ | |
37 | @Parameter(property = "jdepend.classesDirectory", defaultValue = "${project.build.outputDirectory}") | |
38 | @Setter | |
39 | private File classesDirectory; | |
40 | ||
41 | /** | |
42 | * Location of the generated JDepend XML report that is used as the basis of the HTML report generated by this plugin. | |
43 | */ | |
44 | @Parameter(defaultValue = "${project.build.directory}/jdepend-report.xml", readonly = true) | |
45 | @Setter | |
46 | private File reportFile; | |
47 | ||
48 | /** | |
49 | * Skip execution of the plugin. | |
50 | */ | |
51 | @Parameter(property = "jdepend.skip", defaultValue = "false") | |
52 | @Setter | |
53 | private boolean skip; | |
54 | ||
55 | @Override | |
56 | @SuppressWarnings("PMD.AvoidCatchingGenericException") | |
57 | @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "Maven will call canGenerateReport " | |
58 | + "before calling this method") | |
59 | protected void executeReport(Locale locale) throws MavenReportException { | |
60 |
1
1. executeReport : negated conditional → KILLED |
if (skip) { |
61 |
1
1. executeReport : removed call to org/apache/maven/plugin/logging/Log::info → SURVIVED |
getLog().info("Skipping execution on behalf of user"); |
62 | return; | |
63 | } | |
64 | try { | |
65 |
1
1. executeReport : removed call to org/apache/maven/plugin/logging/Log::debug → SURVIVED |
getLog().debug("Running JDepend to generate XML report: reportFile=" + reportFile + ", classesDirectory=" + classesDirectory); |
66 |
1
1. executeReport : removed call to jdepend/xmlui/JDepend::main → SURVIVED |
JDepend.main(new String[] { JDEPEND_FILE_ARGUMENT, reportFile.getPath(), classesDirectory.getPath() }); |
67 | XmlReportParser xmlReportParser = new XmlReportParser(); | |
68 |
1
1. executeReport : removed call to org/apache/maven/plugin/logging/Log::debug → SURVIVED |
getLog().debug("Parsing XML file into XmlReport object"); |
69 | XmlReport xmlReport = xmlReportParser.parse(reportFile); | |
70 | JDependReportRenderer reportRenderer = new JDependReportRenderer(xmlReport, getBundle(locale), getSink()); | |
71 |
1
1. executeReport : removed call to org/apache/maven/plugin/logging/Log::debug → SURVIVED |
getLog().debug("Rendering HTML reportm: outputDirectory=" + outputDirectory); |
72 |
1
1. executeReport : removed call to com/reallifedeveloper/maven/jdepend/JDependReportRenderer::render → KILLED |
reportRenderer.render(); |
73 | } catch (Exception e) { | |
74 | throw new MavenReportException("Error occurred during JDepend report generation", e); | |
75 | } | |
76 | } | |
77 | ||
78 | @Override | |
79 | public boolean canGenerateReport() throws MavenReportException { | |
80 |
4
1. canGenerateReport : negated conditional → KILLED 2. canGenerateReport : negated conditional → KILLED 3. canGenerateReport : negated conditional → KILLED 4. canGenerateReport : replaced boolean return with true for com/reallifedeveloper/maven/jdepend/JDependReport::canGenerateReport → KILLED |
return classesDirectory != null && classesDirectory.canRead() && reportFile != null; |
81 | } | |
82 | ||
83 | @Override | |
84 | public String getOutputName() { | |
85 |
1
1. getOutputName : replaced return value with "" for com/reallifedeveloper/maven/jdepend/JDependReport::getOutputName → KILLED |
return OUTPUT_NAME; |
86 | } | |
87 | ||
88 | @Override | |
89 | public String getName(Locale locale) { | |
90 |
1
1. getName : replaced return value with "" for com/reallifedeveloper/maven/jdepend/JDependReport::getName → KILLED |
return getBundle(locale).getString("jdepend.name"); |
91 | } | |
92 | ||
93 | @Override | |
94 | public String getDescription(Locale locale) { | |
95 |
1
1. getDescription : replaced return value with "" for com/reallifedeveloper/maven/jdepend/JDependReport::getDescription → KILLED |
return getBundle(locale).getString("jdepend.description"); |
96 | } | |
97 | ||
98 | @SuppressWarnings("PMD.UseProperClassLoader") // We want the class loader of this class, not the Maven code creating the report. | |
99 | private static ResourceBundle getBundle(Locale locale) { | |
100 |
1
1. getBundle : replaced return value with null for com/reallifedeveloper/maven/jdepend/JDependReport::getBundle → KILLED |
return ResourceBundle.getBundle(RESOURCE_BUNDLE_BASE_NAME, locale, JDependReport.class.getClassLoader()); |
101 | } | |
102 | } | |
Mutations | ||
60 |
1.1 |
|
61 |
1.1 |
|
65 |
1.1 |
|
66 |
1.1 |
|
68 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
80 |
1.1 2.2 3.3 4.4 |
|
85 |
1.1 |
|
90 |
1.1 |
|
95 |
1.1 |
|
100 |
1.1 |