@Override
  public void publish(ScannerReportWriter writer) {
    Optional<String> targetBranch = getTargetBranch();
    if (targetBranch.isPresent()) {
      Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
      int count = writeChangedLines(scmConfiguration.provider(), writer, targetBranch.get());
      LOG.debug("SCM reported changed lines for {} {} in the branch", count, ScannerUtils.pluralize("file", count));
      profiler.stopInfo();
    }
  }
@Test
  public void do_not_write_last_line_as_changed_if_its_not_empty() {
    DefaultInputFile fileWithChangedLines = createInputFile("path1", "l1\nl2\nl3\nl4");
    DefaultInputFile fileWithoutChangedLines = createInputFile("path2", "l1\nl2\nl3\nl4");
    Set<Path> paths = new HashSet<>(Arrays.asList(BASE_DIR.resolve("path1"), BASE_DIR.resolve("path2")));
    Set<Integer> lines = new HashSet<>(Arrays.asList(1, 2, 3));
    when(provider.branchChangedLines(TARGET_BRANCH, BASE_DIR, paths)).thenReturn(Collections.singletonMap(BASE_DIR.resolve("path1"), lines));
    when(inputComponentStore.allChangedFilesToPublish()).thenReturn(Arrays.asList(fileWithChangedLines, fileWithoutChangedLines));

    publisher.publish(writer);

    assertPublished(fileWithChangedLines, new HashSet<>(Arrays.asList(1, 2, 3)));
    assertPublished(fileWithoutChangedLines, Collections.emptySet());
  }