From f05ceff1bf8833c011753deedb5a7814f23a3d1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:24:33 +0000 Subject: [PATCH 1/2] Bump org.codehaus.mojo:mojo-parent from 78 to 80 Bumps [org.codehaus.mojo:mojo-parent](https://github.com/mojohaus/mojo-parent) from 78 to 80. - [Release notes](https://github.com/mojohaus/mojo-parent/releases) - [Commits](https://github.com/mojohaus/mojo-parent/commits) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mojo-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 40e47bb..413c43a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.codehaus.mojo mojo-parent - 78 + 80 jdepend-maven-plugin @@ -67,7 +67,6 @@ 3.6.3 2.9.1 - 8 target/staging/${project.artifactId} @@ -131,7 +130,6 @@ org.codehaus.mojo license-maven-plugin - 2.4.0 asf-2.0 ${project.baseUri}/src/license From f3cbefd98672b2ddce046067ca184cb3f49aea5d Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 17 Mar 2024 15:50:58 +0100 Subject: [PATCH 2/2] Apply spotless plugin --- pom.xml | 1 - .../mojo/jdepend/AbstractJDependMojo.java | 159 ++++---- .../codehaus/mojo/jdepend/JDependMojo.java | 15 +- .../mojo/jdepend/JDependNoForkMojo.java | 14 +- .../mojo/jdepend/JDependXMLReportParser.java | 153 +++----- .../mojo/jdepend/ReportGenerator.java | 347 ++++++++---------- .../mojo/jdepend/objects/CyclePackage.java | 28 +- .../mojo/jdepend/objects/JDPackage.java | 67 ++-- .../mojo/jdepend/objects/Packages.java | 26 +- .../codehaus/mojo/jdepend/objects/Stats.java | 61 ++- .../mojo/jdepend/JDependMojoTest.java | 36 +- .../mojo/jdepend/JDependReportParserTest.java | 142 +++---- 12 files changed, 421 insertions(+), 628 deletions(-) diff --git a/pom.xml b/pom.xml index 413c43a..e1d89ee 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,6 @@ https://github.com/mojohaus/jdepend-maven-plugin/issues - 3.6.3 2.9.1 diff --git a/src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java b/src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java index 9b4ea57..0f13e48 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java +++ b/src/main/java/org/codehaus/mojo/jdepend/AbstractJDependMojo.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -20,6 +20,12 @@ * #L% */ +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + import jdepend.xmlui.JDepend; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.siterenderer.Renderer; @@ -28,51 +34,44 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.ResourceBundle; /** * @author Karl-Heinz Marbaise */ -public abstract class AbstractJDependMojo - extends AbstractMavenReport -{ +public abstract class AbstractJDependMojo extends AbstractMavenReport { JDependXMLReportParser xmlParser; - @Parameter( defaultValue = "${project}", readonly = true, required = true ) + @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenProject project; /** * Directory where the generated output site files will be located. */ - @Parameter( defaultValue = "${project.build.directory}/site", property = "jdepend.outputDirectory", required = true ) + @Parameter(defaultValue = "${project.build.directory}/site", property = "jdepend.outputDirectory", required = true) private String outputDirectory; /** * Directory of the project. */ - @Parameter( defaultValue = "${basedir}", property = "jdepend.projectDirectory" ) + @Parameter(defaultValue = "${basedir}", property = "jdepend.projectDirectory") private String projectDirectory; /** * Directory containing the class files. */ - @Parameter( defaultValue = "${project.build.outputDirectory}", property = "jdepend.classDirectory", required = true ) + @Parameter(defaultValue = "${project.build.outputDirectory}", property = "jdepend.classDirectory", required = true) private String classDirectory; /** * Location of the generated JDepend xml report. */ - @Parameter( defaultValue = "${project.build.directory}/jdepend-report.xml", required = true, readonly = true ) + @Parameter(defaultValue = "${project.build.directory}/jdepend-report.xml", required = true, readonly = true) private String reportFile; /** * Skip execution of the plugin. */ - @Parameter( defaultValue = "false", property = "jdepend.skip" ) + @Parameter(defaultValue = "false", property = "jdepend.skip") private boolean skip; /** @@ -85,37 +84,29 @@ public abstract class AbstractJDependMojo * (non-Javadoc) * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ - public void executeReport( Locale locale ) - throws MavenReportException - { - if ( skip ) - { - getLog().info( "Skipping execution on behalf of user" ); + public void executeReport(Locale locale) throws MavenReportException { + if (skip) { + getLog().info("Skipping execution on behalf of user"); return; } - try - { - File outputDirFile = new File( outputDirectory ); + try { + File outputDirFile = new File(outputDirectory); - if ( !outputDirFile.exists() ) - { + if (!outputDirFile.exists()) { boolean success = outputDirFile.mkdirs(); - if ( !success ) - { - throw new MavenReportException( "Could not create directory " + outputDirectory ); + if (!success) { + throw new MavenReportException("Could not create directory " + outputDirectory); } } - JDepend.main( getArgumentList( getArgument(), getReportFile(), getClassDirectory() ) ); + JDepend.main(getArgumentList(getArgument(), getReportFile(), getClassDirectory())); - xmlParser = new JDependXMLReportParser( new File( getReportFile() ) ); + xmlParser = new JDependXMLReportParser(new File(getReportFile())); - generateReport( locale ); - } - catch ( Exception e ) - { - throw new MavenReportException( "Failed to execute JDepend", e ); + generateReport(locale); + } catch (Exception e) { + throw new MavenReportException("Failed to execute JDepend", e); } } @@ -123,46 +114,39 @@ public void executeReport( Locale locale ) * (non-Javadoc) * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport() */ - public boolean canGenerateReport() - { - return new File( classDirectory ).exists(); + public boolean canGenerateReport() { + return new File(classDirectory).exists(); } /** * Sets and get the arguments passed for the JDepend. - * + * * @param argument Accepts parameter with "-file" string. * @param locationXMLreportFile Accepts the location of the generated JDepend xml report file. * @param classDir Accepts the location of the classes. * @return String[] Returns the array to be pass as parameters for JDepend. */ - private String[] getArgumentList( String argument, String locationXMLreportFile, String classDir ) - { + private String[] getArgumentList(String argument, String locationXMLreportFile, String classDir) { List argList = new ArrayList<>(); - argList.add( argument ); + argList.add(argument); - argList.add( locationXMLreportFile ); + argList.add(locationXMLreportFile); - argList.add( classDir ); + argList.add(classDir); - return argList.toArray( new String[0] ); + return argList.toArray(new String[0]); } - public void generateReport( Locale locale ) - throws MavenReportException - { + public void generateReport(Locale locale) throws MavenReportException { Sink sink; ReportGenerator report = new ReportGenerator(); - try - { + try { sink = getSink(); - report.doGenerateReport( getBundle( locale ), sink, xmlParser ); - } - catch ( Exception e ) - { - throw new MavenReportException( "Failed to generate JDepend report", e ); + report.doGenerateReport(getBundle(locale), sink, xmlParser); + } catch (Exception e) { + throw new MavenReportException("Failed to generate JDepend report", e); } } @@ -170,32 +154,30 @@ public void generateReport( Locale locale ) * (non-Javadoc) * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale) */ - public String getDescription( Locale locale ) - { - return getBundle( locale ).getString( "report.jdepend.description" ); + public String getDescription(Locale locale) { + return getBundle(locale).getString("report.jdepend.description"); } /* * (non-Javadoc) * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) */ - public String getName( Locale locale ) - { - return getBundle( locale ).getString( "report.jdepend.name" ); + public String getName(Locale locale) { + return getBundle(locale).getString("report.jdepend.name"); } - private ResourceBundle getBundle( Locale locale ) - { - return ResourceBundle.getBundle( "org.codehaus.mojo.jdepend.jdepend-report", locale, - this.getClass().getClassLoader() ); + private ResourceBundle getBundle(Locale locale) { + return ResourceBundle.getBundle( + "org.codehaus.mojo.jdepend.jdepend-report", + locale, + this.getClass().getClassLoader()); } /* * (non-Javadoc) * @see org.apache.maven.reporting.MavenReport#getOutputName() */ - public String getOutputName() - { + public String getOutputName() { return "jdepend-report"; } @@ -203,16 +185,14 @@ public String getOutputName() * (non-Javadoc) * @see org.apache.maven.reporting.AbstractMavenReport#getProject() */ - public MavenProject getProject() - { + public MavenProject getProject() { return project; } /** * @param project */ - public void setProject( MavenProject project ) - { + public void setProject(MavenProject project) { this.project = project; } @@ -220,34 +200,29 @@ public void setProject( MavenProject project ) * (non-Javadoc) * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory() */ - public String getOutputDirectory() - { + public String getOutputDirectory() { return outputDirectory; } - public void setOutputDirectory( String outputDirectory ) - { + public void setOutputDirectory(String outputDirectory) { this.outputDirectory = outputDirectory; } /** * @return The argument. */ - public String getArgument() - { + public String getArgument() { return "-file"; } /** * @return */ - public String getReportFile() - { + public String getReportFile() { return reportFile; } - public void setReportFile( String reportFile ) - { + public void setReportFile(String reportFile) { this.reportFile = reportFile; } @@ -255,33 +230,27 @@ public void setReportFile( String reportFile ) * (non-Javadoc) * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() */ - public Renderer getSiteRenderer() - { + public Renderer getSiteRenderer() { return siteRenderer; } - public void setSiteRenderer( Renderer siteRenderer ) - { + public void setSiteRenderer(Renderer siteRenderer) { this.siteRenderer = siteRenderer; } - public String getProjectDirectory() - { + public String getProjectDirectory() { return projectDirectory; } - public void setProjectDirectory( String projectDirectory ) - { + public void setProjectDirectory(String projectDirectory) { this.projectDirectory = projectDirectory; } - public String getClassDirectory() - { + public String getClassDirectory() { return classDirectory; } - public void setClassDirectory( String classDirectory ) - { + public void setClassDirectory(String classDirectory) { this.classDirectory = classDirectory; } } diff --git a/src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java b/src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java index d6cd427..d6cc5c5 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java +++ b/src/main/java/org/codehaus/mojo/jdepend/JDependMojo.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -26,13 +26,10 @@ /** * Run JDepend and generate a site report. Goal which generate the JDepend metrics. - * + * * @author aramirez@exist.com * @version $Id$ */ -@Mojo( name = "generate" ) -@Execute( phase = LifecyclePhase.COMPILE ) -public class JDependMojo - extends AbstractJDependMojo -{ -} +@Mojo(name = "generate") +@Execute(phase = LifecyclePhase.COMPILE) +public class JDependMojo extends AbstractJDependMojo {} diff --git a/src/main/java/org/codehaus/mojo/jdepend/JDependNoForkMojo.java b/src/main/java/org/codehaus/mojo/jdepend/JDependNoForkMojo.java index 6d75d4c..0acf02d 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/JDependNoForkMojo.java +++ b/src/main/java/org/codehaus/mojo/jdepend/JDependNoForkMojo.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -25,12 +25,8 @@ /** * Run JDepend and generate a site report. Goal which generate the JDepend metrics. - * + * * @author Karl-Heinz Marbaise */ -@Mojo( name = "generate-no-fork", defaultPhase = LifecyclePhase.SITE ) -public class JDependNoForkMojo - extends AbstractJDependMojo -{ - -} +@Mojo(name = "generate-no-fork", defaultPhase = LifecyclePhase.SITE) +public class JDependNoForkMojo extends AbstractJDependMojo {} diff --git a/src/main/java/org/codehaus/mojo/jdepend/JDependXMLReportParser.java b/src/main/java/org/codehaus/mojo/jdepend/JDependXMLReportParser.java index 68d6503..046df4d 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/JDependXMLReportParser.java +++ b/src/main/java/org/codehaus/mojo/jdepend/JDependXMLReportParser.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -20,16 +20,16 @@ * #L% */ +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Stack; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.codehaus.mojo.jdepend.objects.CyclePackage; import org.codehaus.mojo.jdepend.objects.JDPackage; import org.codehaus.mojo.jdepend.objects.Stats; @@ -40,9 +40,7 @@ /** * @author Who ever this implemented first. */ -public class JDependXMLReportParser - extends DefaultHandler -{ +public class JDependXMLReportParser extends DefaultHandler { protected List packages; protected JDPackage jdpackage; @@ -63,15 +61,13 @@ public class JDependXMLReportParser /** * Creates a new instance of JDependXMLReportParser. - * + * * @param xmlFile * @throws ParserConfigurationException * @throws SAXException * @throws IOException */ - public JDependXMLReportParser( File xmlFile ) - throws ParserConfigurationException, SAXException, IOException - { + public JDependXMLReportParser(File xmlFile) throws ParserConfigurationException, SAXException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); /* Create an empty stack */ @@ -79,8 +75,7 @@ public JDependXMLReportParser( File xmlFile ) SAXParser saxParser = factory.newSAXParser(); - saxParser.parse( xmlFile, this ); - + saxParser.parse(xmlFile, this); } /* @@ -88,38 +83,31 @@ public JDependXMLReportParser( File xmlFile ) * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, * org.xml.sax.Attributes) */ - public void startElement( String namespaceURI, String sName, String qName, Attributes attrs ) - { + public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) { /* Push element name into stack */ - stack.push( qName ); + stack.push(qName); // TODO only create a new buffer when the element is expected to have // text buffer = new StringBuffer(); - switch ( qName ) - { + switch (qName) { case "Packages": packages = new ArrayList<>(); break; case "Package": - if ( isParentElement( "Packages" ) ) - { + if (isParentElement("Packages")) { jdpackage = new JDPackage(); - if ( attrs != null ) - { - jdpackage.setPackageName( attrs.getValue( 0 ) ); + if (attrs != null) { + jdpackage.setPackageName(attrs.getValue(0)); } - } - else if ( isParentElement( "Cycles" ) ) - { + } else if (isParentElement("Cycles")) { cyclePackage = new CyclePackage(); - if ( attrs != null ) - { - cyclePackage.setName( attrs.getValue( 0 ) ); + if (attrs != null) { + cyclePackage.setName(attrs.getValue(0)); } } break; @@ -136,94 +124,75 @@ else if ( isParentElement( "Cycles" ) ) * (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ - public void endElement( String namespaceURI, String sName, String qName ) - { + public void endElement(String namespaceURI, String sName, String qName) { String elementValue = buffer != null ? buffer.toString().trim() : null; - switch ( qName ) - { + switch (qName) { case "Package": - if ( isParentElement( "Packages" ) ) - { - if ( !errFlag ) - { - jdpackage.setStats( stats ); + if (isParentElement("Packages")) { + if (!errFlag) { + jdpackage.setStats(stats); - packages.add( jdpackage ); + packages.add(jdpackage); } errFlag = false; - } - else if ( isParentElement( "DependsUpon" ) ) - { - jdpackage.addDependsUpon( elementValue ); - } - else if ( isParentElement( "UsedBy" ) ) - { - jdpackage.addUsedBy( elementValue ); - } - else if ( isParentElement( "Package" ) ) - { - cyclePackage.addPackageList( elementValue ); - } - else if ( isParentElement( "Cycles" ) ) - { - cycles.add( cyclePackage ); + } else if (isParentElement("DependsUpon")) { + jdpackage.addDependsUpon(elementValue); + } else if (isParentElement("UsedBy")) { + jdpackage.addUsedBy(elementValue); + } else if (isParentElement("Package")) { + cyclePackage.addPackageList(elementValue); + } else if (isParentElement("Cycles")) { + cycles.add(cyclePackage); } break; case "TotalClasses": - stats.setTotalClasses( elementValue ); + stats.setTotalClasses(elementValue); break; case "ConcreteClasses": - if ( isParentElement( "Stats" ) ) - { - stats.setConcreteClasses( elementValue ); + if (isParentElement("Stats")) { + stats.setConcreteClasses(elementValue); } break; case "AbstractClasses": - if ( isParentElement( "Stats" ) ) - { - stats.setAbstractClasses( elementValue ); + if (isParentElement("Stats")) { + stats.setAbstractClasses(elementValue); } break; case "Ca": - stats.setCa( elementValue ); + stats.setCa(elementValue); break; case "Ce": - stats.setCe( elementValue ); + stats.setCe(elementValue); break; case "A": - stats.setA( elementValue ); + stats.setA(elementValue); break; case "I": - stats.setI( elementValue ); + stats.setI(elementValue); break; case "D": - stats.setD( elementValue ); + stats.setD(elementValue); break; case "V": - stats.setV( elementValue ); + stats.setV(elementValue); break; case "Class": - if ( isParentElement( "AbstractClasses" ) ) - { - jdpackage.addAbstractClasses( elementValue ); - } - else if ( isParentElement( "ConcreteClasses" ) ) - { - jdpackage.addConcreteClasses( elementValue ); + if (isParentElement("AbstractClasses")) { + jdpackage.addAbstractClasses(elementValue); + } else if (isParentElement("ConcreteClasses")) { + jdpackage.addConcreteClasses(elementValue); } break; case "error": - if ( isParentElement( "Package" ) ) - { + if (isParentElement("Package")) { errFlag = true; } break; } - if ( stack.size() != 0 ) - { + if (stack.size() != 0) { /* Remove element name in stack */ stack.pop(); } @@ -235,35 +204,30 @@ else if ( isParentElement( "ConcreteClasses" ) ) * (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ - public void characters( char[] buff, int offset, int len ) - { - if ( buffer != null ) - { - buffer.append( buff, offset, len ); + public void characters(char[] buff, int offset, int len) { + if (buffer != null) { + buffer.append(buff, offset, len); } } /** * @return Packages. */ - public List getPackages() - { + public List getPackages() { return this.packages; } /** * @return stats. */ - public Stats getStats() - { + public Stats getStats() { return this.stats; } /** * @return parent index. */ - private int getParentIndex() - { + private int getParentIndex() { return stack.size() - 2; } @@ -271,8 +235,7 @@ private int getParentIndex() * @param parentElement * @return true otherwise false. */ - private boolean isParentElement( String parentElement ) - { - return stack.get( getParentIndex() ).equals( parentElement ); + private boolean isParentElement(String parentElement) { + return stack.get(getParentIndex()).equals(parentElement); } } diff --git a/src/main/java/org/codehaus/mojo/jdepend/ReportGenerator.java b/src/main/java/org/codehaus/mojo/jdepend/ReportGenerator.java index fb738a6..84c16a4 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/ReportGenerator.java +++ b/src/main/java/org/codehaus/mojo/jdepend/ReportGenerator.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -20,16 +20,15 @@ * #L% */ +import java.util.List; +import java.util.ResourceBundle; + import org.apache.maven.doxia.sink.Sink; import org.codehaus.mojo.jdepend.objects.CyclePackage; import org.codehaus.mojo.jdepend.objects.JDPackage; import org.codehaus.mojo.jdepend.objects.Stats; -import java.util.List; -import java.util.ResourceBundle; - -public class ReportGenerator -{ +public class ReportGenerator { private JDependXMLReportParser jdepend; private Stats stats; @@ -39,17 +38,14 @@ public class ReportGenerator /** * Creates a new instance of ReportGenerator. */ - public ReportGenerator() - { - } + public ReportGenerator() {} - public void doGenerateReport( ResourceBundle bundle, Sink sink, JDependXMLReportParser jdepend ) - { + public void doGenerateReport(ResourceBundle bundle, Sink sink, JDependXMLReportParser jdepend) { this.jdepend = jdepend; sink.head(); sink.title(); - sink.text( bundle.getString( "report.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.title")); // $NON-NLS-1$ sink.title_(); sink.head_(); @@ -57,223 +53,209 @@ public void doGenerateReport( ResourceBundle bundle, Sink sink, JDependXMLReport sink.section1(); sink.sectionTitle1(); - sink.text( bundle.getString( "report.metricresults" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.metricresults")); // $NON-NLS-1$ sink.sectionTitle1_(); - doSectionLinks( bundle, sink ); + doSectionLinks(bundle, sink); sink.lineBreak(); sink.lineBreak(); - sink.text( bundle.getString( "report.intro" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.intro")); // $NON-NLS-1$ sink.lineBreak(); sink.lineBreak(); - doSummarySection( bundle, sink ); + doSummarySection(bundle, sink); - doPackagesSection( bundle, sink ); + doPackagesSection(bundle, sink); - doCycleSection( bundle, sink ); + doCycleSection(bundle, sink); - doExplanationSection( bundle, sink ); + doExplanationSection(bundle, sink); sink.section1_(); sink.body_(); sink.flush(); sink.close(); - } - public void doSectionLinks( ResourceBundle bundle, Sink sink ) - { + public void doSectionLinks(ResourceBundle bundle, Sink sink) { - sink.text( bundle.getString( "report.square-open" ) ); //$NON-NLS-1$ - sink.link( bundle.getString( "report.summary.anchor" ) ); //$NON-NLS-1$ - sink.text( bundle.getString( "report.summary.text" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-open")); // $NON-NLS-1$ + sink.link(bundle.getString("report.summary.anchor")); // $NON-NLS-1$ + sink.text(bundle.getString("report.summary.text")); // $NON-NLS-1$ sink.link_(); - sink.text( bundle.getString( "report.square-close" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-close")); // $NON-NLS-1$ - sink.text( bundle.getString( "report.square-open" ) ); //$NON-NLS-1$ - sink.link( bundle.getString( "report.packages.anchor" ) ); //$NON-NLS-1$ - sink.text( bundle.getString( "report.packages.text" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-open")); // $NON-NLS-1$ + sink.link(bundle.getString("report.packages.anchor")); // $NON-NLS-1$ + sink.text(bundle.getString("report.packages.text")); // $NON-NLS-1$ sink.link_(); - sink.text( bundle.getString( "report.square-close" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-close")); // $NON-NLS-1$ - sink.text( bundle.getString( "report.square-open" ) ); //$NON-NLS-1$ - sink.link( bundle.getString( "report.cycles.anchor" ) ); //$NON-NLS-1$ - sink.text( bundle.getString( "report.cycles.text" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-open")); // $NON-NLS-1$ + sink.link(bundle.getString("report.cycles.anchor")); // $NON-NLS-1$ + sink.text(bundle.getString("report.cycles.text")); // $NON-NLS-1$ sink.link_(); - sink.text( bundle.getString( "report.square-close" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-close")); // $NON-NLS-1$ - sink.text( bundle.getString( "report.square-open" ) ); //$NON-NLS-1$ - sink.link( bundle.getString( "report.explanations.anchor" ) ); //$NON-NLS-1$ - sink.text( bundle.getString( "report.explanations.text" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.square-open")); // $NON-NLS-1$ + sink.link(bundle.getString("report.explanations.anchor")); // $NON-NLS-1$ + sink.text(bundle.getString("report.explanations.text")); // $NON-NLS-1$ sink.link_(); - sink.text( bundle.getString( "report.square-close" ) ); //$NON-NLS-1$ - + sink.text(bundle.getString("report.square-close")); // $NON-NLS-1$ } - public void doSummarySection( ResourceBundle bundle, Sink sink ) - { + public void doSummarySection(ResourceBundle bundle, Sink sink) { - sink.anchor( bundle.getString( "report.summary.text" ) ); //$NON-NLS-1$ + sink.anchor(bundle.getString("report.summary.text")); // $NON-NLS-1$ sink.anchor_(); sink.sectionTitle1(); - sink.text( bundle.getString( "report.summary.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.summary.title")); // $NON-NLS-1$ sink.sectionTitle1_(); - doSectionLinks( bundle, sink ); + doSectionLinks(bundle, sink); sink.lineBreak(); sink.lineBreak(); sink.table(); - generateHeaderRow( bundle, sink ); + generateHeaderRow(bundle, sink); list = jdepend.packages; - for ( JDPackage o : list ) - { + for (JDPackage o : list) { stats = o.getStats(); sink.tableRow(); sink.tableCell(); - sink.link( bundle.getString( "report.dash" ) + o.getPackageName() ); //$NON-NLS-1$ - sink.text( o.getPackageName() ); + sink.link(bundle.getString("report.dash") + o.getPackageName()); // $NON-NLS-1$ + sink.text(o.getPackageName()); sink.link_(); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getTotalClasses() ); + sink.text(stats.getTotalClasses()); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getConcreteClasses() ); + sink.text(stats.getConcreteClasses()); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getAbstractClasses() ); + sink.text(stats.getAbstractClasses()); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getCa() ); + sink.text(stats.getCa()); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getCe() ); + sink.text(stats.getCe()); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getA() ) ); + sink.text(convertToPercent(stats.getA())); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getI() ) ); + sink.text(convertToPercent(stats.getI())); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getD() ) ); + sink.text(convertToPercent(stats.getD())); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getV() ); + sink.text(stats.getV()); sink.tableCell_(); sink.tableRow_(); } sink.table_(); - } - private void generateHeaderRow( ResourceBundle bundle, Sink sink ) - { + private void generateHeaderRow(ResourceBundle bundle, Sink sink) { sink.tableRow(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.package.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.package.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.TC" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.TC")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.CC" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.CC")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.AC" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.AC")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.Ca" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.Ca")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.Ce" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.Ce")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.A" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.A")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.I" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.I")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.D" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.D")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.V" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.V")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableRow_(); } - public void doPackagesSection( ResourceBundle bundle, Sink sink ) - { + public void doPackagesSection(ResourceBundle bundle, Sink sink) { - sink.anchor( bundle.getString( "report.packages.text" ) ); //$NON-NLS-1$ + sink.anchor(bundle.getString("report.packages.text")); // $NON-NLS-1$ sink.anchor_(); sink.sectionTitle1(); - sink.text( bundle.getString( "report.packages.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.packages.title")); // $NON-NLS-1$ sink.sectionTitle1_(); - doSectionLinks( bundle, sink ); + doSectionLinks(bundle, sink); sink.lineBreak(); - doPackage( bundle, sink ); - + doPackage(bundle, sink); } - public void doPackage( ResourceBundle bundle, Sink sink ) - { + public void doPackage(ResourceBundle bundle, Sink sink) { list = jdepend.packages; - if ( list.size() <= 0 ) - { - sink.text( bundle.getString( "report.nopackages" ) ); //$NON-NLS-1$ + if (list.size() <= 0) { + sink.text(bundle.getString("report.nopackages")); // $NON-NLS-1$ sink.lineBreak(); - } - else - { - for ( JDPackage jdpackage : list ) - { + } else { + for (JDPackage jdpackage : list) { stats = jdpackage.getStats(); - sink.anchor( jdpackage.getPackageName() ); + sink.anchor(jdpackage.getPackageName()); sink.anchor_(); sink.sectionTitle2(); - sink.text( jdpackage.getPackageName() ); + sink.text(jdpackage.getPackageName()); sink.sectionTitle2_(); sink.table(); @@ -283,23 +265,23 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableRow(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.afferentcouplings.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.afferentcouplings.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.efferentcouplings.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.efferentcouplings.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.abstractness.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.abstractness.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.instability.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.instability.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.distance.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.distance.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableRow_(); @@ -309,23 +291,23 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableRow(); sink.tableCell(); - sink.text( stats.getCa() ); + sink.text(stats.getCa()); sink.tableCell_(); sink.tableCell(); - sink.text( stats.getCe() ); + sink.text(stats.getCe()); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getA() ) ); + sink.text(convertToPercent(stats.getA())); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getI() ) ); + sink.text(convertToPercent(stats.getI())); sink.tableCell_(); sink.tableCell(); - sink.text( convertToPercent( stats.getD() ) ); + sink.text(convertToPercent(stats.getD())); sink.tableCell_(); sink.tableRow_(); @@ -342,19 +324,19 @@ public void doPackage( ResourceBundle bundle, Sink sink ) */ sink.tableHeaderCell(); - sink.text( bundle.getString( "report.abstractclasses.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.abstractclasses.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.concreteclasses.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.concreteclasses.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.usedbypackages" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.usedbypackages")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.usespackage" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.usespackage")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableRow_(); @@ -370,17 +352,13 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableCell(); - if ( abstractList.size() <= 0 ) - { + if (abstractList.size() <= 0) { sink.italic(); - sink.text( bundle.getString( "report.none" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.none")); // $NON-NLS-1$ sink.italic_(); - } - else - { - for ( String value : abstractList ) - { - sink.text( value ); + } else { + for (String value : abstractList) { + sink.text(value); sink.lineBreak(); } } @@ -391,17 +369,13 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableCell(); - if ( concreteList.size() <= 0 ) - { + if (concreteList.size() <= 0) { sink.italic(); - sink.text( bundle.getString( "report.none" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.none")); // $NON-NLS-1$ sink.italic_(); - } - else - { - for ( String s : concreteList ) - { - sink.text( s ); + } else { + for (String s : concreteList) { + sink.text(s); sink.lineBreak(); } } @@ -412,17 +386,13 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableCell(); - if ( aList.size() <= 0 ) - { + if (aList.size() <= 0) { sink.italic(); - sink.text( bundle.getString( "report.none" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.none")); // $NON-NLS-1$ sink.italic_(); - } - else - { - for ( String s : aList ) - { - sink.text( s ); + } else { + for (String s : aList) { + sink.text(s); sink.lineBreak(); } } @@ -433,17 +403,13 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.tableCell(); - if ( aList.size() <= 0 ) - { + if (aList.size() <= 0) { sink.italic(); - sink.text( bundle.getString( "report.none" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.none")); // $NON-NLS-1$ sink.italic_(); - } - else - { - for ( String s : aList ) - { - sink.text( s ); + } else { + for (String s : aList) { + sink.text(s); sink.lineBreak(); } } @@ -454,103 +420,88 @@ public void doPackage( ResourceBundle bundle, Sink sink ) sink.table_(); } } - } - public void doCycleSection( ResourceBundle bundle, Sink sink ) - { + public void doCycleSection(ResourceBundle bundle, Sink sink) { - sink.anchor( bundle.getString( "report.cycles.text" ) ); //$NON-NLS-1$ + sink.anchor(bundle.getString("report.cycles.text")); // $NON-NLS-1$ sink.anchor_(); sink.sectionTitle1(); - sink.text( bundle.getString( "report.cycles.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.cycles.title")); // $NON-NLS-1$ sink.sectionTitle1_(); - doSectionLinks( bundle, sink ); + doSectionLinks(bundle, sink); sink.lineBreak(); sink.lineBreak(); - doCycles( bundle, sink ); - + doCycles(bundle, sink); } - public void doCycles( ResourceBundle bundle, Sink sink ) - { + public void doCycles(ResourceBundle bundle, Sink sink) { List cycleList = jdepend.cycles; - if ( cycleList.size() <= 0 ) - { - sink.text( bundle.getString( "report.nocyclicdependencies" ) ); //$NON-NLS-1$ + if (cycleList.size() <= 0) { + sink.text(bundle.getString("report.nocyclicdependencies")); // $NON-NLS-1$ sink.lineBreak(); - } - else - { + } else { sink.table(); sink.tableRow(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.package.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.package.title")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.packagedependencies" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.packagedependencies")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableRow_(); - for ( CyclePackage cyclePackage : cycleList ) - { + for (CyclePackage cyclePackage : cycleList) { sink.tableRow(); sink.tableCell(); - sink.text( cyclePackage.getName() ); + sink.text(cyclePackage.getName()); sink.tableCell_(); /* Package Dependencies List */ List packageList = cyclePackage.getPackageList(); sink.tableCell(); - if ( packageList.size() <= 0 ) - { + if (packageList.size() <= 0) { sink.italic(); - sink.text( bundle.getString( "report.none" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.none")); // $NON-NLS-1$ sink.italic_(); - } - else - { - for ( String s : packageList ) - { - sink.text( s ); + } else { + for (String s : packageList) { + sink.text(s); sink.lineBreak(); } } sink.tableCell_(); sink.tableRow_(); - } sink.table_(); } - } - public void doExplanationSection( ResourceBundle bundle, Sink sink ) - { + public void doExplanationSection(ResourceBundle bundle, Sink sink) { - sink.anchor( bundle.getString( "report.explanations" ) ); //$NON-NLS-1$ + sink.anchor(bundle.getString("report.explanations")); // $NON-NLS-1$ sink.anchor_(); sink.sectionTitle1(); - sink.text( bundle.getString( "report.explanation.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.explanation.title")); // $NON-NLS-1$ sink.sectionTitle1_(); - doSectionLinks( bundle, sink ); + doSectionLinks(bundle, sink); sink.lineBreak(); sink.lineBreak(); - sink.text( bundle.getString( "report.explanation.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.explanation.description")); // $NON-NLS-1$ sink.lineBreak(); sink.lineBreak(); @@ -559,90 +510,88 @@ public void doExplanationSection( ResourceBundle bundle, Sink sink ) sink.tableRow(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.term" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.term")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( bundle.getString( "report.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.description")); // $NON-NLS-1$ sink.tableHeaderCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.numberofclasses.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.numberofclasses.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.numberofclasses.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.numberofclasses.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.afferentcouplings.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.afferentcouplings.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.afferentcouplings.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.afferentcouplings.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.efferentcouplings.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.efferentcouplings.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.efferentcouplings.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.efferentcouplings.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.abstractness.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.abstractness.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.abstractness.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.abstractness.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.instability.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.instability.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.instability.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.instability.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.distance.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.distance.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.distance.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.distance.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.tableRow(); sink.tableCell(); - sink.text( bundle.getString( "report.cycles.title" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.cycles.title")); // $NON-NLS-1$ sink.tableCell_(); sink.tableCell(); - sink.text( bundle.getString( "report.cycles.description" ) ); //$NON-NLS-1$ + sink.text(bundle.getString("report.cycles.description")); // $NON-NLS-1$ sink.tableCell_(); sink.tableRow_(); sink.table_(); - } - private String convertToPercent( String value ) - { - return Float.parseFloat( value ) * 100 + "%"; //$NON-NLS-1$ + private String convertToPercent(String value) { + return Float.parseFloat(value) * 100 + "%"; // $NON-NLS-1$ } } diff --git a/src/main/java/org/codehaus/mojo/jdepend/objects/CyclePackage.java b/src/main/java/org/codehaus/mojo/jdepend/objects/CyclePackage.java index 0695e72..a8bf1b5 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/objects/CyclePackage.java +++ b/src/main/java/org/codehaus/mojo/jdepend/objects/CyclePackage.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -26,8 +26,7 @@ /** * @author Who ever this implemented first. */ -public class CyclePackage -{ +public class CyclePackage { private List packageList; private String name; @@ -35,31 +34,24 @@ public class CyclePackage /** * Creates a new instance of Cycles. */ - public CyclePackage() - { - } + public CyclePackage() {} - public List getPackageList() - { - if ( packageList == null ) - { + public List getPackageList() { + if (packageList == null) { packageList = new ArrayList<>(); } return this.packageList; } - public void addPackageList( String object ) - { - getPackageList().add( object ); + public void addPackageList(String object) { + getPackageList().add(object); } - public String getName() - { + public String getName() { return name; } - public void setName( String name ) - { + public void setName(String name) { this.name = name; } } diff --git a/src/main/java/org/codehaus/mojo/jdepend/objects/JDPackage.java b/src/main/java/org/codehaus/mojo/jdepend/objects/JDPackage.java index dd4fef1..fa2c00d 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/objects/JDPackage.java +++ b/src/main/java/org/codehaus/mojo/jdepend/objects/JDPackage.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -26,8 +26,7 @@ /** * @author Who ever this implemented first. */ -public class JDPackage -{ +public class JDPackage { /* Elements */ private Stats stats; @@ -44,81 +43,63 @@ public class JDPackage /** * Creates a new instance of JDPackage. */ - public JDPackage() - { - } + public JDPackage() {} - public String getPackageName() - { + public String getPackageName() { return this.packageName; } - public void setPackageName( String name ) - { + public void setPackageName(String name) { this.packageName = name; } - public Stats getStats() - { + public Stats getStats() { return stats; } - public void setStats( Stats stats ) - { + public void setStats(Stats stats) { this.stats = stats; } - public List getAbstractClasses() - { - if ( abstractClasses == null ) - { + public List getAbstractClasses() { + if (abstractClasses == null) { abstractClasses = new ArrayList<>(); } return abstractClasses; } - public void addAbstractClasses( String object ) - { - getAbstractClasses().add( object ); + public void addAbstractClasses(String object) { + getAbstractClasses().add(object); } - public List getConcreteClasses() - { - if ( concreteClasses == null ) - { + public List getConcreteClasses() { + if (concreteClasses == null) { concreteClasses = new ArrayList<>(); } return concreteClasses; } - public void addConcreteClasses( String object ) - { - getConcreteClasses().add( object ); + public void addConcreteClasses(String object) { + getConcreteClasses().add(object); } - public List getDependsUpon() - { - if ( dependsUpon == null ) - { + public List getDependsUpon() { + if (dependsUpon == null) { dependsUpon = new ArrayList<>(); } return dependsUpon; } - public void addDependsUpon( String object ) - { - getDependsUpon().add( object ); + public void addDependsUpon(String object) { + getDependsUpon().add(object); } - public void addUsedBy( String object ) - { - getUsedBy().add( object ); + public void addUsedBy(String object) { + getUsedBy().add(object); } - public List getUsedBy() - { - if ( usedBy == null ) - { + public List getUsedBy() { + if (usedBy == null) { usedBy = new ArrayList<>(); } return usedBy; diff --git a/src/main/java/org/codehaus/mojo/jdepend/objects/Packages.java b/src/main/java/org/codehaus/mojo/jdepend/objects/Packages.java index b75bcdb..fb93176 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/objects/Packages.java +++ b/src/main/java/org/codehaus/mojo/jdepend/objects/Packages.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -26,24 +26,19 @@ /** * @author Who ever this implemented first. */ -public class Packages -{ +public class Packages { private List jdpackage; /** * Creates a new instance of Packages. */ - public Packages() - { - } + public Packages() {} /** * @return packages. */ - public List getPackages() - { - if ( this.jdpackage == null ) - { + public List getPackages() { + if (this.jdpackage == null) { this.jdpackage = new ArrayList<>(); } @@ -53,17 +48,14 @@ public List getPackages() /** * @param jdpackage The List of JDPackage */ - public void setPackages( List jdpackage ) - { + public void setPackages(List jdpackage) { this.jdpackage = jdpackage; } /** * @param jdpackage Add a single package. */ - public void addPackage( JDPackage jdpackage ) - { - getPackages().add( jdpackage ); + public void addPackage(JDPackage jdpackage) { + getPackages().add(jdpackage); } - } diff --git a/src/main/java/org/codehaus/mojo/jdepend/objects/Stats.java b/src/main/java/org/codehaus/mojo/jdepend/objects/Stats.java index 9634642..11a2ccb 100644 --- a/src/main/java/org/codehaus/mojo/jdepend/objects/Stats.java +++ b/src/main/java/org/codehaus/mojo/jdepend/objects/Stats.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -23,8 +23,7 @@ /** * @author Who ever this implemented first. */ -public class Stats -{ +public class Stats { private String totalClasses; private String concreteClasses; @@ -46,141 +45,123 @@ public class Stats /** * @return total classes. */ - public String getTotalClasses() - { + public String getTotalClasses() { return totalClasses; } /** * @param totalClasses */ - public void setTotalClasses( String totalClasses ) - { + public void setTotalClasses(String totalClasses) { this.totalClasses = totalClasses; } /** * @return concrete classes. */ - public String getConcreteClasses() - { + public String getConcreteClasses() { return concreteClasses; } /** * @param concreteClasses */ - public void setConcreteClasses( String concreteClasses ) - { + public void setConcreteClasses(String concreteClasses) { this.concreteClasses = concreteClasses; } /** * @return get abstract classes. */ - public String getAbstractClasses() - { + public String getAbstractClasses() { return abstractClasses; } /** * @param abstractClasses */ - public void setAbstractClasses( String abstractClasses ) - { + public void setAbstractClasses(String abstractClasses) { this.abstractClasses = abstractClasses; } /** * @return ca. */ - public String getCa() - { + public String getCa() { return ca; } /** * @param ca */ - public void setCa( String ca ) - { + public void setCa(String ca) { this.ca = ca; } /** * @return Ce */ - public String getCe() - { + public String getCe() { return ce; } - public void setCe( String ce ) - { + public void setCe(String ce) { this.ce = ce; } /** * @return A */ - public String getA() - { + public String getA() { return a; } /** * @param a */ - public void setA( String a ) - { + public void setA(String a) { this.a = a; } /** * @return I */ - public String getI() - { + public String getI() { return i; } /** * @param i */ - public void setI( String i ) - { + public void setI(String i) { this.i = i; } /** * @return D */ - public String getD() - { + public String getD() { return d; } /** * @param d */ - public void setD( String d ) - { + public void setD(String d) { this.d = d; } /** * @return V */ - public String getV() - { + public String getV() { return v; } /** * @param v */ - public void setV( String v ) - { + public void setV(String v) { this.v = v; } } diff --git a/src/test/java/org/codehaus/mojo/jdepend/JDependMojoTest.java b/src/test/java/org/codehaus/mojo/jdepend/JDependMojoTest.java index 03e592a..61a4150 100644 --- a/src/test/java/org/codehaus/mojo/jdepend/JDependMojoTest.java +++ b/src/test/java/org/codehaus/mojo/jdepend/JDependMojoTest.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -21,41 +21,34 @@ */ import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Files; import jdepend.xmlui.JDepend; - import org.codehaus.plexus.util.IOUtil; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertTrue; -public class JDependMojoTest -{ +public class JDependMojoTest { JDependXMLReportParser parser; public static final String REPORT_PATH = "target/test-classes/jdepend-report.xml"; - private final String basedir = System.getProperty( "basedir" ); + private final String basedir = System.getProperty("basedir"); - private final File reportXML = new File( basedir, REPORT_PATH ); + private final File reportXML = new File(basedir, REPORT_PATH); @Before - public void setUp() - throws Exception - { - parser = new JDependXMLReportParser( reportXML ); + public void setUp() throws Exception { + parser = new JDependXMLReportParser(reportXML); } @Test - public void testJDependReportContent() - throws IOException - { - File generatedReport = new File( basedir, "target/jdepend-report.xml" ); - File classDirectory = new File( basedir, "target/classes" ); + public void testJDependReportContent() throws IOException { + File generatedReport = new File(basedir, "target/jdepend-report.xml"); + File classDirectory = new File(basedir, "target/classes"); String[] args = new String[3]; @@ -63,10 +56,11 @@ public void testJDependReportContent() args[1] = generatedReport.getCanonicalPath(); args[2] = classDirectory.getCanonicalPath(); - JDepend.main( args ); + JDepend.main(args); - assertTrue( "Generated report xml from " + generatedReport + " is not equal to expected output " + reportXML, - IOUtil.contentEquals(Files.newInputStream(generatedReport.toPath()), Files.newInputStream(reportXML.toPath())) ); + assertTrue( + "Generated report xml from " + generatedReport + " is not equal to expected output " + reportXML, + IOUtil.contentEquals( + Files.newInputStream(generatedReport.toPath()), Files.newInputStream(reportXML.toPath()))); } - } diff --git a/src/test/java/org/codehaus/mojo/jdepend/JDependReportParserTest.java b/src/test/java/org/codehaus/mojo/jdepend/JDependReportParserTest.java index 8820373..6226197 100644 --- a/src/test/java/org/codehaus/mojo/jdepend/JDependReportParserTest.java +++ b/src/test/java/org/codehaus/mojo/jdepend/JDependReportParserTest.java @@ -9,9 +9,9 @@ * Licensed 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. @@ -20,148 +20,128 @@ * #L% */ +import java.io.File; +import java.util.ArrayList; +import java.util.List; + import org.codehaus.mojo.jdepend.objects.JDPackage; import org.codehaus.mojo.jdepend.objects.Stats; import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -public class JDependReportParserTest -{ +public class JDependReportParserTest { private JDependXMLReportParser parser; private List packages; - private final String basedir = System.getProperty( "basedir" ); + private final String basedir = System.getProperty("basedir"); @Before - public void setUp() - throws Exception - { - File reportXML = new File( basedir, JDependMojoTest.REPORT_PATH ); - parser = new JDependXMLReportParser( reportXML ); + public void setUp() throws Exception { + File reportXML = new File(basedir, JDependMojoTest.REPORT_PATH); + parser = new JDependXMLReportParser(reportXML); packages = parser.packages; } @Test - public void testTotalNumberPackages() - { - assertEquals( "Total number of packages is not equal to expected output", 3, parser.packages.size() ); + public void testTotalNumberPackages() { + assertEquals("Total number of packages is not equal to expected output", 3, parser.packages.size()); } @Test - public void testPackageNames() - { + public void testPackageNames() { List packageNames = new ArrayList<>(); - for (JDPackage jdpackage : packages) - { - packageNames.add( jdpackage.getPackageName() ); + for (JDPackage jdpackage : packages) { + packageNames.add(jdpackage.getPackageName()); } - assertTrue( packageNames.contains( "org.codehaus.mojo.jdepend" ) ); - assertTrue( packageNames.contains( "org.codehaus.mojo.jdepend.objects" ) ); + assertTrue(packageNames.contains("org.codehaus.mojo.jdepend")); + assertTrue(packageNames.contains("org.codehaus.mojo.jdepend.objects")); } @Test - public void testPackageNamesNotContainingInList() - { + public void testPackageNamesNotContainingInList() { List packageNames = new ArrayList<>(); - for (JDPackage jdpackage : packages) - { - packageNames.add( jdpackage.getPackageName() ); + for (JDPackage jdpackage : packages) { + packageNames.add(jdpackage.getPackageName()); } - assertFalse( packageNames.contains( "test" ) ); - assertFalse( packageNames.contains( "test2" ) ); + assertFalse(packageNames.contains("test")); + assertFalse(packageNames.contains("test2")); } @Test - public void testStats() - { - for (JDPackage jdpackage : packages) - { - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend" ) ) - { + public void testStats() { + for (JDPackage jdpackage : packages) { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend")) { Stats stats = jdpackage.getStats(); - assertEquals( "Stats Total Classes is not equal to expected output", "5", stats.getTotalClasses() ); - assertEquals( "Stats Concrete classes is not equal to expected output", "4", stats.getConcreteClasses() ); - assertEquals( "Stats Abstract Classes is not equal to expected output", "1", stats.getAbstractClasses() ); - assertEquals( "0", stats.getCa() ); - assertEquals( "13", stats.getCe() ); - assertEquals( "0.2", stats.getA() ); - assertEquals( "1", stats.getI() ); - assertEquals( "0.2", stats.getD() ); - assertEquals( "1", stats.getV() ); + assertEquals("Stats Total Classes is not equal to expected output", "5", stats.getTotalClasses()); + assertEquals("Stats Concrete classes is not equal to expected output", "4", stats.getConcreteClasses()); + assertEquals("Stats Abstract Classes is not equal to expected output", "1", stats.getAbstractClasses()); + assertEquals("0", stats.getCa()); + assertEquals("13", stats.getCe()); + assertEquals("0.2", stats.getA()); + assertEquals("1", stats.getI()); + assertEquals("0.2", stats.getD()); + assertEquals("1", stats.getV()); } - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend.objects" ) ) - { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend.objects")) { Stats stats = jdpackage.getStats(); - assertEquals( "Stats Total Classes is not equal to expected output", "4", stats.getTotalClasses() ); - assertEquals( "Stats Concrete classes is not equal to expected output", "4", stats.getConcreteClasses() ); - assertEquals( "Stats Abstract Classes is not equal to expected output", "0", stats.getAbstractClasses() ); - assertEquals( "1", stats.getCa() ); - assertEquals( "2", stats.getCe() ); - assertEquals( "0", stats.getA() ); - assertEquals( "0.67", stats.getI() ); - assertEquals( "0.33", stats.getD() ); - assertEquals( "1", stats.getV() ); + assertEquals("Stats Total Classes is not equal to expected output", "4", stats.getTotalClasses()); + assertEquals("Stats Concrete classes is not equal to expected output", "4", stats.getConcreteClasses()); + assertEquals("Stats Abstract Classes is not equal to expected output", "0", stats.getAbstractClasses()); + assertEquals("1", stats.getCa()); + assertEquals("2", stats.getCe()); + assertEquals("0", stats.getA()); + assertEquals("0.67", stats.getI()); + assertEquals("0.33", stats.getD()); + assertEquals("1", stats.getV()); } } } @Test - public void testConcreteClasses() - { - for (JDPackage jdpackage : packages) - { - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend" ) ) - { + public void testConcreteClasses() { + for (JDPackage jdpackage : packages) { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend")) { List concretes = jdpackage.getConcreteClasses(); - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.JDependMojo" ) ); - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.JDependXMLReportParser" ) ); - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.ReportGenerator" ) ); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.JDependMojo")); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.JDependXMLReportParser")); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.ReportGenerator")); } - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend.objects" ) ) - { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend.objects")) { List concretes = jdpackage.getConcreteClasses(); - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.objects.CyclePackage" ) ); - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.objects.JDPackage" ) ); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.objects.CyclePackage")); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.objects.JDPackage")); /* * Test failure assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.objects.Packages" ) ); */ - assertTrue( concretes.contains( "org.codehaus.mojo.jdepend.objects.Stats" ) ); + assertTrue(concretes.contains("org.codehaus.mojo.jdepend.objects.Stats")); } } } @Test - public void testCountOfDependsUpon() - { - for (JDPackage jdpackage : packages) - { - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend" ) ) - { + public void testCountOfDependsUpon() { + for (JDPackage jdpackage : packages) { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend")) { int count = jdpackage.getDependsUpon().size(); - assertEquals( 13, count ); + assertEquals(13, count); } - if ( jdpackage.getPackageName().equals( "org.codehaus.mojo.jdepend.objects" ) ) - { + if (jdpackage.getPackageName().equals("org.codehaus.mojo.jdepend.objects")) { int count = jdpackage.getDependsUpon().size(); - assertEquals( 2, count ); + assertEquals(2, count); } } }