public boolean setLocations(DefaultIssue issue, @Nullable Object locations) { if (!Objects.equal(locations, issue.getLocations())) { issue.setLocations(locations); issue.setChanged(true); return true; } return false; }
public void setCloseDate(DefaultIssue issue, @Nullable Date d, IssueChangeContext context) { Date dateWithoutMilliseconds = d == null ? null : DateUtils.truncate(d, Calendar.SECOND); if (!Objects.equal(dateWithoutMilliseconds, issue.closeDate())) { issue.setCloseDate(d); issue.setUpdateDate(context.date()); issue.setChanged(true); } }
public boolean setLine(DefaultIssue issue, @Nullable Integer line) { if (!Objects.equal(line, issue.line())) { issue.setLine(line); issue.setChanged(true); return true; } return false; }
public boolean setProject(DefaultIssue issue, String projectKey, IssueChangeContext context) { if (!Objects.equal(projectKey, issue.projectKey())) { issue.setProjectKey(projectKey); issue.setUpdateDate(context.date()); issue.setChanged(true); return true; } return false; }
public boolean setMessage(DefaultIssue issue, @Nullable String s, IssueChangeContext context) { if (!Objects.equal(s, issue.message())) { issue.setMessage(s); issue.setUpdateDate(context.date()); issue.setChanged(true); return true; } return false; }
public boolean setEffortToFix( DefaultIssue issue, @Nullable Double d, IssueChangeContext context) { if (!Objects.equal(d, issue.effortToFix())) { issue.setEffortToFix(d); issue.setUpdateDate(context.date()); issue.setChanged(true); // Do not send notifications to prevent spam when installing the SQALE plugin, // and do not complete the changelog (for the moment) return true; } return false; }
public boolean setAttribute( DefaultIssue issue, String key, @Nullable String value, IssueChangeContext context) { String oldValue = issue.attribute(key); if (!Objects.equal(oldValue, value)) { issue.setFieldChange(context, key, oldValue, value); issue.setAttribute(key, value); issue.setUpdateDate(context.date()); issue.setChanged(true); return true; } return false; }
public boolean setTechnicalDebt( DefaultIssue issue, @Nullable Duration value, IssueChangeContext context) { Duration oldValue = issue.debt(); if (!Objects.equal(value, oldValue)) { issue.setDebt(value != null ? value : null); issue.setFieldChange( context, TECHNICAL_DEBT, oldValue != null ? oldValue.toMinutes() : null, value != null ? value.toMinutes() : null); issue.setUpdateDate(context.date()); issue.setChanged(true); return true; } return false; }
public boolean setManualSeverity( DefaultIssue issue, String severity, IssueChangeContext context) { if (!issue.manualSeverity() || !Objects.equal(severity, issue.severity())) { issue.setFieldChange(context, SEVERITY, issue.severity(), severity); issue.setSeverity(severity); issue.setManualSeverity(true); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean setStatus(DefaultIssue issue, String status, IssueChangeContext context) { if (!Objects.equal(status, issue.status())) { issue.setFieldChange(context, STATUS, issue.status(), status); issue.setStatus(status); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean setResolution( DefaultIssue issue, @Nullable String resolution, IssueChangeContext context) { if (!Objects.equal(resolution, issue.resolution())) { issue.setFieldChange(context, RESOLUTION, issue.resolution(), resolution); issue.setResolution(resolution); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean setSeverity(DefaultIssue issue, String severity, IssueChangeContext context) { if (issue.manualSeverity()) { throw new IllegalStateException("Severity can't be changed"); } if (!Objects.equal(severity, issue.severity())) { issue.setFieldChange(context, SEVERITY, issue.severity(), severity); issue.setSeverity(severity); issue.setUpdateDate(context.date()); issue.setChanged(true); return true; } return false; }
public boolean setAuthorLogin( DefaultIssue issue, @Nullable String authorLogin, IssueChangeContext context) { if (!Objects.equal(authorLogin, issue.authorLogin())) { issue.setFieldChange(context, AUTHOR, issue.authorLogin(), authorLogin); issue.setAuthorLogin(authorLogin); issue.setUpdateDate(context.date()); issue.setChanged(true); // do not send notifications to prevent spam when installing the developer cockpit plugin return true; } return false; }
@Test public void build_project_issue() { SensorStorage storage = mock(SensorStorage.class); DefaultIssue issue = new DefaultIssue(storage) .addLocation(new DefaultIssueLocation().onProject().message("Wrong way!")) .forRule(RuleKey.of("repo", "rule")) .effortToFix(10.0); assertThat(issue.locations().get(0).inputPath()).isNull(); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.locations().get(0).textRange()).isNull(); assertThat(issue.effortToFix()).isEqualTo(10.0); assertThat(issue.locations().get(0).message()).isEqualTo("Wrong way!"); issue.save(); verify(storage).store(issue); }
public boolean assign(DefaultIssue issue, @Nullable User user, IssueChangeContext context) { String sanitizedAssignee = null; if (user != null) { sanitizedAssignee = StringUtils.defaultIfBlank(user.login(), null); } if (!Objects.equal(sanitizedAssignee, issue.assignee())) { String newAssignee = user != null ? user.name() : null; issue.setFieldChange(context, ASSIGNEE, UNUSED, newAssignee); issue.setAssignee(sanitizedAssignee); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean plan( DefaultIssue issue, @Nullable ActionPlan actionPlan, IssueChangeContext context) { String sanitizedActionPlanKey = null; if (actionPlan != null) { sanitizedActionPlanKey = StringUtils.defaultIfBlank(actionPlan.key(), null); } if (!Objects.equal(sanitizedActionPlanKey, issue.actionPlanKey())) { String newActionPlanName = actionPlan != null ? actionPlan.name() : null; issue.setFieldChange(context, ACTION_PLAN, UNUSED, newActionPlanName); issue.setActionPlanKey(sanitizedActionPlanKey); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
@Test public void build_directory_issue() { SensorStorage storage = mock(SensorStorage.class); DefaultIssue issue = new DefaultIssue(storage) .addLocation( new DefaultIssueLocation() .onDir(new DefaultInputDir("foo", "src")) .message("Wrong way!")) .forRule(RuleKey.of("repo", "rule")) .overrideSeverity(Severity.BLOCKER); assertThat(issue.locations().get(0).inputPath()).isEqualTo(new DefaultInputDir("foo", "src")); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.locations().get(0).textRange()).isNull(); assertThat(issue.locations().get(0).message()).isEqualTo("Wrong way!"); assertThat(issue.overriddenSeverity()).isEqualTo(Severity.BLOCKER); issue.save(); verify(storage).store(issue); }
public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) { Set<String> newTags = Sets.newHashSet( Collections2.transform( Collections2.filter( tags, new Predicate<String>() { @Override public boolean apply(@Nullable String tag) { return tag != null && !tag.isEmpty(); } }), new Function<String, String>() { @Override public String apply(String tag) { String lowerCaseTag = tag.toLowerCase(); RuleTagFormat.validate(lowerCaseTag); return lowerCaseTag; } })); Set<String> oldTags = Sets.newHashSet(issue.tags()); if (!oldTags.equals(newTags)) { issue.setFieldChange( context, TAGS, oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags), newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags)); issue.setTags(newTags); issue.setUpdateDate(context.date()); issue.setChanged(true); issue.setSendNotifications(true); return true; } return false; }
public boolean setPastSeverity( DefaultIssue issue, @Nullable String previousSeverity, IssueChangeContext context) { String currentSeverity = issue.severity(); issue.setSeverity(previousSeverity); return setSeverity(issue, currentSeverity, context); }
public boolean setPastProject( DefaultIssue issue, String previousKey, IssueChangeContext context) { String currentProjectKey = issue.projectKey(); issue.setProjectKey(previousKey); return setProject(issue, currentProjectKey, context); }
public void addComment(DefaultIssue issue, String text, IssueChangeContext context) { issue.addComment(DefaultIssueComment.create(issue.key(), context.login(), text)); issue.setUpdateDate(context.date()); issue.setChanged(true); }
public boolean setPastTechnicalDebt( DefaultIssue issue, @Nullable Duration previousTechnicalDebt, IssueChangeContext context) { Duration currentTechnicalDebt = issue.debt(); issue.setDebt(previousTechnicalDebt); return setTechnicalDebt(issue, currentTechnicalDebt, context); }
public boolean setPastLine(DefaultIssue issue, @Nullable Integer previousLine) { Integer currentLine = issue.line(); issue.setLine(previousLine); return setLine(issue, currentLine); }
public boolean setPastEffortToFix( DefaultIssue issue, @Nullable Double previousEffort, IssueChangeContext context) { Double currentEffort = issue.effortToFix(); issue.setEffortToFix(previousEffort); return setEffortToFix(issue, currentEffort, context); }
public boolean setPastLocations(DefaultIssue issue, @Nullable Object previousLocations) { Object currentLocations = issue.getLocations(); issue.setLocations(previousLocations); return setLocations(issue, currentLocations); }
public boolean setPastMessage( DefaultIssue issue, @Nullable String previousMessage, IssueChangeContext context) { String currentMessage = issue.message(); issue.setMessage(previousMessage); return setMessage(issue, currentMessage, context); }