I am trying to get the total number of unresolved bugs and Vulnerabilities in the particular project using `sonar-ws-5.6.jar`.

I tried to pass the *type* as BUG to the search query. But still I am getting all the unresolved stuff. It is not taking the parameter type.

How to get the exact number of bugs and Vulnerabilities using Webservice?

Here is my code to connect to sonar and get the data.

```
import java.util.ArrayList;
import java.util.List;

import org.sonarqube.ws.Issues.SearchWsResponse;
import org.sonarqube.ws.client.HttpConnector;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.WsClientFactories;
import org.sonarqube.ws.client.issue.SearchWsRequest;

public class SonarTest {
    static String resourceKey = "com.company.projectname:parent";
    public static void main(String[] args) {                
        try {       
            // Get Issue
            HttpConnector httpConnector = HttpConnector.newBuilder().url("http://localhost:9000").credentials("admin", "admin").build();
            SearchWsRequest issueSearchRequest = new SearchWsRequest();
            issueSearchRequest.setPageSize(1000);
            issueSearchRequest.setResolved(false);
            List<String> bugTypesList = new ArrayList<String>();
            bugTypesList.add("BUG");
            issueSearchRequest.setTypes(bugTypesList);
            WsClient wsClient = WsClientFactories.getDefault().newClient(httpConnector);
            SearchWsResponse issuesResponse =  wsClient.issues().search(issueSearchRequest);
            System.out.println(issuesResponse.getIssuesList());

            System.out.println("DONE");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

Note: I am using sonarqube 5.6 with Java 1.8

As of now I am iterating the response and getting the count

```
List<Issue> issueList = issuesResponse.getIssuesList();
int bugCount = 0;
for(Issue issue : issueList){
   if(issue.getType() == RuleType.BUG){
          bugCount ++;
   }
}

```