Package com.google.test.metric

Examples of com.google.test.metric.Cost


    SourceLocation location = new SourceLocation("com/google/FooClass.java", 1);
    final Issue issue =
        new Issue(location, "void doThing()", 0.5f, IssueType.CONSTRUCTION, IssueSubType.SETTER);
    final MethodCost methodCost = new MethodCost("", "void setUp()", 1, false, false, false);
    methodCost.addCostSource(new MethodInvocationCost(location, methodCost,
        Reason.IMPLICIT_SETTER, new Cost(100, 1, new int[0])));

    //TODO: looks like we want IssuesReporter to be an interface
    IssuesReporter issuesReporter = new IssuesReporter(null, null) {
      @Override
      public List<ClassIssues> getMostImportantIssues() {
View Full Code Here


  public void test2DeepSupress0Cost() throws Exception {
    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 2);
    methodCost1.addCostSource(new MethodInvocationCost(new SourceLocation(null, 8), methodCost0,
        NON_OVERRIDABLE_METHOD_CALL, new Cost()));
    methodCost1.addCostSource(new MethodInvocationCost(new SourceLocation(null, 13), methodCost3,
        NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(3)));
    methodCost1.link();
    printer.print("", methodCost1, MAX_VALUE);
    assertStringEquals("c.g.t.A.method1()V [CC: 4 / CC: 1]\n" +
View Full Code Here

    DrillDownReportGenerator printer =
      new DrillDownReportGenerator(new PrintStream(out), costModel, null, MAX_VALUE, 0);
    methodCost3.addCostSource(new MethodInvocationCost(new SourceLocation(null, 1), methodCost2,
        NON_OVERRIDABLE_METHOD_CALL, Cost.cyclomatic(2)));
    methodCost2.addCostSource(new MethodInvocationCost(new SourceLocation(null, 2), methodCost2,
        NON_OVERRIDABLE_METHOD_CALL, new Cost()));
    methodCost3.link();
    printer.print("", methodCost3, 10);
    assertStringEquals("c.g.t.A.method3()V [CC: 5 / CC: 3]\n" +
      "  line 1: c.g.t.A.method2()V [CC: 2 / CC: 2] " + NON_OVERRIDABLE_METHOD_CALL + "\n",
      out.toString());
View Full Code Here

  private int computeClassWithoutMethod(ClassCost classCost, MethodCost adjustedMethod,
                                        Cost replacementCost) {

    WeightedAverage average = costModel.createWeighedAverage();
    for (MethodCost methodCost : classCost.getMethods()) {
      Cost cost = (adjustedMethod == methodCost ? replacementCost : methodCost.getTotalCost());
      average.addValue(costModel.computeOverall(cost));
    }
    return (int) average.getAverage();
  }
View Full Code Here

    return (int) average.getAverage();
  }

  public float computeContributionFromIssue(ClassCost classCost, MethodCost violationMethodCost,
                                            ViolationCost violationCost) {
    Cost adjustedCost = violationMethodCost.getTotalCost().add(violationCost.getCost().negate());
    WeightedAverage average = costModel.createWeighedAverage();
    for (MethodCost methodCost : classCost.getMethods()) {
      Cost cost = (violationMethodCost == methodCost ? adjustedCost : methodCost.getTotalCost());
      average.addValue(costModel.computeOverall(cost));
    }
    return 1 - (int) average.getAverage() / (float) computeClass(classCost);
  }
View Full Code Here

      if (model instanceof SimpleNumber) {
        SimpleNumber number = (SimpleNumber) model;
        return "" + number;
      } else if (model instanceof BeanModel) {
        BeanModel arg0 = (BeanModel) model;
        Cost cost = (Cost) arg0.getAdaptedObject(Cost.class);
        return "Cost: " + costModel.computeOverall(cost) + " [" + cost + "]";
      } else {
        throw new IllegalStateException();
      }
    }
View Full Code Here

      if (model instanceof SimpleNumber) {
        SimpleNumber number = (SimpleNumber) model;
        return number;
      } else if (model instanceof BeanModel) {
        BeanModel arg0 = (BeanModel) model;
        Cost cost = (Cost) arg0.getAdaptedObject(Cost.class);
        return costModel.computeOverall(cost);
      } else {
        throw new IllegalStateException();
      }
    }
View Full Code Here

TOP

Related Classes of com.google.test.metric.Cost

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.