use of org.sonar.java.se.checks.StreamConsumedCheck.StreamPipelineConstraint.NOT_CONSUMED in project sonar-java by SonarSource.
the class StreamNotConsumedCheck method checkEndOfExecutionPath.
@Override
public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) {
if (context.getState().exitValue() instanceof SymbolicValue.ExceptionalSymbolicValue) {
// don't report when exiting on exception
return;
}
ProgramState state = context.getState();
List<SymbolicValue> notConsumed = state.getValuesWithConstraints(NOT_CONSUMED);
notConsumed.forEach(sv -> {
Set<Flow> flows = FlowComputation.flow(context.getNode(), Collections.singleton(sv), NOT_CONSUMED::equals, NOT_CONSUMED::equals, Collections.singletonList(StreamConsumedCheck.StreamPipelineConstraint.class), Collections.emptySet());
Flow flow = flows.iterator().next();
JavaFileScannerContext.Location location = flow.elements().get(0);
reportIssue(location.syntaxNode, "Refactor the code so this stream pipeline is used.");
});
}
Aggregations