Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-9692 - Perform issue tracking for short living branches
- Loading branch information
Showing
21 changed files
with
850 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...n/java/org/sonar/server/computation/task/projectanalysis/issue/ComponentIssuesLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,67 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 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.server.computation.task.projectanalysis.issue; | |||
|
|||
import java.util.ArrayList; | |||
import java.util.List; | |||
|
|||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rule.RuleStatus; | |||
import org.sonar.core.issue.DefaultIssue; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.issue.IssueMapper; | |||
import org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRulesHolder; | |||
|
|||
public class ComponentIssuesLoader { | |||
private final DbClient dbClient; | |||
private final RuleRepository ruleRepository; | |||
private final ActiveRulesHolder activeRulesHolder; | |||
|
|||
public ComponentIssuesLoader(DbClient dbClient, RuleRepository ruleRepository, ActiveRulesHolder activeRulesHolder) { | |||
this.activeRulesHolder = activeRulesHolder; | |||
this.dbClient = dbClient; | |||
this.ruleRepository = ruleRepository; | |||
} | |||
|
|||
public List<DefaultIssue> loadForComponentUuid(String componentUuid) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
List<DefaultIssue> result = new ArrayList<>(); | |||
dbSession.getMapper(IssueMapper.class).scrollNonClosedByComponentUuid(componentUuid, resultContext -> { | |||
DefaultIssue issue = (resultContext.getResultObject()).toDefaultIssue(); | |||
|
|||
// TODO this field should be set outside this class | |||
if (!isActive(issue.ruleKey()) || ruleRepository.getByKey(issue.ruleKey()).getStatus() == RuleStatus.REMOVED) { | |||
issue.setOnDisabledRule(true); | |||
// TODO to be improved, why setOnDisabledRule(true) is not enough ? | |||
issue.setBeingClosed(true); | |||
} | |||
// FIXME | |||
issue.setSelectedAt(System.currentTimeMillis()); | |||
result.add(issue); | |||
}); | |||
return result; | |||
} | |||
} | |||
|
|||
private boolean isActive(RuleKey ruleKey) { | |||
return activeRulesHolder.get(ruleKey).isPresent(); | |||
} | |||
} |
55 changes: 55 additions & 0 deletions
55
...in/java/org/sonar/server/computation/task/projectanalysis/issue/DefaultTrackingInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2017 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.server.computation.task.projectanalysis.issue; | |||
|
|||
import java.util.Collection; | |||
|
|||
import org.sonar.core.issue.DefaultIssue; | |||
import org.sonar.core.issue.tracking.BlockHashSequence; | |||
import org.sonar.core.issue.tracking.Input; | |||
import org.sonar.core.issue.tracking.LineHashSequence; | |||
|
|||
public class DefaultTrackingInput implements Input<DefaultIssue> { | |||
private final Collection<DefaultIssue> issues; | |||
private final LineHashSequence lineHashes; | |||
private final BlockHashSequence blockHashes; | |||
|
|||
public DefaultTrackingInput(Collection<DefaultIssue> issues, LineHashSequence lineHashes, BlockHashSequence blockHashes) { | |||
this.issues = issues; | |||
this.lineHashes = lineHashes; | |||
this.blockHashes = blockHashes; | |||
} | |||
|
|||
@Override | |||
public LineHashSequence getLineHashSequence() { | |||
return lineHashes; | |||
} | |||
|
|||
@Override | |||
public BlockHashSequence getBlockHashSequence() { | |||
return blockHashes; | |||
} | |||
|
|||
@Override | |||
public Collection<DefaultIssue> getIssues() { | |||
return issues; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.