<commit_before>defmodule Samuel.Checks.HasComments do
  @moduledoc """
  A check ensures a Pull Request has been commented on by at least one person.
  """

  @behaviour Samuel.Check

  alias Samuel.Action

  def check(data) do
    case other_user_comments(data) do
      0 ->
        action(data.event)
      _ ->
        nil
    end
  end

  def action(event) do
    %Action{
      action: :post_comment,
      repo: event["repository"]["full_name"],
      pull_id: event["pull_request"]["number"],
      message: """
      I don't see any comments on your Pull Request.

      Are you too good for code reviews now?
      No. No you aren't.

      Maybe you forgot to say who reviewed it. That's fine, but let me know.
      """
    }
  end

  def requirements do
    ~w(commit_comments pr_comments)a
  end

  defp all_comments(data) do
    data.commit_comments ++ data.pr_comments
  end

  # Returns the number of comments made by someone who is not the Pull Request
  # author or Samuel.
  defp other_user_comments(data) do
    users_that_dont_count = users_that_dont_count(data.event)

    all_comments(data)
    |> Enum.map(fn(c) -> c["user"]["login"] end)
    |> Enum.filter(fn(u) ->
      Enum.all?(users_that_dont_count, fn(n) -> n != u end)
    end)
    |> Enum.count
  end

  # List of users whose comments do not count towards the comment count.
  defp users_that_dont_count(event) do
    [
      "reevoo-samuel",
      event["pull_request"]["user"]["login"] # Author
    ]
  end
end<commit_msg>Pipe that mutha<commit_after>defmodule Samuel.Checks.HasComments do
  @moduledoc """
  A check ensures a Pull Request has been commented on by at least one person.
  """

  @behaviour Samuel.Check

  alias Samuel.Action

  def check(data) do
    case other_user_comments(data) do
      0 ->
        action(data.event)
      _ ->
        nil
    end
  end

  def action(event) do
    %Action{
      action: :post_comment,
      repo: event["repository"]["full_name"],
      pull_id: event["pull_request"]["number"],
      message: """
      I don't see any comments on your Pull Request.

      Are you too good for code reviews now?
      No. No you aren't.

      Maybe you forgot to say who reviewed it. That's fine, but let me know.
      """
    }
  end

  def requirements do
    ~w(commit_comments pr_comments)a
  end

  defp all_comments(data) do
    data.commit_comments ++ data.pr_comments
  end

  # Returns the number of comments made by someone who is not the Pull Request
  # author or Samuel.
  defp other_user_comments(data) do
    users_that_dont_count = users_that_dont_count(data.event)

    data
    |> all_comments
    |> Enum.map(fn(c) -> c["user"]["login"] end)
    |> Enum.filter(fn(u) ->
      Enum.all?(users_that_dont_count, fn(n) -> n != u end)
    end)
    |> Enum.count
  end

  # List of users whose comments do not count towards the comment count.
  defp users_that_dont_count(event) do
    [
      "reevoo-samuel",
      event["pull_request"]["user"]["login"] # Author
    ]
  end
end
{'fraction_non_alphanumeric': 0.10251322751322751, 'fraction_numerical': 0.0006613756613756613, 'mean_word_length': 2.7116564417177913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5304151', 'n_tokens_mistral': 996, 'n_tokens_neox': 975, 'n_words': 298}