Coverage Report - com.jeantessier.dependencyfinder.cli.DependencyMetrics
 
Classes in this File Line Coverage Branch Coverage Complexity
DependencyMetrics
61%
30/49
N/A
1
 
 1  
 /*
 2  
  *  Copyright (c) 2001-2009, Jean Tessier
 3  
  *  All rights reserved.
 4  
  *  
 5  
  *  Redistribution and use in source and binary forms, with or without
 6  
  *  modification, are permitted provided that the following conditions
 7  
  *  are met:
 8  
  *  
 9  
  *      * Redistributions of source code must retain the above copyright
 10  
  *        notice, this list of conditions and the following disclaimer.
 11  
  *  
 12  
  *      * Redistributions in binary form must reproduce the above copyright
 13  
  *        notice, this list of conditions and the following disclaimer in the
 14  
  *        documentation and/or other materials provided with the distribution.
 15  
  *  
 16  
  *      * Neither the name of Jean Tessier nor the names of his contributors
 17  
  *        may be used to endorse or promote products derived from this software
 18  
  *        without specific prior written permission.
 19  
  *  
 20  
  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 21  
  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 22  
  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 23  
  *  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR
 24  
  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 25  
  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 26  
  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 27  
  *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 28  
  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 29  
  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 30  
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31  
  */
 32  
 
 33  
 package com.jeantessier.dependencyfinder.cli;
 34  
 
 35  
 import java.util.*;
 36  
 
 37  
 import com.jeantessier.commandline.*;
 38  
 import com.jeantessier.dependency.*;
 39  
 
 40  1
 public class DependencyMetrics extends DependencyGraphCommand {
 41  
     protected void populateCommandLineSwitches()  {
 42  20
         super.populateCommandLineSwitches();
 43  
 
 44  20
         populateCommandLineSwitchesForScoping();
 45  20
         populateCommandLineSwitchesForFiltering();
 46  
 
 47  20
         getCommandLine().addAliasSwitch("p2p", "package-scope", "package-filter");
 48  20
         getCommandLine().addAliasSwitch("c2p", "class-scope", "package-filter");
 49  20
         getCommandLine().addAliasSwitch("c2c", "class-scope", "class-filter");
 50  20
         getCommandLine().addAliasSwitch("f2f", "feature-scope", "feature-filter");
 51  20
         getCommandLine().addAliasSwitch("includes", "scope-includes", "filter-includes");
 52  20
         getCommandLine().addAliasSwitch("excludes", "scope-excludes", "filter-excludes");
 53  
 
 54  20
         getCommandLine().addToggleSwitch("list");
 55  20
         getCommandLine().addToggleSwitch("chart-classes-per-package");
 56  20
         getCommandLine().addToggleSwitch("chart-features-per-class");
 57  20
         getCommandLine().addToggleSwitch("chart-inbounds-per-package");
 58  20
         getCommandLine().addToggleSwitch("chart-outbounds-per-package");
 59  20
         getCommandLine().addToggleSwitch("chart-inbounds-per-class");
 60  20
         getCommandLine().addToggleSwitch("chart-outbounds-per-class");
 61  20
         getCommandLine().addToggleSwitch("chart-inbounds-per-feature");
 62  20
         getCommandLine().addToggleSwitch("chart-outbounds-per-feature");
 63  
 
 64  20
         getCommandLine().addAliasSwitch("chart-inbounds", "chart-inbounds-per-package", "chart-inbounds-per-class", "chart-inbounds-per-feature");
 65  20
         getCommandLine().addAliasSwitch("chart-outbounds", "chart-outbounds-per-package", "chart-outbounds-per-class", "chart-outbounds-per-feature");
 66  20
         getCommandLine().addAliasSwitch("chart-packages", "chart-classes-per-package", "chart-inbounds-per-package", "chart-outbounds-per-package");
 67  20
         getCommandLine().addAliasSwitch("chart-classes", "chart-features-per-class", "chart-inbounds-per-class", "chart-outbounds-per-class");
 68  20
         getCommandLine().addAliasSwitch("chart-features", "chart-inbounds-per-feature", "chart-outbounds-per-feature");
 69  20
         getCommandLine().addAliasSwitch("chart-all", "chart-classes-per-package", "chart-features-per-class", "chart-inbounds-per-package", "chart-outbounds-per-package", "chart-inbounds-per-class", "chart-outbounds-per-class", "chart-inbounds-per-feature", "chart-outbounds-per-feature");
 70  20
     }
 71  
 
 72  
     protected Collection<CommandLineException> parseCommandLine(String[] args) {
 73  19
         Collection<CommandLineException> exceptions = super.parseCommandLine(args);
 74  
 
 75  19
         exceptions.addAll(validateCommandLineForScoping());
 76  19
         exceptions.addAll(validateCommandLineForFiltering());
 77  
 
 78  19
         return exceptions;
 79  
     }
 80  
 
 81  
     public void doProcessing() throws Exception {
 82  0
         MetricsReport reporter = new MetricsReport(getOut());
 83  
 
 84  0
         reporter.setListingElements(getCommandLine().getToggleSwitch("list"));
 85  0
         reporter.setChartingClassesPerPackage(getCommandLine().getToggleSwitch("chart-classes-per-package"));
 86  0
         reporter.setChartingFeaturesPerClass(getCommandLine().getToggleSwitch("chart-features-per-class"));
 87  0
         reporter.setChartingInboundsPerPackage(getCommandLine().getToggleSwitch("chart-inbounds-per-package"));
 88  0
         reporter.setChartingOutboundsPerPackage(getCommandLine().getToggleSwitch("chart-outbounds-per-package"));
 89  0
         reporter.setChartingInboundsPerClass(getCommandLine().getToggleSwitch("chart-inbounds-per-class"));
 90  0
         reporter.setChartingOutboundsPerClass(getCommandLine().getToggleSwitch("chart-outbounds-per-class"));
 91  0
         reporter.setChartingInboundsPerFeature(getCommandLine().getToggleSwitch("chart-inbounds-per-feature"));
 92  0
         reporter.setChartingOutboundsPerFeature(getCommandLine().getToggleSwitch("chart-outbounds-per-feature"));
 93  
 
 94  0
         SelectionCriteria scopeCriteria = getScopeCriteria();
 95  0
         SelectionCriteria filterCriteria = getFilterCriteria();
 96  
 
 97  0
         getVerboseListener().print("Generating report ...");
 98  
 
 99  0
         MetricsGatherer metrics = new MetricsGatherer(new SelectiveTraversalStrategy(scopeCriteria, filterCriteria));
 100  0
         metrics.traverseNodes(loadGraph().getPackages().values());
 101  0
         reporter.process(metrics);
 102  0
     }
 103  
 
 104  
     public static void main(String[] args) throws Exception {
 105  0
         new DependencyMetrics().run(args);
 106  0
     }
 107  
 }