public boolean initAndAddIssue(Issue issue) {
    DefaultInputComponent inputComponent = (DefaultInputComponent) issue.primaryLocation().inputComponent();

    if (noSonar(inputComponent, issue)) {
      return false;
    }

    ActiveRule activeRule = activeRules.find(issue.ruleKey());
    if (activeRule == null) {
      // rule does not exist or is not enabled -> ignore the issue
      return false;
    }

    ScannerReport.Issue rawIssue = createReportIssue(issue, inputComponent.scannerId(), activeRule.severity());

    if (filters.accept(inputComponent, rawIssue)) {
      write(inputComponent.scannerId(), rawIssue);
      return true;
    }
    return false;
  }
@Test
  public void add_issue_flows_to_cache() {
    initModuleIssues();

    DefaultMessageFormatting messageFormatting = new DefaultMessageFormatting().start(0).end(4).type(CODE);
    DefaultIssue issue = new DefaultIssue(project)
      .at(new DefaultIssueLocation().on(file))
      // Flow without type
      .addFlow(List.of(new DefaultIssueLocation().on(file).at(file.selectLine(1)).message("Foo1", List.of(messageFormatting)),
        new DefaultIssueLocation().on(file).at(file.selectLine(2)).message("Foo2")))
      // Flow with type and description
      .addFlow(List.of(new DefaultIssueLocation().on(file)), NewIssue.FlowType.DATA, "description")
      // Flow with execution type and no description
      .addFlow(List.of(new DefaultIssueLocation().on(file)), NewIssue.FlowType.EXECUTION, null)
      .forRule(JAVA_RULE_KEY);

    when(filters.accept(any(InputComponent.class), any(ScannerReport.Issue.class))).thenReturn(true);
    moduleIssues.initAndAddIssue(issue);

    ArgumentCaptor<ScannerReport.Issue> argument = ArgumentCaptor.forClass(ScannerReport.Issue.class);
    verify(reportPublisher.getWriter()).appendComponentIssue(eq(file.scannerId()), argument.capture());
    List<ScannerReport.Flow> writtenFlows = argument.getValue().getFlowList();

    assertThat(writtenFlows)
      .extracting(ScannerReport.Flow::getDescription, ScannerReport.Flow::getType)
      .containsExactly(tuple("", FlowType.UNDEFINED), tuple("description", FlowType.DATA), tuple("", FlowType.EXECUTION));

    assertThat(writtenFlows.get(0).getLocationCount()).isEqualTo(2);
    assertThat(writtenFlows.get(0).getLocationList()).containsExactly(
      ScannerReport.IssueLocation.newBuilder()
        .setComponentRef(file.scannerId())
        .setMsg("Foo1")
        .addMsgFormatting(ScannerReport.MessageFormatting.newBuilder().setStart(0).setEnd(4).setType(ScannerReport.MessageFormattingType.CODE).build())
        .setTextRange(ScannerReport.TextRange.newBuilder().setStartLine(1).setEndLine(1).setEndOffset(3).build())
        .build(),
      ScannerReport.IssueLocation.newBuilder()
        .setComponentRef(file.scannerId())
        .setMsg("Foo2")
        .setTextRange(ScannerReport.TextRange.newBuilder().setStartLine(2).setEndLine(2).setEndOffset(3).build())
        .build());
  }