Explorar o código

add logic for divided by zero;
remove useless import in callgraph.html

Miaomz %!s(int64=6) %!d(string=hai) anos
pai
achega
c5cad5a46f

+ 5 - 1
src/main/java/com/moekr/moocoder/logic/service/impl/OOPMetricAnalyzer.java

@@ -55,7 +55,11 @@ public class OOPMetricAnalyzer {
             }
 
             Pair<Integer, Integer> pair = walaController.countAbstractness(srcDir, group, Source.CLASS_FILE);
-            double abstractness = pair.fst / (double)pair.snd;
+
+            double abstractness = 0; // if there is no class, there is no abstract class
+            if (pair.snd != 0) {
+                abstractness = pair.fst / (double)pair.snd;
+            }
             List<String> walaOutput = walaController.getWalaOutput(srcDir, dstDir, Source.CLASS_FILE);
             return analyzeMetricExceptAbstractness(walaOutput, group, abstractness);
         } catch (IOException|CallGraphBuilderCancelException e){

+ 0 - 3
src/main/resources/templates/views/callgraph.html

@@ -39,9 +39,6 @@
 
 <svg width="1024" height="640"></svg>
 </body>
-<script type="text/javascript" th:src="@{../../lib/vue/vue.js}"></script>
-<script type="text/javascript" th:src="@{../../lib/vue/vue-resource.js}"></script>
-<script type="text/javascript" th:src="@{../../lib/element-ui/lib/index.js}"></script>
 <script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
 <script>
     function drawCallGraph(id, granularity) {