Skip to content

Commit

Permalink
Fix #140 verify limit 10000
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrie-allaigre committed Sep 3, 2018
1 parent bcff434 commit 0b6272c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ Inspired by https://github.com/SonarCommunity/sonar-github

# Changelog

## Version 4.0.0-rc1
## Version 4.0.0-rc2

### Changed
- Update to sonarqube 7.0 plugin version

### Fixed
- Using properties instead of depending on the deprecated, work with SonarQube 7.2 #162 (Thanks dmarin)
- Using properties instead of depending on the deprecated, work with SonarQube 7.2 [#164](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/pull/164) (Thanks dmarin)
- Fix others deprecated
- Fix sonar issues limit 10000 [#140](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/issues/140)

**[Download 4.0.0-rc1](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/releases/download/4.0.0-rc1/sonar-gitlab-plugin-4.0.0-rc1.jar)**
**[Download 4.0.0-rc2](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/releases/download/4.0.0-rc2/sonar-gitlab-plugin-4.0.0-rc2.jar)**

## Version 3.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class SonarFacade {

private static final Logger LOG = Loggers.get(SonarFacade.class);
private static final String LOG_MSG = "{}: {} {} {}";
private static final int MAX_SEARCH_ISSUES = 10000;
private final GitLabPluginConfiguration gitLabPluginConfiguration;
private final WsClient wsClient;
private File projectBaseDir;
Expand Down Expand Up @@ -226,7 +227,6 @@ public List<Issue> getNewIssues() {
while (nbPage == null || page <= nbPage) {
Issues.SearchWsResponse searchWsResponse = searchIssues(projectKey, refName, page);
nbPage = computeNbPage(searchWsResponse.getTotal(), searchWsResponse.getPs());

issues.addAll(toIssues(searchWsResponse, refName));

page++;
Expand All @@ -252,7 +252,9 @@ private String toString(GetRequest getRequest) {
}

private int computeNbPage(long total, int pageSize) {
return (int) (total / (long) (pageSize + 1)) + 1;
int maxPage = (int) (MAX_SEARCH_ISSUES / (long) (pageSize + 1)) + 1;
int nbPage = (int) (total / (long) (pageSize + 1)) + 1;
return Math.min(nbPage, maxPage);
}

private List<Issue> toIssues(Issues.SearchWsResponse issuesSearchWsResponse, String branch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ public void testNotEmptyGetNewIssue() throws IOException {
Assertions.assertThat(issues.get(0).getFile().getAbsolutePath()).isEqualTo(new File(projectDir, "toto.java").getAbsolutePath());
}

@Test
public void test10000NewIssue() throws IOException {
Issues.SearchWsResponse.Builder builder = Issues.SearchWsResponse.newBuilder().setTotal(20000).setPs(100);
for (int i = 0; i < 100; i++) {
builder.addIssues(Issues.Issue.newBuilder().build());
}
Issues.SearchWsResponse searchWsResponse = builder.build();
for (int i = 0; i < 100; i++) {
sonar.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/x-protobuf").setBody(toBuffer(searchWsResponse)));
}
sonar.enqueue(new MockResponse().setResponseCode(400).setBody("{\"errors\":[{\"msg\":\"Can return only the first 10000 results. 10100th result asked.\"}]}"));

createReportTaskFile();

List<Issue> issues = sonarFacade.getNewIssues();
Assertions.assertThat(issues).isNotNull().hasSize(10000);
}

@Test
public void tesFullPageGetNewIssue() throws IOException {
tesFullPageGetNewIssueForQualifier(Qualifiers.FILE);
Expand Down

0 comments on commit 0b6272c

Please sign in to comment.