PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/main/java/com/google/test/metric/LoDViolation.java

http://testability-explorer.googlecode.com/
Java | 45 lines | 21 code | 9 blank | 15 comment | 0 complexity | e6c12385a1cceb925dd1d9e7d17b47e3 MD5 | raw file
 1/*
 2 * Copyright 2007 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric;
17
18
19
20public class LoDViolation extends ViolationCost {
21
22  private final String methodName;
23  private final int distance;
24
25  public LoDViolation(SourceLocation sourceLocation, String methodName, Cost lod, int distance) {
26    super(sourceLocation, lod);
27    this.methodName = methodName;
28    this.distance = distance;
29  }
30
31  @Override
32  public String getDescription() {
33    return methodName + "[distance=" + distance + "]";
34  }
35
36  public String getReason() {
37    return "cost from breaking the Law of Demeter";
38  }
39
40  @Override
41  public void link(Cost directCost, Cost dependentCost, Cost constructorDependentCost) {
42    directCost.add(getCost());
43  }
44
45}