@Override public DefaultIssueLocation at(TextRange location) { Preconditions.checkState(this.component != null, "at() should be called after on()"); Preconditions.checkState(this.component.isFile(), "at() should be called only for an InputFile."); DefaultInputFile file = (DefaultInputFile) this.component; file.validate(location); this.textRange = location; return this; }
@CheckForNull private SourceHashHolder loadSourceHashes(InputComponent component) { SourceHashHolder sourceHashHolder = null; if (component.isFile()) { DefaultInputFile file = (DefaultInputFile) component; sourceHashHolder = new SourceHashHolder(project, file, lastLineHashes); } return sourceHashHolder; }
@Override public void doSave() { requireNonNull(this.engineId, "Engine id is mandatory on external issue"); requireNonNull(this.ruleId, "Rule id is mandatory on external issue"); checkState(primaryLocation != null, "Primary location is mandatory on every external issue"); checkState(primaryLocation.inputComponent().isFile(), "External issues must be located in files"); checkState(primaryLocation.message() != null, "External issues must have a message"); checkState(severity != null, "Severity is mandatory on every external issue"); checkState(type != null, "Type is mandatory on every external issue"); storage.store(this); }
@CheckForNull @Override public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, InputComponent component) { if (component.isFile()) { InputFile inputFile = (InputFile) component; if (inputFile.type() == Type.MAIN) { return new DefaultTestable((DefaultInputFile) inputFile); } } return null; } }
private boolean shouldCopyServerIssues(InputComponent component) { if (!mode.scanAllFiles() && component.isFile()) { InputFile inputFile = (InputFile) component; if (inputFile.status() == Status.SAME) { return true; } } return false; }
@CheckForNull @Override public MutableTestPlan loadPerspective(Class<MutableTestPlan> perspectiveClass, InputComponent component) { if (component.isFile()) { DefaultInputFile inputFile = (DefaultInputFile) component; if (inputFile.type() == Type.TEST) { inputFile.setPublished(true); if (!testPlanByFile.containsKey(inputFile)) { testPlanByFile.put(inputFile, new DefaultTestPlan()); } return testPlanByFile.get(inputFile); } } return null; }
@Override public boolean accept(FilterableIssue issue, IssueFilterChain chain) { InputComponent component = ((DefaultFilterableIssue) issue).getComponent(); if (component.isFile() && ((DefaultInputFile) component).isIgnoreAllIssues()) { return false; } if (component.isFile() && ((DefaultInputFile) component).isIgnoreAllIssuesOnLine(issue.line())) { return false; } if (hasRuleMatchFor(component, issue)) { return false; } return chain.accept(issue); }
public List<TrackedIssue> trackIssues(InputComponent component, Collection<ScannerReport.Issue> reportIssues, Date analysisDate) { List<TrackedIssue> trackedIssues = new LinkedList<>(); if (hasServerAnalysis) { // all the issues that are not closed in db before starting this module scan, including manual issues Collection<ServerIssueFromWs> serverIssues = loadServerIssues(component); if (shouldCopyServerIssues(component)) { // raw issues should be empty, we just need to deal with server issues (SONAR-6931) copyServerIssues(serverIssues, trackedIssues, component.key()); } else { SourceHashHolder sourceHashHolder = loadSourceHashes(component); Collection<TrackedIssue> rIssues = IssueTransformer.toTrackedIssue(component, reportIssues, sourceHashHolder); Input<ServerIssueFromWs> baseIssues = createBaseInput(serverIssues, sourceHashHolder); Input<TrackedIssue> rawIssues = createRawInput(rIssues, sourceHashHolder); Tracking<TrackedIssue, ServerIssueFromWs> track = tracker.trackNonClosed(rawIssues, baseIssues); addUnmatchedFromServer(track.getUnmatchedBases(), trackedIssues, component.key()); mergeMatched(track, trackedIssues, rIssues); addUnmatchedFromReport(track.getUnmatchedRaws(), trackedIssues, analysisDate); } } if (hasServerAnalysis && !component.isFile()) { Preconditions.checkState(component instanceof InputModule, "Object without parent is of type: " + component.getClass()); // issues that relate to deleted components addIssuesOnDeletedComponents(trackedIssues, component.key()); } return trackedIssues; }
private void saveMeasure(InputComponent component, DefaultMeasure<?> measure) { if (component.isFile()) { DefaultInputFile defaultInputFile = (DefaultInputFile) component; defaultInputFile.setPublished(true); logOnce(metric.key(), "Coverage measure for metric '{}' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead.", metric.key()); if (!component.isFile()) { throw new UnsupportedOperationException("Saving coverage measure is only allowed on files. Attempt to save '" + metric.key() + "' on '" + component.key() + "'");
atLeastOneRuleMatched = true; InputComponent component = ((DefaultFilterableIssue) issue).getComponent(); if (component.isFile()) { DefaultInputFile file = (DefaultInputFile) component; if (pattern.matchFile(file.getProjectRelativePath())) {
InputComponent component = componentStore.getByKey(issue.componentKey()); String componentKeyWithBranch = project.getKeyWithBranch(); if (component.isFile()) { componentKeyWithBranch = ComponentKeys.createEffectiveKey(componentKeyWithBranch, (DefaultInputFile) component);
@CheckForNull private SourceHashHolder loadSourceHashes(InputComponent component) { SourceHashHolder sourceHashHolder = null; if (component.isFile()) { DefaultInputFile file = (DefaultInputFile) component; sourceHashHolder = new SourceHashHolder(project, file, lastLineHashes); } return sourceHashHolder; }
@Override public IssueBuilder line(@Nullable Integer line) { Preconditions.checkState(newIssue.primaryLocation() == null, "Do not use line() and at() for the same issue"); if (primaryComponent.isFile()) { if (line != null) { this.primaryRange = ((InputFile) primaryComponent).selectLine(line.intValue()); } return this; } else { throw new IllegalArgumentException("Unable to set line for issues on project or directory"); } }
@CheckForNull @Override public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, InputComponent component) { if (component.isFile()) { InputFile inputFile = (InputFile) component; if (inputFile.type() == Type.MAIN) { return new DefaultTestable((DefaultInputFile) inputFile); } } return null; } }
private boolean shouldCopyServerIssues(InputComponent component) { if (!mode.scanAllFiles() && component.isFile()) { InputFile inputFile = (InputFile) component; if (inputFile.status() == Status.SAME) { return true; } } return false; }
public DefaultFlow(List<IssueLocation> issueLocations) { this.locations = issueLocations.stream() .map(i -> new DefaultLocation( i.inputComponent().isFile() ? ((SonarLintInputFile) i.inputComponent()).getClientInputFile() : null, i.textRange(), i.message())) .collect(Collectors.toList()); }
@Override public DefaultIssueLocation at(TextRange location) { Preconditions.checkState(this.component != null, "at() should be called after on()"); Preconditions.checkState(this.component.isFile(), "at() should be called only for an InputFile."); DefaultInputFile file = (DefaultInputFile) this.component; file.validate(location); this.textRange = location; return this; }
@Override public DefaultSonarLintIssueLocation at(TextRange location) { Preconditions.checkState(this.inputComponent() != null, "at() should be called after on()"); Preconditions.checkState(this.inputComponent().isFile(), "at() should be called only for an InputFile."); this.textRange = location; return this; }
@Override public void doSave() { requireNonNull(this.engineId, "Engine id is mandatory on external issue"); requireNonNull(this.ruleId, "Rule id is mandatory on external issue"); checkState(primaryLocation != null, "Primary location is mandatory on every external issue"); checkState(primaryLocation.inputComponent().isFile(), "External issues must be located in files"); checkState(primaryLocation.message() != null, "External issues must have a message"); checkState(severity != null, "Severity is mandatory on every external issue"); checkState(type != null, "Type is mandatory on every external issue"); storage.store(this); }
private void processIssue(GlobalReport report, Map<InputFile, Map<Integer, StringBuilder>> commentToBeAddedByFileAndByLine, PostJobIssue issue) { boolean reportedInline = false; InputComponent inputComponent = issue.inputComponent(); if (gitHubPluginConfiguration.tryReportIssuesInline() && inputComponent != null && inputComponent.isFile()) { reportedInline = tryReportInline(commentToBeAddedByFileAndByLine, issue, (InputFile) inputComponent); } report.process(issue, pullRequestFacade.getGithubUrl(inputComponent, issue.line()), reportedInline); }