public class SonarLintTest {
private static final List<String> VALUES = Arrays.asList("VAL1", "VAL2", "VAL3");
private static class Value {
private String region;
private String description;
private String detail;
}
/**
* Test of squid:3516
* @param parValues list of values
* @return true if the list contains items with all 3 details
*/
public boolean testInvariant(final List<Value> parValues) {
if (parValues == null || parValues.isEmpty() || parValues.size() < VALUES.size()) {
return false;
}
boolean val1Found = false;
boolean val2Found = false;
boolean val3Found = false;
for (Value val : parValues) {
if (checkValue(val)) { // without this additional check squid:S3516 is not raised
if ("VAL1".equalsIgnoreCase(val.detail)) {
val1Found = true;
} else if ("VAL2".equalsIgnoreCase(val.detail)) {
val2Found = true;
} else if ("VAL3".equalsIgnoreCase(val.detail)) {
val3Found = true;
}
}
}
return val1Found && val2Found && val3Found;
}
private boolean checkValue(final Value parValue) {
return parValue.description != null && parValue.region != null;
}
}
--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/5a77231f-dca5-4daf-9fae-8ee23a73dd29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.