@Override public boolean matches(Issue issue) { return issue.resolution() == null; } }
public List<Transition> outTransitions(Issue issue) { String status = issue.status(); State state = machine.state(status); checkArgument(state != null, "Unknown status: %s", status); return state.outManualTransitions(issue); }
protected void createIssue(Resource resource, ResourcePerspectives perspectives, RuleKey ruleKey, @Nullable Double effortToFix, String message) { Issuable issuable = perspectives.as(Issuable.class, resource); if (issuable != null) { issuable.addIssue(issuable.newIssueBuilder() .ruleKey(ruleKey) .effortToFix(effortToFix) .message(message) .build()); } }
.setCreationDate(creationDate); Issue issue = new TrackedIssueAdapter(trackedIssue); assertThat(issue.key()).isEqualTo("XYZ123"); assertThat(issue.componentKey()).isEqualTo("foo"); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.severity()).isEqualTo("MAJOR"); assertThat(issue.message()).isEqualTo("msg"); assertThat(issue.line()).isEqualTo(1); assertThat(issue.gap()).isEqualTo(2.0); assertThat(issue.status()).isEqualTo("RESOLVED"); assertThat(issue.resolution()).isEqualTo("FIXED"); assertThat(issue.assignee()).isEqualTo("tata"); assertThat(issue.isNew()).isTrue(); assertThat(issue.attribute("foo")).isNull(); assertThat(issue.creationDate()).isEqualTo(creationDate); assertThat(issue.language()).isNull(); assertThat(issue.updateDate()).isNull(); assertThat(issue.closeDate()).isNull(); assertThat(issue.authorLogin()).isNull(); assertThat(issue.comments()).isEmpty(); assertThat(issue.effort()).isNull(); assertThat(issue.projectKey()).isNull(); assertThat(issue.projectUuid()).isNull(); assertThat(issue.componentUuid()).isNull(); assertThat(issue.tags()).isEmpty();
@CheckForNull protected Integer getRuleId(Issue issue) { Rule rule = ruleFinder.findByKey(issue.ruleKey()); return rule != null ? rule.getId() : null; } }
@Test public void should_store_nosonar_lines_on_inputfile() { DefaultInputFile f = TestInputFileBuilder.create("module1", "myfile.java").build(); new NoSonarFilter().noSonarInFile(f, new HashSet<>(Arrays.asList(1,4))); assertThat(f.hasNoSonarAt(1)).isTrue(); assertThat(f.hasNoSonarAt(2)).isFalse(); assertThat(f.hasNoSonarAt(4)).isTrue(); } }
private void processFile(InputFile inputFile) { try { Set<Integer> noSonarLines = new HashSet<>(); int[] lineCounter = {1}; try (Stream<String> stream = Files.lines(inputFile.path(), inputFile.charset())) { stream.forEachOrdered(lineStr -> { if (lineStr.contains("//NOSONAR")) { noSonarLines.add(lineCounter[0]); } lineCounter[0]++; }); } noSonarFilter.noSonarInFile(inputFile, noSonarLines); } catch (IOException e) { throw new IllegalStateException("Fail to process " + inputFile, e); } } }
@Override public void executeOn(Project project, SensorContext context) { for (Issue issue : projectIssues.issues()) { if (Severity.ALL.indexOf(issue.severity()) >= issuesSeveritySettingValue) { // only mark failure and fail on PostJobsPhaseHandler.onPostJobsPhase() to ensure other // plugins can finish their work, most notably the stash issue reporter plugin failed = true; return; } } }
private boolean isCurrentUserIssueAdminAndNotSecurityHotspot(Issue issue) { DefaultIssue defaultIssue = (DefaultIssue) issue; return (defaultIssue.type() != RuleType.SECURITY_HOTSPOT && userSession.hasComponentUuidPermission(ISSUE_ADMIN, issue.projectUuid())); }
public void execute(DefaultIssue issue, IssueChangeContext changeContext) { context.reset(issue, changeContext); for (IssueHandler handler : handlers) { handler.onIssue(context); } }
private void reportIssueBeforeSQ52(InputPath inputFile, RuleKey key, @Nullable Double cost, String message, @Nullable Integer line) { Issuable issuable = issuableFor(inputFile); if (issuable != null) { Issuable.IssueBuilder newIssueBuilder = issuable.newIssueBuilder() .ruleKey(key) .message(message) .line(line) .effortToFix(cost); issuable.addIssue(newIssueBuilder.build()); } }
@Override public boolean matches(Issue issue) { return issue.resolution() != null && resolutions.contains(issue.resolution()); } }
private boolean isCurrentUserIssueAdmin(Issue issue) { return !((DefaultIssue) issue).isFromHotspot() && userSession.hasComponentUuidPermission(UserRole.ISSUE_ADMIN, issue.projectUuid()); }
private Directory createIssueOnDir(Directory dir) { Issuable issuable = perspectives.as(Issuable.class, dir); issuable.addIssue(issuable.newIssueBuilder() .ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)) .message("Issue created using deprecated API") .build()); return dir; }
@Test public void should_match() { HasResolution condition = new HasResolution(Issue.RESOLUTION_FIXED, Issue.RESOLUTION_FALSE_POSITIVE); when(issue.resolution()).thenReturn("FIXED"); assertThat(condition.matches(issue)).isTrue(); when(issue.resolution()).thenReturn("FALSE-POSITIVE"); assertThat(condition.matches(issue)).isTrue(); when(issue.resolution()).thenReturn("Fixed"); assertThat(condition.matches(issue)).isFalse(); } }
@Test public void should_match() { IsUnResolved condition = new IsUnResolved(); assertThat(condition.matches(issue)).isTrue(); when(issue.resolution()).thenReturn("FIXED"); assertThat(condition.matches(issue)).isFalse(); } }
@Override public boolean matches(Issue issue) { return issue.resolution() == null; } }
@Override public boolean matches(Issue issue) { return issue.resolution() != null && resolutions.contains(issue.resolution()); } }