group=org.sonarsource.sonarqube
version=10.4
-pluginApiVersion=10.4.0.2064
+pluginApiVersion=10.5.0.2090
description=Open source platform for continuous inspection of code quality
projectTitle=SonarQube
org.gradle.jvmargs=-Xmx2048m
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.rules.RuleType;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.metric.Metric;
import org.sonar.ce.task.projectanalysis.metric.MetricRepository;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.status.IssueStatus;
import static org.sonar.api.issue.Issue.STATUS_CONFIRMED;
import static org.sonar.api.issue.Issue.STATUS_OPEN;
unresolved++;
typeBag.add(issue.type());
severityBag.add(issue.severity());
- } else if (IssueStatus.FALSE_POSITIVE.equals(issue.getIssueStatus())) {
+ } else if (IssueStatus.FALSE_POSITIVE.equals(issue.issueStatus())) {
falsePositives++;
- } else if (IssueStatus.ACCEPTED.equals(issue.getIssueStatus())) {
+ } else if (IssueStatus.ACCEPTED.equals(issue.issueStatus())) {
accepted++;
if (issue.impacts().values().stream().anyMatch(severity -> severity == Severity.HIGH)) {
highImpactAccepted++;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.RuleKey;
import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
import org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter;
import org.sonar.ce.task.projectanalysis.issue.RuleRepository;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.user.UserDto;
import org.sonar.server.issue.notification.IssuesChangesNotification;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder;
import java.util.Optional;
import java.util.Set;
import javax.annotation.CheckForNull;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
-import org.sonar.core.issue.status.IssueStatus;
public final class IndexedIssueDto {
private String issueKey = null;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.jetbrains.annotations.NotNull;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.core.util.Uuids;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.protobuf.DbIssues;
import java.util.Set;
import org.junit.Test;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
-import org.sonar.core.issue.status.IssueStatus;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple;
public class IndexedIssueDtoTest {
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.rule.RuleDto;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.utils.System2;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ProjectData;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.DefaultIssueComment;
import org.sonar.core.issue.IssueChangeContext;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.user.UserDto;
import org.sonar.db.user.UserIdDto;
public boolean setIssueStatus(DefaultIssue issue, @Nullable IssueStatus previousIssueStatus, @Nullable IssueStatus newIssueStatus, IssueChangeContext context) {
if (!Objects.equals(newIssueStatus, previousIssueStatus)) {
//Currently, issue status is not persisted in database, but is considered as an issue change
- issue.setFieldChange(context, ISSUE_STATUS, previousIssueStatus, issue.getIssueStatus());
+ issue.setFieldChange(context, ISSUE_STATUS, previousIssueStatus, issue.issueStatus());
return true;
}
return false;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.sonar.core.issue.status.IssueStatus;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue;
import org.sonar.server.notification.EmailNotificationHandler;
import org.sonar.server.notification.NotificationDispatcherMetadata;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
-import org.sonar.core.issue.status.IssueStatus;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.RuleKey;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Rule;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.issue.DefaultTransitions;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ServerSide;
import org.sonar.api.web.UserRole;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.IssueChangeContext;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.server.issue.IssueFieldsSetter;
import static com.google.common.base.Preconditions.checkArgument;
public boolean doManualTransition(DefaultIssue issue, String transitionKey, IssueChangeContext issueChangeContext) {
Transition transition = stateOf(issue).transition(transitionKey);
if (transition.supports(issue) && !transition.automatic()) {
- IssueStatus previousIssueStatus = issue.getIssueStatus();
+ IssueStatus previousIssueStatus = issue.issueStatus();
functionExecutor.execute(transition.functions(), issue, issueChangeContext);
updater.setStatus(issue, transition.to(), issueChangeContext);
- updater.setIssueStatus(issue, previousIssueStatus, issue.getIssueStatus(), issueChangeContext);
+ updater.setIssueStatus(issue, previousIssueStatus, issue.issueStatus(), issueChangeContext);
return true;
}
return false;
public void doAutomaticTransition(DefaultIssue issue, IssueChangeContext issueChangeContext) {
Transition transition = stateOf(issue).outAutomaticTransition(issue);
if (transition != null) {
- IssueStatus previousIssueStatus = issue.getIssueStatus();
+ IssueStatus previousIssueStatus = issue.issueStatus();
functionExecutor.execute(transition.functions(), issue, issueChangeContext);
updater.setStatus(issue, transition.to(), issueChangeContext);
- updater.setIssueStatus(issue, previousIssueStatus, issue.getIssueStatus(), issueChangeContext);
+ updater.setIssueStatus(issue, previousIssueStatus, issue.issueStatus(), issueChangeContext);
}
}
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.FieldDiffs;
import org.sonar.core.issue.IssueChangeContext;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.protobuf.DbCommons;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.protobuf.DbIssues.MessageFormattingType;
issue.setResolution(null);
issue.setStatus(Issue.STATUS_OPEN);
- IssueStatus issueStatus = issue.getIssueStatus();
+ IssueStatus issueStatus = issue.issueStatus();
underTest.setResolution(issue, Issue.RESOLUTION_WONT_FIX, context);
underTest.setStatus(issue, Issue.STATUS_RESOLVED, context);
- underTest.setIssueStatus(issue, issueStatus, issue.getIssueStatus(), context);
+ underTest.setIssueStatus(issue, issueStatus, issue.issueStatus(), context);
FieldDiffs.Diff diff = issue.currentChange().diffs().get(IssueFieldsSetter.ISSUE_STATUS);
assertThat(diff.oldValue()).isEqualTo(IssueStatus.OPEN);
issue.setResolution(null);
issue.setStatus(Issue.STATUS_OPEN);
- IssueStatus issueStatus = issue.getIssueStatus();
- underTest.setIssueStatus(issue, issueStatus, issue.getIssueStatus(), context);
+ IssueStatus issueStatus = issue.issueStatus();
+ underTest.setIssueStatus(issue, issueStatus, issue.issueStatus(), context);
assertThat(issue.currentChange()).isNull();
}
issue.setResolution(null);
issue.setStatus(Issue.STATUS_TO_REVIEW);
- IssueStatus issueStatus = issue.getIssueStatus();
+ IssueStatus issueStatus = issue.issueStatus();
issue.setResolution(Issue.RESOLUTION_SAFE);
issue.setStatus(Issue.STATUS_REVIEWED);
- underTest.setIssueStatus(issue, issueStatus, issue.getIssueStatus(), context);
+ underTest.setIssueStatus(issue, issueStatus, issue.issueStatus(), context);
assertThat(issue.currentChange()).isNull();
}
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.sonar.api.issue.Issue;
-import org.sonar.core.issue.status.IssueStatus;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.server.issue.notification.FPOrAcceptedNotification.FpPrAccepted;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Change;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue;
import java.util.stream.IntStream;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.System2;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.AnalysisChange;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.ChangedIssue;
import org.sonar.server.issue.notification.IssuesChangesNotificationBuilder.Project;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.joda.time.Duration;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.CleanCodeAttributeCategory;
import org.sonar.api.server.rule.RulesDefinition.PciDssVersion;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.EsUtils;
import org.sonar.server.es.SearchOptions;
import static org.sonar.server.issue.index.IssueIndex.Facet.FILES;
import static org.sonar.server.issue.index.IssueIndex.Facet.IMPACT_SEVERITY;
import static org.sonar.server.issue.index.IssueIndex.Facet.IMPACT_SOFTWARE_QUALITY;
+import static org.sonar.server.issue.index.IssueIndex.Facet.ISSUE_STATUSES;
import static org.sonar.server.issue.index.IssueIndex.Facet.LANGUAGES;
import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_ASVS_40;
import static org.sonar.server.issue.index.IssueIndex.Facet.OWASP_TOP_10;
import static org.sonar.server.issue.index.IssueIndex.Facet.SANS_TOP_25;
import static org.sonar.server.issue.index.IssueIndex.Facet.SCOPES;
import static org.sonar.server.issue.index.IssueIndex.Facet.SEVERITIES;
-import static org.sonar.server.issue.index.IssueIndex.Facet.ISSUE_STATUSES;
import static org.sonar.server.issue.index.IssueIndex.Facet.SONARSOURCE_SECURITY;
import static org.sonar.server.issue.index.IssueIndex.Facet.STATUSES;
import static org.sonar.server.issue.index.IssueIndex.Facet.TAGS;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LANGUAGE;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_LINE;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_NEW_CODE_REFERENCE;
+import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_NEW_STATUS;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_ASVS_40;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_TOP_10;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_OWASP_TOP_10_2021;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_SCOPE;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_SEVERITY;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_SEVERITY_VALUE;
-import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_NEW_STATUS;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_SQ_SECURITY_CATEGORY;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_STATUS;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_TAGS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IMPACT_SEVERITIES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IMPACT_SOFTWARE_QUALITIES;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUE_STATUSES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_LANGUAGES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_ASVS_40;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_OWASP_TOP_10;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SANS_TOP_25;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SCOPES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUE_STATUSES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_SONARSOURCE_SECURITY;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_TAGS;
import java.util.Set;
import org.elasticsearch.action.search.SearchResponse;
import org.junit.Test;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition.OwaspAsvsVersion;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.server.es.Facets;
import org.assertj.core.api.Fail;
import org.junit.Test;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.RuleType;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.server.es.SearchOptions;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.sonar.api.impl.utils.TestSystem2;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
assertThat(changedIssue.getKey()).isEqualTo(issue.key());
assertThat(changedIssue.getNewStatus()).isEqualTo(issue.status());
assertThat(changedIssue.getOldIssueStatus()).contains(originalIssueDto.getIssueStatus());
- assertThat(changedIssue.getNewIssueStatus()).contains(issue.getIssueStatus());
+ assertThat(changedIssue.getNewIssueStatus()).contains(issue.issueStatus());
assertThat(changedIssue.getAssignee()).contains(userOf(assignee));
assertThat(changedIssue.getRule()).isEqualTo(ruleOf(rule));
assertThat(changedIssue.getProject()).isEqualTo(projectOf(project));
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.Durations;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IMPACT_SEVERITIES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IMPACT_SOFTWARE_QUALITIES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUE_STATUSES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PULL_REQUEST;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_RULES;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ISSUE_STATUSES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_STATUSES;
public class SearchActionIT {
Optional<UserDto> assignee = Optional.ofNullable(issue.assignee()).map(userDtoByUuid::get);
return new ChangedIssue.Builder(issue.key())
.setNewStatus(issue.status())
- .setNewIssueStatus(issue.getIssueStatus())
+ .setNewIssueStatus(issue.issueStatus())
.setOldIssueStatus(oldIssueDto.getIssueStatus())
.setAssignee(assignee.map(u -> new User(u.getUuid(), u.getLogin(), u.getName())).orElse(null))
.setRule(new IssuesChangesNotificationBuilder.Rule(ruleDefinitionDto.getKey(), RuleType.valueOfNullable(ruleDefinitionDto.getType()), ruleDefinitionDto.getName()))
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rules.RuleType;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.IssueChangeContext;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.BranchDto;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
import org.sonar.api.issue.DefaultTransitions;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.CleanCodeAttributeCategory;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.Paging;
import org.sonar.api.utils.System2;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.user.UserDto;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.Duration;
import org.sonar.api.utils.Durations;
import org.sonar.api.utils.Paging;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDto;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.RuleType;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.issue.IssueGroupDto;
import org.sonar.db.rule.SeverityUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.resources.Languages;
import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.utils.Duration;
import org.sonar.api.utils.Durations;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.db.DbTester;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
-import org.sonar.core.issue.status.IssueStatus;
import org.sonar.core.issue.tracking.Trackable;
import static org.sonar.api.utils.DateUtils.truncateToSeconds;
}
@Nullable
- public IssueStatus getIssueStatus() {
+ @Override
+ public IssueStatus issueStatus() {
return IssueStatus.of(status, resolution);
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.issue.status;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.issue.Issue;
-
-public enum IssueStatus {
-
-
- OPEN,
-
- @Deprecated(since = "10.4")
- /*
- * @deprecated use {@link IssueStatus#ACCEPTED} instead
- */
- CONFIRMED,
- FALSE_POSITIVE,
- ACCEPTED,
- FIXED;
-
- private static final Logger LOGGER = LoggerFactory.getLogger(IssueStatus.class);
-
- @CheckForNull
- public static IssueStatus of(@Nullable String status, @Nullable String resolution) {
-
- //null status is not supposed to happen, but since it is nullable in database, we want the mapping to be resilient.
- if (status == null) {
- LOGGER.warn("Missing status, falling back to {}", IssueStatus.OPEN);
- return IssueStatus.OPEN;
- }
-
- switch (status) {
- case Issue.STATUS_OPEN, Issue.STATUS_REOPENED:
- return IssueStatus.OPEN;
- case Issue.STATUS_CONFIRMED:
- return IssueStatus.CONFIRMED;
- case Issue.STATUS_CLOSED:
- return IssueStatus.FIXED;
- // Security hotspot should not return issue status as they are deprecated.
- case Issue.STATUS_REVIEWED, Issue.STATUS_TO_REVIEW:
- return null;
- default:
- }
- if (Issue.STATUS_RESOLVED.equals(status) && resolution != null) {
- switch (resolution) {
- case Issue.RESOLUTION_FALSE_POSITIVE:
- return IssueStatus.FALSE_POSITIVE;
- case Issue.RESOLUTION_WONT_FIX:
- return IssueStatus.ACCEPTED;
- case Issue.RESOLUTION_FIXED:
- return IssueStatus.FIXED;
- default:
- }
- }
-
-
- LOGGER.warn("Can't find mapped issue status for status '{}' and resolution '{}'", status, resolution);
- return null;
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.core.issue.status;
-
-import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueStatus;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.utils.Duration;
-import org.sonar.core.issue.status.IssueStatus;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
issue.setStatus(Issue.STATUS_RESOLVED);
issue.setResolution(Issue.RESOLUTION_FIXED);
- assertThat(issue.getIssueStatus()).isEqualTo(IssueStatus.FIXED);
+ assertThat(issue.issueStatus()).isEqualTo(IssueStatus.FIXED);
}
@Test
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.issue.status;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.testfixtures.log.LogAndArguments;
-import org.sonar.api.testfixtures.log.LogTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class IssueStatusTest {
-
- @Rule
- public LogTester logTester = new LogTester();
-
- @Test
- public void of_shouldMapToCorrectIssueStatus() {
- assertThat(IssueStatus.of(Issue.STATUS_RESOLVED, Issue.RESOLUTION_FIXED))
- .isEqualTo(IssueStatus.FIXED);
-
- assertThat(IssueStatus.of(Issue.STATUS_CONFIRMED, null))
- .isEqualTo(IssueStatus.CONFIRMED);
-
- assertThat(IssueStatus.of(Issue.STATUS_RESOLVED, Issue.RESOLUTION_FALSE_POSITIVE))
- .isEqualTo(IssueStatus.FALSE_POSITIVE);
-
- assertThat(IssueStatus.of(Issue.STATUS_RESOLVED, Issue.RESOLUTION_WONT_FIX))
- .isEqualTo(IssueStatus.ACCEPTED);
-
- assertThat(IssueStatus.of(Issue.STATUS_REOPENED, null))
- .isEqualTo(IssueStatus.OPEN);
-
- assertThat(IssueStatus.of(Issue.STATUS_CLOSED, null))
- .isEqualTo(IssueStatus.FIXED);
- }
-
- @Test
- public void of_shouldReturnNull_whenStatusBelongsToHotspot() {
- assertThat(IssueStatus.of(Issue.STATUS_TO_REVIEW, null))
- .isNull();
-
- assertThat(IssueStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_SAFE))
- .isNull();
-
- assertThat(IssueStatus.of(Issue.STATUS_REVIEWED, Issue.RESOLUTION_ACKNOWLEDGED))
- .isNull();
- }
-
- @Test
- public void of_shouldLogWarning_whenUnknownMapping() {
- assertThat(IssueStatus.of(Issue.STATUS_RESOLVED, null)).isNull();
- assertThat(logTester.getLogs()).extracting(LogAndArguments::getFormattedMsg).contains("Can't find mapped issue status for status 'RESOLVED' and resolution 'null'");
-
- assertThat(IssueStatus.of(Issue.STATUS_RESOLVED, Issue.RESOLUTION_SAFE)).isNull();
- assertThat(logTester.getLogs()).extracting(LogAndArguments::getFormattedMsg).contains("Can't find mapped issue status for status 'RESOLVED' and resolution 'SAFE'");
- }
-
- @Test
- public void of_shouldLogWarning_whenStatusIsNull() {
- assertThat(IssueStatus.of(null, null)).isEqualTo(IssueStatus.OPEN);
- assertThat(logTester.getLogs()).extracting(LogAndArguments::getFormattedMsg).contains("Missing status, falling back to OPEN");
- }
-
-}