From d57ad836112d5a3748cf98c27772a792ed2fadb4 Mon Sep 17 00:00:00 2001 From: Andrew Summers Date: Wed, 22 Nov 2017 19:26:56 -0500 Subject: [PATCH] Resolved more dialyzer errors. --- .../github/event/issue_comment/issue_comment.ex | 13 +++++++------ lib/code_corps/github/event/issues/issues.ex | 15 +++++++-------- .../github/event/pull_request/pull_request.ex | 15 +++++++-------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lib/code_corps/github/event/issue_comment/issue_comment.ex b/lib/code_corps/github/event/issue_comment/issue_comment.ex index 7f3115e03..1d0e0323b 100644 --- a/lib/code_corps/github/event/issue_comment/issue_comment.ex +++ b/lib/code_corps/github/event/issue_comment/issue_comment.ex @@ -1,6 +1,7 @@ defmodule CodeCorps.GitHub.Event.IssueComment do @moduledoc ~S""" In charge of handling a GitHub Webhook payload for the IssueComment event type + [https://developer.github.com/v3/activity/events/types/#issuecommentevent](https://developer.github.com/v3/activity/events/types/#issuecommentevent) """ @@ -12,8 +13,6 @@ defmodule CodeCorps.GitHub.Event.IssueComment do } alias GitHub.Sync - @type outcome :: Sync.outcome | {:error, :unexpected_payload} - @doc ~S""" Handles the "IssueComment" GitHub webhook @@ -23,7 +22,8 @@ defmodule CodeCorps.GitHub.Event.IssueComment do - validate the action is properly supported - sync the comment using `CodeCorps.GitHub.Sync.Comment` """ - @spec handle(map) :: outcome + @impl CodeCorps.GitHub.Event.Handler + @spec handle(map) :: {:ok, any} | {:error, atom} def handle(payload) do with {:ok, :valid} <- validate_payload(payload) do Sync.issue_comment_event(payload) @@ -34,9 +34,10 @@ defmodule CodeCorps.GitHub.Event.IssueComment do @spec validate_payload(map) :: {:ok, :valid} | {:error, :unexpected_payload} defp validate_payload(%{} = payload) do - case payload |> Validator.valid? do - true -> {:ok, :valid} - false -> {:error, :unexpected_payload} + if Validator.valid?(payload) do + {:ok, :valid} + else + {:error, :unexpected_payload} end end end diff --git a/lib/code_corps/github/event/issues/issues.ex b/lib/code_corps/github/event/issues/issues.ex index 73a1ecc5f..9f558e943 100644 --- a/lib/code_corps/github/event/issues/issues.ex +++ b/lib/code_corps/github/event/issues/issues.ex @@ -13,8 +13,6 @@ defmodule CodeCorps.GitHub.Event.Issues do } alias GitHub.Sync - @type outcome :: Sync.outcome | {:ok, :ignored} | {:error, :unexpected_payload} - @doc ~S""" Handles the "Issues" GitHub webhook @@ -24,7 +22,8 @@ defmodule CodeCorps.GitHub.Event.Issues do - validate the action is properly supported - sync the issue using `CodeCorps.GitHub.Sync.Issue` """ - @spec handle(map) :: outcome + @impl CodeCorps.GitHub.Event.Handler + @spec handle(map) :: {:ok, any} | {:error, atom} def handle(payload) do with {:ok, :valid} <- validate_payload(payload) do Sync.issue_event(payload) @@ -33,12 +32,12 @@ defmodule CodeCorps.GitHub.Event.Issues do end end - @spec validate_payload(map) :: {:ok, :valid} - | {:error, :unexpected_payload} + @spec validate_payload(map) :: {:ok, :valid} | {:error, :unexpected_payload} defp validate_payload(%{} = payload) do - case payload |> Validator.valid? do - true -> {:ok, :valid} - false -> {:error, :unexpected_payload} + if Validator.valid?(payload) do + {:ok, :valid} + else + {:error, :unexpected_payload} end end end diff --git a/lib/code_corps/github/event/pull_request/pull_request.ex b/lib/code_corps/github/event/pull_request/pull_request.ex index 442603c0e..88c784eb4 100644 --- a/lib/code_corps/github/event/pull_request/pull_request.ex +++ b/lib/code_corps/github/event/pull_request/pull_request.ex @@ -13,8 +13,6 @@ defmodule CodeCorps.GitHub.Event.PullRequest do } alias GitHub.Sync - @type outcome :: Sync.outcome | {:error, :unexpected_payload} - @doc ~S""" Handles the "PullRequest" GitHub webhook @@ -24,7 +22,8 @@ defmodule CodeCorps.GitHub.Event.PullRequest do - validate the action is properly supported - sync the pull request using `CodeCorps.GitHub.Sync.PullRequest` """ - @spec handle(map) :: outcome + @impl CodeCorps.GitHub.Event.Handler + @spec handle(map) :: {:ok, any} | {:error, atom} def handle(payload) do with {:ok, :valid} <- validate_payload(payload) do Sync.pull_request_event(payload) @@ -33,12 +32,12 @@ defmodule CodeCorps.GitHub.Event.PullRequest do end end - @spec validate_payload(map) :: {:ok, :valid} - | {:error, :unexpected_payload} + @spec validate_payload(map) :: {:ok, :valid} | {:error, :unexpected_payload} defp validate_payload(%{} = payload) do - case payload |> Validator.valid? do - true -> {:ok, :valid} - false -> {:error, :unexpected_payload} + if Validator.valid?(payload) do + {:ok, :valid} + else + {:error, :unexpected_payload} end end end