public void saveDesign(Project sonarProject) { Collection<Resource> directories = resourceMapping.directories(); TimeProfiler profiler = new TimeProfiler(LOG).start("Package design analysis"); LOG.debug("{} packages to analyze", directories.size()); IncrementalCyclesAndFESSolver<Resource> cyclesAndFESSolver = new IncrementalCyclesAndFESSolver<>(graph, directories); LOG.debug("{} cycles", cyclesAndFESSolver.getCycles().size()); Set<Edge> feedbackEdges = cyclesAndFESSolver.getFeedbackEdgeSet(); LOG.debug("{} feedback edges", feedbackEdges.size()); int tangles = cyclesAndFESSolver.getWeightOfFeedbackEdgeSet(); saveIssues(feedbackEdges); saveDependencies(); savePositiveMeasure( sonarProject, CoreMetrics.PACKAGE_CYCLES, cyclesAndFESSolver.getCycles().size()); savePositiveMeasure(sonarProject, CoreMetrics.PACKAGE_FEEDBACK_EDGES, feedbackEdges.size()); savePositiveMeasure(sonarProject, CoreMetrics.PACKAGE_TANGLES, tangles); savePositiveMeasure( sonarProject, CoreMetrics.PACKAGE_EDGES_WEIGHT, getEdgesWeight(directories)); String dsmJson = serializeDsm(graph, directories, feedbackEdges); Measure dsmMeasure = new Measure(CoreMetrics.DEPENDENCY_MATRIX, dsmJson) .setPersistenceMode(PersistenceMode.DATABASE); context.saveMeasure(sonarProject, dsmMeasure); profiler.stop(); for (Resource sonarPackage : directories) { onPackage(sonarPackage); } }
private void onPackage(Resource sonarPackage) { Collection<Resource> squidFiles = getResourcesForDirectory(sonarPackage); if (squidFiles != null && !squidFiles.isEmpty()) { IncrementalCyclesAndFESSolver<Resource> cycleDetector = new IncrementalCyclesAndFESSolver<>(graph, squidFiles); Set<Cycle> cycles = cycleDetector.getCycles(); MinimumFeedbackEdgeSetSolver solver = new MinimumFeedbackEdgeSetSolver(cycles); Set<Edge> feedbackEdges = solver.getEdges(); int tangles = solver.getWeightOfFeedbackEdgeSet(); savePositiveMeasure(sonarPackage, CoreMetrics.FILE_CYCLES, cycles.size()); savePositiveMeasure(sonarPackage, CoreMetrics.FILE_FEEDBACK_EDGES, feedbackEdges.size()); savePositiveMeasure(sonarPackage, CoreMetrics.FILE_TANGLES, tangles); savePositiveMeasure(sonarPackage, CoreMetrics.FILE_EDGES_WEIGHT, getEdgesWeight(squidFiles)); String dsmJson = serializeDsm(graph, squidFiles, feedbackEdges); context.saveMeasure(sonarPackage, new Measure(CoreMetrics.DEPENDENCY_MATRIX, dsmJson)); } }