Skip to content

Commit

Permalink
Resolved more dialyzer errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
asummers committed Nov 23, 2017
1 parent 61c558e commit d57ad83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
13 changes: 7 additions & 6 deletions lib/code_corps/github/event/issue_comment/issue_comment.ex
Original file line number Diff line number Diff line change
@@ -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)
"""

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
15 changes: 7 additions & 8 deletions lib/code_corps/github/event/issues/issues.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
15 changes: 7 additions & 8 deletions lib/code_corps/github/event/pull_request/pull_request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

0 comments on commit d57ad83

Please sign in to comment.