private void initMostComplexElements(final Project project) throws IOException { LOG.info(" Retrieving most complex elements"); LOG.debug("Accessing Sonar: getting most complex elements"); ResourceQuery resourceQuery = ResourceQuery.createForMetrics( project.getKey(), MetricKeys.COMPLEXITY); resourceQuery.setScopes("FIL"); resourceQuery.setDepth(-1); resourceQuery.setLimit(5); List<Resource> resources = sonar.findAll(resourceQuery); project.setMostComplexFiles(FileInfoBuilder.initFromDocument(resources, FileInfo.CCN_CONTENT)); }
private void initMostDuplicatedFiles(final Project project) throws IOException { LOG.info(" Retrieving most duplicated files"); LOG.debug("Accessing Sonar: getting most duplicated files"); ResourceQuery resourceQuery = ResourceQuery.createForMetrics( project.getKey(), MetricKeys.DUPLICATED_LINES); resourceQuery.setScopes("FIL"); resourceQuery.setDepth(-1); resourceQuery.setLimit(5); List<Resource> resources = sonar.findAll(resourceQuery); project.setMostDuplicatedFiles(FileInfoBuilder.initFromDocument(resources, FileInfo.DUPLICATIONS_CONTENT)); }
private void initMostViolatedFiles(final Project project) throws IOException { LOG.info(" Retrieving most violated files"); LOG.debug("Accessing Sonar: getting most violated files"); ResourceQuery resourceQuery = ResourceQuery.createForMetrics( project.getKey(), MetricKeys.VIOLATIONS); resourceQuery.setScopes("FIL"); resourceQuery.setDepth(-1); resourceQuery.setLimit(5); List<Resource> resources = sonar.findAll(resourceQuery); List<FileInfo> fileInfoList = FileInfoBuilder.initFromDocument(resources, FileInfo.VIOLATIONS_CONTENT); project.setMostViolatedFiles(fileInfoList); }
private void initMostViolatedRules(final Project project) throws IOException, ReportException { LOG.info(" Retrieving most violated rules"); LOG.debug("Accessing Sonar: getting most violated rules"); String[] priorities = Priority.getPrioritiesArray(); // Reverse iteration to get violations with upper level first int limit = 10; for (int i = priorities.length - 1; i >= 0 && limit > 0; i--) { ResourceQuery query = ResourceQuery.create(project.getKey()); query.setDepth(0); query.setLimit(limit); query.setMetrics(UrlPath.getViolationsLevelPath(priorities[i])); // "&filter_rules=false&filter_rules_cats=true" ?? query.setExcludeRules(false); // query.setExcludeRuleCategories(true); Resource mostViolatedRulesByLevel = sonar.find(query); if (mostViolatedRulesByLevel != null) { int count = initMostViolatedRulesFromNode(project, mostViolatedRulesByLevel); LOG.debug("\t " + count + " " + priorities[i] + " violations"); limit = limit - count; } else { LOG.debug("There is not result on select //resources/resource"); LOG.debug("There are no violations with level " + priorities[i]); } } }