package org.sonar.plugins.stash;

import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.issue.Issue;

public class StashPluginUtils {

  private static final Logger LOGGER = LoggerFactory.getLogger(StashPluginUtils.class);

  private StashPluginUtils() {}

  public static String formatPercentage(double d) {
    DecimalFormat df = new DecimalFormat("0.0");
    df.setRoundingMode(RoundingMode.HALF_UP);
    return df.format(d);
  }

  public static long countIssuesBySeverity(List<Issue> issues, final String severity) {
      return issues.stream().filter(i -> i.severity() == severity).count();
  }

  public static Map<String, Issue> getUniqueRulesBySeverity(List<Issue> issues, final String severity) {
    Map<String, Issue> result = new HashMap<>();

    for (Issue issue : getIssuesBySeverity(issues, severity)) {
      result.put(issue.ruleKey().toString(), issue);
    }

    return result;
  }

  public static List<Issue> getIssuesBySeverity(List<Issue> issues, String severity) {
    return issues.stream().filter(i -> i.severity() == severity).collect(Collectors.toList());
  }

}

@@ -773,34 +773,32 @@
 filter(i -%3E 
-i.
 severity
 () == severi
@@ -781,38 +781,42 @@
  -%3E severity
-() == 
+.equals(i.
 severity
 ).count();%0D%0A
@@ -799,24 +799,27 @@
 s(i.severity
+())
 ).count();%0D%0A
@@ -1265,26 +1265,24 @@
 er(i -%3E 
-i.
 severity
 () == se
@@ -1277,22 +1277,26 @@
 rity
-() == 
+.equals(i.
 severity
 ).co
@@ -1291,16 +1291,19 @@
 severity
+())
 ).collec

use equals() instead of ==