aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis/src
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2019-12-06 10:11:44 +0100
committerSonarTech <sonartech@sonarsource.com>2020-01-13 20:46:26 +0100
commit114efaae21bbf1c8a42c4f17627a0496ce65a2be (patch)
treede96bdc924b5d4a226b974388554030dfc3df6eb /server/sonar-ce-task-projectanalysis/src
parentb8d394da901488b5493e95c0bf98d0ff1139de09 (diff)
downloadsonarqube-114efaae21bbf1c8a42c4f17627a0496ce65a2be.tar.gz
sonarqube-114efaae21bbf1c8a42c4f17627a0496ce65a2be.zip
SONAR-12725 drop manual vulnerabilities
* drop manual vulnerabilities * remove issues `from_hotspot` column usage
Diffstat (limited to 'server/sonar-ce-task-projectanalysis/src')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoaderTest.java10
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java66
3 files changed, 5 insertions, 83 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
index 4505d748997..7c01c43f013 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
@@ -76,7 +76,6 @@ public class IssueLifecycle {
issue.setCreationDate(changeContext.date());
issue.setUpdateDate(changeContext.date());
issue.setEffort(debtCalculator.calculate(issue));
- issue.setIsFromHotspot(rule.getType() == RuleType.SECURITY_HOTSPOT);
setType(issue, rule);
setStatus(issue, rule);
}
@@ -165,20 +164,9 @@ public class IssueLifecycle {
// In case issue was moved from module or folder to the root project
raw.setChanged(true);
}
- raw.setIsFromHotspot(rule.getType() == RuleType.SECURITY_HOTSPOT);
setType(raw, rule);
copyFields(raw, base);
base.changes().forEach(raw::addChange);
- if (raw.isFromHotspot() != base.isFromHotspot()) {
- // This is to force DB update of the issue
- raw.setChanged(true);
- }
- if (raw.isFromHotspot() && !base.isFromHotspot()) {
- // First analysis after rule type was changed to security_hotspot. Issue will be reset to an open hotspot
- updater.setType(raw, RuleType.SECURITY_HOTSPOT, changeContext);
- updater.setStatus(raw, Issue.STATUS_TO_REVIEW, changeContext);
- updater.setResolution(raw, null, changeContext);
- }
if (base.manualSeverity()) {
raw.setManualSeverity(true);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoaderTest.java
index 746dd126efc..09e165377ff 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/ComponentIssuesLoaderTest.java
@@ -80,7 +80,7 @@ public class ComponentIssuesLoaderTest {
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
RuleDefinitionDto rule = db.rules().insert(t -> t.setType(CODE_SMELL));
Date issueDate = addDays(NOW, -10);
- IssueDto issue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL).setIsFromHotspot(false));
+ IssueDto issue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(issueDate, 10));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(addDays(issueDate, 3), 20));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(addDays(issueDate, 1), 30));
@@ -100,7 +100,7 @@ public class ComponentIssuesLoaderTest {
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
RuleDefinitionDto rule = db.rules().insert(t -> t.setType(CODE_SMELL));
Date issueDate = addDays(NOW, -10);
- IssueDto issue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL).setIsFromHotspot(false));
+ IssueDto issue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(issueDate, 10));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(addDays(issueDate, 2), null));
db.issues().insertFieldDiffs(issue, newToClosedDiffsWithLine(addDays(issueDate, 1), 30));
@@ -120,9 +120,9 @@ public class ComponentIssuesLoaderTest {
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
RuleDefinitionDto rule = db.rules().insert(t -> t.setType(CODE_SMELL));
Date issueDate = addDays(NOW, -10);
- IssueDto closedIssue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL).setIsFromHotspot(false));
+ IssueDto closedIssue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL));
db.issues().insertFieldDiffs(closedIssue, newToClosedDiffsWithLine(issueDate, 10));
- IssueDto issueNoCloseDate = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIsFromHotspot(false));
+ IssueDto issueNoCloseDate = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED));
db.issues().insertFieldDiffs(issueNoCloseDate, newToClosedDiffsWithLine(issueDate, 10));
when(system2.now()).thenReturn(NOW.getTime());
@@ -198,7 +198,7 @@ public class ComponentIssuesLoaderTest {
};
IssueDto[] issues = Arrays.stream(issueDates)
.map(issueDate -> {
- IssueDto closedIssue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL).setIsFromHotspot(false));
+ IssueDto closedIssue = db.issues().insert(rule, project, file, t -> t.setStatus(STATUS_CLOSED).setIssueCloseDate(issueDate).setType(CODE_SMELL));
db.issues().insertFieldDiffs(closedIssue, newToClosedDiffsWithLine(issueDate, 10));
return closedIssue;
})
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java
index 0ce772abef6..56629df1fe2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java
@@ -87,7 +87,6 @@ public class IssueLifecycleTest {
assertThat(issue.effort()).isEqualTo(DEFAULT_DURATION);
assertThat(issue.isNew()).isTrue();
assertThat(issue.isCopied()).isFalse();
- assertThat(issue.isFromHotspot()).isFalse();
}
@Test
@@ -107,7 +106,6 @@ public class IssueLifecycleTest {
assertThat(issue.effort()).isEqualTo(DEFAULT_DURATION);
assertThat(issue.isNew()).isTrue();
assertThat(issue.isCopied()).isFalse();
- assertThat(issue.isFromHotspot()).isTrue();
}
@Test
@@ -304,70 +302,6 @@ public class IssueLifecycleTest {
}
@Test
- public void mergeExistingOpenIssue_vulnerability_changed_to_hotspot_should_be_to_review() {
- rule.setType(RuleType.SECURITY_HOTSPOT);
- DefaultIssue raw = new DefaultIssue()
- .setNew(true)
- .setKey("RAW_KEY")
- .setRuleKey(XOO_X1)
- .setCreationDate(parseDate("2015-10-01"))
- .setUpdateDate(parseDate("2015-10-02"))
- .setCloseDate(parseDate("2015-10-03"));
-
- DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder()
- .setTextRange(DbCommons.TextRange.newBuilder()
- .setStartLine(10)
- .setEndLine(12)
- .build())
- .build();
- DefaultIssue base = new DefaultIssue()
- .setKey("BASE_KEY")
- .setType(RuleType.VULNERABILITY)
- // First analysis before rule was changed to hotspot
- .setIsFromHotspot(false)
- .setCreationDate(parseDate("2015-01-01"))
- .setUpdateDate(parseDate("2015-01-02"))
- .setResolution(RESOLUTION_FALSE_POSITIVE)
- .setStatus(STATUS_RESOLVED)
- .setSeverity(BLOCKER)
- .setAssigneeUuid("base assignee uuid")
- .setAuthorLogin("base author")
- .setTags(newArrayList("base tag"))
- .setSelectedAt(1000L)
- .setLine(10)
- .setMessage("message")
- .setGap(15d)
- .setEffort(Duration.create(15L))
- .setManualSeverity(false)
- .setLocations(issueLocations);
-
- when(debtCalculator.calculate(raw)).thenReturn(DEFAULT_DURATION);
-
- underTest.mergeExistingOpenIssue(raw, base);
-
- assertThat(raw.isNew()).isFalse();
- assertThat(raw.key()).isEqualTo("BASE_KEY");
- assertThat(raw.creationDate()).isEqualTo(base.creationDate());
- assertThat(raw.updateDate()).isEqualTo(base.updateDate());
- assertThat(raw.assignee()).isEqualTo("base assignee uuid");
- assertThat(raw.authorLogin()).isEqualTo("base author");
- assertThat(raw.tags()).containsOnly("base tag");
- assertThat(raw.effort()).isEqualTo(DEFAULT_DURATION);
- assertThat(raw.selectedAt()).isEqualTo(1000L);
- assertThat(raw.isFromHotspot()).isTrue();
- assertThat(raw.isChanged()).isTrue();
-
- verify(updater).setType(raw, RuleType.SECURITY_HOTSPOT, issueChangeContext);
- verify(updater).setStatus(raw, STATUS_TO_REVIEW, issueChangeContext);
- verify(updater).setResolution(raw, null, issueChangeContext);
- verify(updater).setPastSeverity(raw, BLOCKER, issueChangeContext);
- verify(updater).setPastLine(raw, 10);
- verify(updater).setPastMessage(raw, "message", issueChangeContext);
- verify(updater).setPastEffort(raw, Duration.create(15L), issueChangeContext);
- verify(updater).setPastLocations(raw, issueLocations);
- }
-
- @Test
public void mergeExistingOpenIssue_with_manual_severity() {
DefaultIssue raw = new DefaultIssue()
.setNew(true)