public String key() { return r.getEffectiveKey(); }
public BatchComponent get(Resource resource) { return components.get(resource.getEffectiveKey()); }
@CheckForNull public BatchResource get(Resource resource) { if (!(resource instanceof Library)) { return resources.get(resource.getEffectiveKey()); } else { return libraries.get(resource); } }
public BatchComponent add(Resource resource, @Nullable Resource parentResource) { String componentKey = resource.getEffectiveKey(); Preconditions.checkState(!Strings.isNullOrEmpty(componentKey), "Missing resource effective key"); BatchComponent parent = parentResource != null ? get(parentResource.getEffectiveKey()) : null; BatchComponent batchComponent = new BatchComponent(components.size() + 1, resource, parent); components.put(componentKey, batchComponent); if (parent == null) { root = batchComponent; } return batchComponent; }
@Override public String saveResource(Resource resource) { Resource persistedResource = index.addResource(resource); if (persistedResource != null) { return persistedResource.getEffectiveKey(); } return null; }
@Override public String saveResource(Resource resource) { Resource persistedResource = index.addResource(resource); if (persistedResource != null) { return persistedResource.getEffectiveKey(); } return null; }
public void addResource(Resource model, Set<Integer> noSonarLines) { if (model != null && noSonarLines != null) { // Reload resource to handle backward compatibility of resource keys Resource resource = sonarIndex.getResource(model); if (resource != null) { noSonarLinesByKey.put(resource.getEffectiveKey(), noSonarLines); } } }
public Iterable<Measure> byMetric(Resource r, String metricKey) { return byMetric(r.getEffectiveKey(), metricKey); }
public MeasureCache put(Resource resource, Measure measure) { Preconditions.checkNotNull(resource.getEffectiveKey()); Preconditions.checkNotNull(measure.getMetricKey()); cache.put(resource.getEffectiveKey(), measure.getMetricKey(), computeMeasureKey(measure), measure); return this; }
public boolean contains(Resource resource, Measure measure) { Preconditions.checkNotNull(resource.getEffectiveKey()); Preconditions.checkNotNull(measure.getMetricKey()); return cache.containsKey(resource.getEffectiveKey(), measure.getMetricKey(), computeMeasureKey(measure)); }
public boolean contains(Resource resource, Measure measure) { Preconditions.checkNotNull(resource.getEffectiveKey()); Preconditions.checkNotNull(measure.getMetricKey()); return cache.containsKey(resource.getEffectiveKey(), measure.getMetricKey(), computeMeasureKey(measure)); }
public MeasureCache put(Resource resource, Measure measure) { Preconditions.checkNotNull(resource.getEffectiveKey()); Preconditions.checkNotNull(measure.getMetricKey()); cache.put(resource.getEffectiveKey(), measure.getMetricKey(), computeMeasureKey(measure), measure); return this; }
private <M> Collection<Measure> getMeasuresOfASingleMetric(MeasuresFilter<M> filter) { Collection<Measure> unfiltered; String metricKey = ((MeasuresFilters.MetricFilter<M>) filter).filterOnMetricKey(); if (CoreMetrics.DUPLICATIONS_DATA_KEY.equals(metricKey)) { // Hack for SONAR-5765 Iterable<DefaultDuplication> group = duplicationCache.byComponent(resource.getEffectiveKey()); unfiltered = Arrays.asList(new Measure(CoreMetrics.DUPLICATIONS_DATA, DuplicationUtils.toXml(group))); } else { // optimization unfiltered = measuresByMetric.get(metricKey); } return unfiltered; }
public ResourceNode(Resource sonarResource, @Nullable File path, Charset encoding) { this.path = path; this.encoding = encoding; this.key = sonarResource.getEffectiveKey(); this.name = sonarResource.getName(); this.longName = sonarResource.getLongName(); this.scope = sonarResource.getScope(); }
public List<Object[]> getPastMeasures(Resource resource, PastSnapshot projectPastSnapshot) { if (projectPastSnapshot != null && projectPastSnapshot.getProjectSnapshot() != null) { return getPastMeasures(resource.getEffectiveKey(), resource.getPath(), projectPastSnapshot.getProjectSnapshot()); } return Collections.emptyList(); }
@CheckForNull public InputPath getInputPath(BatchResource component) { if (component.isFile()) { return getFile(component.parent().parent().resource().getEffectiveKey(), component.resource().getPath()); } else if (component.isDir()) { return getDir(component.parent().parent().resource().getEffectiveKey(), component.resource().getPath()); } return null; }
private CommentLinesVisitor createCommentLineVisitorAndFindNoSonar(JavaFileScannerContext context) { CommentLinesVisitor commentLinesVisitor = new CommentLinesVisitor(); commentLinesVisitor.analyzeCommentLines(context.getTree()); noSonarFilter.addComponent(sensorContext.getResource(sonarFile).getEffectiveKey(), commentLinesVisitor.noSonarLines()); return commentLinesVisitor; }
public void saveEvent(Resource resource, Event event) { BatchResource batchResource = resourceCache.get(resource.getEffectiveKey()); checkState(batchResource != null, "Unknown component: " + resource); event.setCreatedAt(new Date(system2.now())); if (event.getDate() == null) { event.setSnapshot(batchResource.snapshot()); } else { event.setResourceId(batchResource.resource().getId()); } session.save(event); session.commit(); } }
void persistConfiguration(Resource module) { List<PastSnapshot> pastSnapshots = timeMachineConfiguration.getProjectPastSnapshots(); Snapshot projectSnapshot = resourceCache.get(module.getEffectiveKey()).snapshot(); for (PastSnapshot pastSnapshot : pastSnapshots) { Snapshot snapshot = session.reattach(Snapshot.class, projectSnapshot.getId()); updatePeriodParams(snapshot, pastSnapshot); updatePeriodParams(projectSnapshot, pastSnapshot); session.save(snapshot); } session.commit(); }
private DefaultIssue newIssue(Violation violation) { return new DefaultIssueBuilder() .componentKey(violation.getResource().getEffectiveKey()) // Project can be null but Violation not used by scan2 .projectKey(project.getRoot().getEffectiveKey()) .ruleKey(RuleKey.of(violation.getRule().getRepositoryKey(), violation.getRule().getKey())) .effortToFix(violation.getCost()) .line(violation.getLineId()) .message(violation.getMessage()) .severity(violation.getSeverity() != null ? violation.getSeverity().name() : null) .build(); }