summaryrefslogtreecommitdiffstats
path: root/sonar-graph/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-02-04 10:42:21 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-02-04 10:42:21 +0100
commita14a0644c2a27ddec22f23925578a40aa6fa8302 (patch)
treeaa5c078cc8ec7c4e2020960ad9a343fb7e79a16c /sonar-graph/src
parent0f44a42b85093a3dcef64b52f6e15337b119ec88 (diff)
downloadsonarqube-a14a0644c2a27ddec22f23925578a40aa6fa8302.tar.gz
sonarqube-a14a0644c2a27ddec22f23925578a40aa6fa8302.zip
Upgrade copyright headers
Diffstat (limited to 'sonar-graph/src')
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/Cycle.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DirectedGraphAccessor.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/Dsm.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmCell.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmPrinter.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/Edge.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/EdgeFactory.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java214
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/FeedbackEdge.java150
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/StringEdge.java2
-rw-r--r--sonar-graph/src/main/java/org/sonar/graph/StringEdgeFactory.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/CycleTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DirectedGraphTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmScannerTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/FeedbackEdgeTest.java162
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/StringPrintWriter.java2
32 files changed, 292 insertions, 292 deletions
diff --git a/sonar-graph/src/main/java/org/sonar/graph/Cycle.java b/sonar-graph/src/main/java/org/sonar/graph/Cycle.java
index 84353b485d7..0e781641f77 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/Cycle.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/Cycle.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
index df6062ab5ff..36e263f1c4b 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/CycleDetector.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java
index 816a01422bc..ff11699877b 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraph.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraphAccessor.java b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraphAccessor.java
index 219adf38222..7c065fa0149 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DirectedGraphAccessor.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DirectedGraphAccessor.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/Dsm.java b/sonar-graph/src/main/java/org/sonar/graph/Dsm.java
index 1c3527d37ca..0c5939a1767 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/Dsm.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/Dsm.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmCell.java b/sonar-graph/src/main/java/org/sonar/graph/DsmCell.java
index 0e992922c16..404d31ff5ef 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmCell.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmCell.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java b/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java
index 26069308de8..7124619255f 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmManualSorter.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmPrinter.java b/sonar-graph/src/main/java/org/sonar/graph/DsmPrinter.java
index df36cedb936..7a7d8819808 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmPrinter.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmPrinter.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
index 997d5ce9e94..c69a2708e62 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmScanner.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java b/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java
index 715bf8cba6c..aee2709996b 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/DsmTopologicalSorter.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/Edge.java b/sonar-graph/src/main/java/org/sonar/graph/Edge.java
index 1e627b0cc9b..84f968f3d3b 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/Edge.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/Edge.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/EdgeFactory.java b/sonar-graph/src/main/java/org/sonar/graph/EdgeFactory.java
index 935315bbd74..06d137fab24 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/EdgeFactory.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/EdgeFactory.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
index 618d07feb3e..a23cb74c9f0 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/FeedbackCycle.java
@@ -1,107 +1,107 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-
-package org.sonar.graph;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.collect.HashMultiset;
-import com.google.common.collect.Multiset;
-
-public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<FeedbackCycle> {
-
- private List<FeedbackEdge> orderedFeedbackEdges;
- private int totalOccurrencesOfEdgesInCycle;
- private final Cycle cycle;
-
- private FeedbackCycle(Cycle cycle) {
- orderedFeedbackEdges = new ArrayList<FeedbackEdge>();
- totalOccurrencesOfEdgesInCycle = 0;
- this.cycle = cycle;
- }
-
- private void add(FeedbackEdge feedbackEdge) {
- orderedFeedbackEdges.add(feedbackEdge);
- }
-
- public static List<FeedbackCycle> buildFeedbackCycles(Set<Cycle> cycles) {
- Multiset<Edge> edgesBag = createBagWithAllEdgesOfCycles(cycles);
-
- List<FeedbackCycle> feedbackCycles = new ArrayList<FeedbackCycle>();
- for (Cycle cycle : cycles) {
- FeedbackCycle feedbackCycle = new FeedbackCycle(cycle);
- int totalOccurrences = 0;
- for (Edge edge : cycle.getEdges()) {
- FeedbackEdge feedbackEdge = new FeedbackEdge(edge, edgesBag.count(edge));
- feedbackCycle.add(feedbackEdge);
- totalOccurrences += feedbackEdge.getOccurences();
- }
- feedbackCycle.setTotalOccurrencesOfEdgesInCycle(totalOccurrences);
- Collections.sort(feedbackCycle.orderedFeedbackEdges);
- feedbackCycles.add(feedbackCycle);
- }
- Collections.sort(feedbackCycles);
-
- return feedbackCycles;
- }
-
- private static Multiset<Edge> createBagWithAllEdgesOfCycles(Set<Cycle> cycles) {
- Multiset<Edge> edgesBag = HashMultiset.create();
- for (Cycle cycle : cycles) {
- for (Edge edge : cycle.getEdges()) {
- edgesBag.add(edge);
- }
- }
- return edgesBag;
- }
-
- private void setTotalOccurrencesOfEdgesInCycle(int totalOccurrencesOfEdgesInCycle) {
- this.totalOccurrencesOfEdgesInCycle = totalOccurrencesOfEdgesInCycle;
- }
-
- public int getTotalOccurrencesOfEdgesInCycle() {
- return totalOccurrencesOfEdgesInCycle;
- }
-
- public Iterator<FeedbackEdge> iterator() {
- return orderedFeedbackEdges.iterator();
- }
-
- public int compareTo(FeedbackCycle feedbackCycle) {
- if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
- return -1;
- }
- if (getTotalOccurrencesOfEdgesInCycle() == feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
- if (cycle.size() == feedbackCycle.cycle.size()) {
- return orderedFeedbackEdges.get(0).compareTo(feedbackCycle.orderedFeedbackEdges.get(0));
- }
- return cycle.size() - feedbackCycle.cycle.size();
- }
- return 1;
- }
-
- public Cycle getCycle() {
- return cycle;
- }
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Multiset;
+
+public final class FeedbackCycle implements Iterable<FeedbackEdge>, Comparable<FeedbackCycle> {
+
+ private List<FeedbackEdge> orderedFeedbackEdges;
+ private int totalOccurrencesOfEdgesInCycle;
+ private final Cycle cycle;
+
+ private FeedbackCycle(Cycle cycle) {
+ orderedFeedbackEdges = new ArrayList<FeedbackEdge>();
+ totalOccurrencesOfEdgesInCycle = 0;
+ this.cycle = cycle;
+ }
+
+ private void add(FeedbackEdge feedbackEdge) {
+ orderedFeedbackEdges.add(feedbackEdge);
+ }
+
+ public static List<FeedbackCycle> buildFeedbackCycles(Set<Cycle> cycles) {
+ Multiset<Edge> edgesBag = createBagWithAllEdgesOfCycles(cycles);
+
+ List<FeedbackCycle> feedbackCycles = new ArrayList<FeedbackCycle>();
+ for (Cycle cycle : cycles) {
+ FeedbackCycle feedbackCycle = new FeedbackCycle(cycle);
+ int totalOccurrences = 0;
+ for (Edge edge : cycle.getEdges()) {
+ FeedbackEdge feedbackEdge = new FeedbackEdge(edge, edgesBag.count(edge));
+ feedbackCycle.add(feedbackEdge);
+ totalOccurrences += feedbackEdge.getOccurences();
+ }
+ feedbackCycle.setTotalOccurrencesOfEdgesInCycle(totalOccurrences);
+ Collections.sort(feedbackCycle.orderedFeedbackEdges);
+ feedbackCycles.add(feedbackCycle);
+ }
+ Collections.sort(feedbackCycles);
+
+ return feedbackCycles;
+ }
+
+ private static Multiset<Edge> createBagWithAllEdgesOfCycles(Set<Cycle> cycles) {
+ Multiset<Edge> edgesBag = HashMultiset.create();
+ for (Cycle cycle : cycles) {
+ for (Edge edge : cycle.getEdges()) {
+ edgesBag.add(edge);
+ }
+ }
+ return edgesBag;
+ }
+
+ private void setTotalOccurrencesOfEdgesInCycle(int totalOccurrencesOfEdgesInCycle) {
+ this.totalOccurrencesOfEdgesInCycle = totalOccurrencesOfEdgesInCycle;
+ }
+
+ public int getTotalOccurrencesOfEdgesInCycle() {
+ return totalOccurrencesOfEdgesInCycle;
+ }
+
+ public Iterator<FeedbackEdge> iterator() {
+ return orderedFeedbackEdges.iterator();
+ }
+
+ public int compareTo(FeedbackCycle feedbackCycle) {
+ if (getTotalOccurrencesOfEdgesInCycle() < feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
+ return -1;
+ }
+ if (getTotalOccurrencesOfEdgesInCycle() == feedbackCycle.getTotalOccurrencesOfEdgesInCycle()) {
+ if (cycle.size() == feedbackCycle.cycle.size()) {
+ return orderedFeedbackEdges.get(0).compareTo(feedbackCycle.orderedFeedbackEdges.get(0));
+ }
+ return cycle.size() - feedbackCycle.cycle.size();
+ }
+ return 1;
+ }
+
+ public Cycle getCycle() {
+ return cycle;
+ }
+}
diff --git a/sonar-graph/src/main/java/org/sonar/graph/FeedbackEdge.java b/sonar-graph/src/main/java/org/sonar/graph/FeedbackEdge.java
index 53fe8918583..60e60fc4cc6 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/FeedbackEdge.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/FeedbackEdge.java
@@ -1,75 +1,75 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.graph;
-
-public class FeedbackEdge implements Comparable<FeedbackEdge> {
-
- private Edge edge;
- private double relativeWeight;
- private int occurences;
- private final int hashcode;
-
- public FeedbackEdge(Edge edge, int occurences) {
- this.edge = edge;
- this.hashcode = edge.hashCode();
- this.occurences = occurences;
- this.relativeWeight = (double) edge.getWeight() / occurences;
- }
-
- protected Edge getEdge() {
- return edge;
- }
-
- protected int getWeight() {
- return edge.getWeight();
- }
-
- protected double getRelativeWeight() {
- return relativeWeight;
- }
-
- protected int getOccurences() {
- return occurences;
- }
-
- public int compareTo(FeedbackEdge feedbackEdge) {
- if (this.getRelativeWeight() < feedbackEdge.getRelativeWeight()) {
- return -1;
- }
- if (this.getRelativeWeight() == feedbackEdge.getRelativeWeight()) {
- return this.getEdge().getFrom().toString().compareTo(feedbackEdge.getEdge().getFrom().toString());
- }
- return 1;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof FeedbackEdge) || this.hashCode() != obj.hashCode()) {
- return false;
- }
- FeedbackEdge otherEdge = (FeedbackEdge) obj;
- return edge.equals(otherEdge.edge);
- }
-
- @Override
- public int hashCode() {
- return hashcode;
- }
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.graph;
+
+public class FeedbackEdge implements Comparable<FeedbackEdge> {
+
+ private Edge edge;
+ private double relativeWeight;
+ private int occurences;
+ private final int hashcode;
+
+ public FeedbackEdge(Edge edge, int occurences) {
+ this.edge = edge;
+ this.hashcode = edge.hashCode();
+ this.occurences = occurences;
+ this.relativeWeight = (double) edge.getWeight() / occurences;
+ }
+
+ protected Edge getEdge() {
+ return edge;
+ }
+
+ protected int getWeight() {
+ return edge.getWeight();
+ }
+
+ protected double getRelativeWeight() {
+ return relativeWeight;
+ }
+
+ protected int getOccurences() {
+ return occurences;
+ }
+
+ public int compareTo(FeedbackEdge feedbackEdge) {
+ if (this.getRelativeWeight() < feedbackEdge.getRelativeWeight()) {
+ return -1;
+ }
+ if (this.getRelativeWeight() == feedbackEdge.getRelativeWeight()) {
+ return this.getEdge().getFrom().toString().compareTo(feedbackEdge.getEdge().getFrom().toString());
+ }
+ return 1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof FeedbackEdge) || this.hashCode() != obj.hashCode()) {
+ return false;
+ }
+ FeedbackEdge otherEdge = (FeedbackEdge) obj;
+ return edge.equals(otherEdge.edge);
+ }
+
+ @Override
+ public int hashCode() {
+ return hashcode;
+ }
+}
diff --git a/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java b/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java
index 3fde2eaa2e8..051cdc92f1d 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/IncrementalCyclesAndFESSolver.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java
index 2c27caad174..a37c358188b 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/MinimumFeedbackEdgeSetSolver.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/StringEdge.java b/sonar-graph/src/main/java/org/sonar/graph/StringEdge.java
index bd11d99adfd..97b773ea330 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/StringEdge.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/StringEdge.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/main/java/org/sonar/graph/StringEdgeFactory.java b/sonar-graph/src/main/java/org/sonar/graph/StringEdgeFactory.java
index c576b5a47ef..c3b44890943 100644
--- a/sonar-graph/src/main/java/org/sonar/graph/StringEdgeFactory.java
+++ b/sonar-graph/src/main/java/org/sonar/graph/StringEdgeFactory.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java b/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java
index dd010d64d4b..7ca0fd8747d 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/CycleDetectorTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/CycleTest.java b/sonar-graph/src/test/java/org/sonar/graph/CycleTest.java
index a42366abbab..4b666acb4c2 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/CycleTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/CycleTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DirectedGraphTest.java b/sonar-graph/src/test/java/org/sonar/graph/DirectedGraphTest.java
index 0abcb4c9af2..3e7b9a117a1 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DirectedGraphTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DirectedGraphTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java
index 12069d2dc88..24fd45df840 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java
index 617abe383f6..8d57aacfc0e 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmManualSorterTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java
index 55e8de64de6..40d2d22c18e 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmPrinterTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmScannerTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmScannerTest.java
index 1d9df9239d4..9efb36566aa 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmScannerTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmScannerTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmTest.java
index 06fbcba4160..c070457ee0c 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java
index f017d32dc23..2a67b72cd9f 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/DsmTopologicalSorterTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java b/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java
index ea3ee61fe69..6a63b04ac67 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/FeedbackCycleTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/FeedbackEdgeTest.java b/sonar-graph/src/test/java/org/sonar/graph/FeedbackEdgeTest.java
index 67ba883635b..f865db73c44 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/FeedbackEdgeTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/FeedbackEdgeTest.java
@@ -1,81 +1,81 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.graph;
-
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-
-public class FeedbackEdgeTest {
-
- @Test
- public void testWeights() {
- FeedbackEdge fEdge = mockFeedbackEdge(14, 2);
- assertThat(fEdge.getWeight(), is(14));
- assertThat(fEdge.getRelativeWeight(), is(7.0));
- assertThat(fEdge.getOccurences(), is(2));
- }
-
- @Test
- public void testCompareTo() {
- FeedbackEdge feedbackEdge1;
- FeedbackEdge feedbackEdge2;
- FeedbackEdge feedbackEdge3;
-
- feedbackEdge1 = mockFeedbackEdge(14, 2);
- feedbackEdge2 = mockFeedbackEdge(10, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
-
- feedbackEdge1 = mockFeedbackEdge(10, 2);
- feedbackEdge2 = mockFeedbackEdge(14, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
-
- feedbackEdge1 = mockFeedbackEdge(14, 2);
- feedbackEdge2 = mockFeedbackEdge(14, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(0));
-
- feedbackEdge1 = mockFeedbackEdge(14, 2);
- feedbackEdge2 = mockFeedbackEdge(13, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
-
- feedbackEdge1 = mockFeedbackEdge(13, 2);
- feedbackEdge2 = mockFeedbackEdge(14, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
-
- feedbackEdge1 = mockFeedbackEdge("A", "B", 14, 2);
- feedbackEdge2 = mockFeedbackEdge("B", "C", 14, 2);
- feedbackEdge3 = mockFeedbackEdge("C", "A", 14, 2);
- assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
- assertThat(feedbackEdge2.compareTo(feedbackEdge3), is(-1));
- assertThat(feedbackEdge3.compareTo(feedbackEdge1), greaterThan(1));
- }
-
- private FeedbackEdge mockFeedbackEdge(int weight, int occurrences) {
- return mockFeedbackEdge("from", "to", weight, occurrences);
- }
-
- private FeedbackEdge mockFeedbackEdge(String from, String to, int weight, int occurrences) {
- Edge edge = new StringEdge(from, to, weight);
- return new FeedbackEdge(edge, occurrences);
- }
-
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.graph;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+
+public class FeedbackEdgeTest {
+
+ @Test
+ public void testWeights() {
+ FeedbackEdge fEdge = mockFeedbackEdge(14, 2);
+ assertThat(fEdge.getWeight(), is(14));
+ assertThat(fEdge.getRelativeWeight(), is(7.0));
+ assertThat(fEdge.getOccurences(), is(2));
+ }
+
+ @Test
+ public void testCompareTo() {
+ FeedbackEdge feedbackEdge1;
+ FeedbackEdge feedbackEdge2;
+ FeedbackEdge feedbackEdge3;
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(10, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
+
+ feedbackEdge1 = mockFeedbackEdge(10, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(0));
+
+ feedbackEdge1 = mockFeedbackEdge(14, 2);
+ feedbackEdge2 = mockFeedbackEdge(13, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(1));
+
+ feedbackEdge1 = mockFeedbackEdge(13, 2);
+ feedbackEdge2 = mockFeedbackEdge(14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+
+ feedbackEdge1 = mockFeedbackEdge("A", "B", 14, 2);
+ feedbackEdge2 = mockFeedbackEdge("B", "C", 14, 2);
+ feedbackEdge3 = mockFeedbackEdge("C", "A", 14, 2);
+ assertThat(feedbackEdge1.compareTo(feedbackEdge2), is(-1));
+ assertThat(feedbackEdge2.compareTo(feedbackEdge3), is(-1));
+ assertThat(feedbackEdge3.compareTo(feedbackEdge1), greaterThan(1));
+ }
+
+ private FeedbackEdge mockFeedbackEdge(int weight, int occurrences) {
+ return mockFeedbackEdge("from", "to", weight, occurrences);
+ }
+
+ private FeedbackEdge mockFeedbackEdge(String from, String to, int weight, int occurrences) {
+ Edge edge = new StringEdge(from, to, weight);
+ return new FeedbackEdge(edge, occurrences);
+ }
+
+}
diff --git a/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java b/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java
index 3b11829819c..d9a9e4b58f3 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/IncrementalCyclesAndFESSolverTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java b/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java
index 704b8f83402..b20683d45c0 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/MinimumFeedbackEdgeSetSolverTest.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
diff --git a/sonar-graph/src/test/java/org/sonar/graph/StringPrintWriter.java b/sonar-graph/src/test/java/org/sonar/graph/StringPrintWriter.java
index 3beddf48215..e76a21403b2 100644
--- a/sonar-graph/src/test/java/org/sonar/graph/StringPrintWriter.java
+++ b/sonar-graph/src/test/java/org/sonar/graph/StringPrintWriter.java
@@ -1,6 +1,6 @@
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
+ * Copyright (C) 2008-2011 SonarSource
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or