@Override public void reportIssue(JavaCheck check, Resource resource, String message, int line) { if (sonarComponents != null) { sonarComponents.addIssue(new File(resource.getPath()), check, line, message, null); } }
@Override public Measure saveMeasure(Resource resource, Metric metric, Double value) { Measure<?> measure = new Measure(metric, value); coverageFilter.validate(measure, resource.getPath()); return saveMeasure(resource, measure); }
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(); }
@Override public void decorate(Resource resource, DecoratorContext context) { if (!ResourceUtils.isPersistable(resource)) { return; } File path = null; if (ResourceUtils.isProject(resource)) { path = fs.baseDir(); } else if (resource.getPath() != null) { path = new File(fs.baseDir(), resource.getPath()); } ResourceNode resourceNode = new ResourceNode(resource, path, fs.sourceCharset()); RESOURCE_BY_KEY.put(resource.getEffectiveKey(), resourceNode); for (DecoratorContext childContext : context.getChildren()) { Resource child = childContext.getResource(); ResourceNode childNode = RESOURCE_BY_KEY.get(child.getEffectiveKey()); if (childNode != null) { resourceNode.addChild(childNode); } } }
@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; }
static void mergeModel(ResourceModel model, Resource resource) { model.setEnabled(true); model.setKey(resource.getEffectiveKey()); if (StringUtils.isNotBlank(resource.getName())) { model.setName(resource.getName()); } if (StringUtils.isNotBlank(resource.getLongName())) { model.setLongName(resource.getLongName()); } if (StringUtils.isNotBlank(resource.getDescription())) { model.setDescription(resource.getDescription()); } if (StringUtils.isNotBlank(resource.getPath())) { model.setPath(resource.getPath()); } if (!ResourceUtils.isLibrary(resource)) { model.setScope(resource.getScope()); model.setQualifier(resource.getQualifier()); } Language language = resource.getLanguage(); if (language != null) { model.setLanguageKey(language.getKey()); } } }
public Iterable<ServerIssue> byComponent(BatchResource component) { if (analysisMode.isIncremental()) { if (!component.isFile()) { throw new UnsupportedOperationException("Incremental mode should only get issues on files"); } InputFile inputFile = (InputFile) inputPathCache.getInputPath(component); if (inputFile.status() == Status.ADDED) { return Collections.emptyList(); } Profiler profiler = Profiler.create(LOG).startInfo("Load server issues for " + component.resource().getPath()); final List<ServerIssue> result = new ArrayList<>(); previousIssuesLoader.load(component.key(), new Function<ServerIssue, Void>() { @Override public Void apply(@Nullable ServerIssue issue) { if (issue == null) { return null; } result.add(issue); return null; } }, true); profiler.stopDebug(); return result; } else { return issuesCache.values(component.batchId()); } }
ResourceModel createModel(Resource resource, @Nullable Resource parentResource) { ResourceModel model = new ResourceModel(); model.setEnabled(Boolean.TRUE); model.setDescription(resource.getDescription()); model.setKey(resource.getEffectiveKey()); model.setUuid(Uuids.create()); model.setPath(resource.getPath()); Language language = resource.getLanguage(); if (language != null) { model.setLanguageKey(language.getKey()); } if (StringUtils.isNotBlank(resource.getName())) { model.setName(resource.getName()); } else { model.setName(resource.getKey()); } model.setLongName(resource.getLongName()); model.setScope(resource.getScope()); model.setQualifier(resource.getQualifier()); return model; }
/** * Maps a resource to a resource model and returns the resource */ public static ResourceModel build(Resource resource) { ResourceModel model = new ResourceModel(); model.setEnabled(Boolean.TRUE); model.setDescription(resource.getDescription()); model.setKey(resource.getEffectiveKey()); model.setPath(resource.getPath()); Language lang = resource.getLanguage(); if (lang != null) { model.setLanguageKey(lang.getKey()); } if (StringUtils.isNotBlank(resource.getName())) { model.setName(resource.getName()); } else { model.setName(resource.getKey()); } model.setLongName(resource.getLongName()); model.setQualifier(resource.getQualifier()); model.setScope(resource.getScope()); return model; }
builder.setName(name); String path = r.getPath(); if (path != null) { builder.setPath(path);
builder.setDescription(description); String path = r.getPath(); if (path != null) { builder.setPath(path);