/** * {@inheritDoc} */ public Collection<SourceCode> getProjects() { ArrayList<SourceCode> result = Lists.newArrayList(); for (Resource resource : sonar.findAll(new ResourceQuery())) { result.add(new RemoteSourceCode(resource.getKey(), resource.getName()).setRemoteSonarIndex(this)); } return result; }
private void loadMeasures(Resource resource) { ResourceQuery query = ResourceQuery.createForMetrics(resource.getKey(), metrics).setVerbose(true); Sonar.getInstance().find(query, new AbstractCallback<Resource>() { @Override protected void doOnResponse(Resource resource) { display(header, resource); } }); }
/** * {@inheritDoc} */ public Set<SourceCode> getChildren() { if (children == null) { ResourceQuery query = new ResourceQuery().setDepth(1).setResourceKeyOrId(getKey()); Collection<Resource> resources = index.getSonar().findAll(query); children = new HashSet<SourceCode>(); for (Resource resource : resources) { children.add(new RemoteSourceCode(resource.getKey(), resource.getName()).setRemoteSonarIndex(index)); } } return children; }
Project childProject = initializeProject(childNode.getKey()); project.getSubprojects().add(childProject);
/** * A FileInfo object could contain information about violations, ccn or * duplications, this cases are distinguished in function of content param, * and defined by project context. * * @param fileNode * DOM Node that contains file info * @param content * Type of content */ public static void initFromNode(final FileInfo fileInfo, final Resource fileNode, final int content) { fileInfo.setKey(fileNode.getKey()); fileInfo.setName(fileNode.getName()); if (content == FileInfo.VIOLATIONS_CONTENT) { fileInfo.setViolations(fileNode.getMeasure(MetricKeys.VIOLATIONS) .getFormattedValue()); } else if (content == FileInfo.CCN_CONTENT) { fileInfo.setComplexity(fileNode.getMeasure(MetricKeys.COMPLEXITY) .getFormattedValue()); } else if (content == FileInfo.DUPLICATIONS_CONTENT) { fileInfo.setDuplicatedLines(fileNode.getMeasure( MetricKeys.DUPLICATED_LINES).getFormattedValue()); } }