Skip to content

Commit

Permalink
Fix Dialyzer, Remove Dead Code
Browse files Browse the repository at this point in the history
  • Loading branch information
maennchen committed Jan 22, 2017
1 parent 55c2b4d commit 022dd16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
14 changes: 7 additions & 7 deletions lib/crontab/cron_expression.ex
Expand Up @@ -8,13 +8,13 @@ defmodule Crontab.CronExpression do
@type t :: %Crontab.CronExpression{
extended: boolean,
reboot: boolean,
second: value,
minute: value,
hour: value,
day: value,
month: value,
weekday: value,
year: value
second: [value],
minute: [value],
hour: [value],
day: [value],
month: [value],
weekday: [value],
year: [value]
}
@type interval :: :second | :minute | :hour | :day | :month | :weekday | :year
@type min_max :: {:-, time_unit, time_unit}
Expand Down
12 changes: 6 additions & 6 deletions lib/crontab/cron_expression/parser.ex
Expand Up @@ -112,7 +112,7 @@ defmodule Crontab.CronExpression.Parser do
end
end

@spec interpret([binary], [CronExpression.interval], CronExpression.t) :: CronExpression.t | {:error, binary}
@spec interpret([binary], [CronExpression.interval], CronExpression.t) :: {:ok, CronExpression.t} | {:error, binary}
defp interpret([head_format | tail_format], [head_expression | tail_expression], cron_expression) do
conditions = interpret head_expression, head_format
case conditions do
Expand All @@ -128,17 +128,17 @@ defmodule Crontab.CronExpression.Parser do
defp interpret(interval, format) do
parts = String.split(format, ",")
tokens = Enum.map(parts, fn(part) -> tokenize interval, part end)
if has_failed_tokens(tokens) do
has_failed_tokens(tokens)
if get_failed_token(tokens) do
get_failed_token(tokens)
else
{:ok, Enum.map(tokens, fn({:ok, token}) -> token end)}
end
end

@spec has_failed_tokens([{:error, binary}] | CronExpression.value) :: boolean | binary
defp has_failed_tokens(tokens) do
@spec get_failed_token([{:error, binary}] | CronExpression.value) :: {:error, binary} | nil
defp get_failed_token(tokens) do
Enum.find(tokens, fn(token) -> case token do
failed_token = {:error, _} -> failed_token
{:error, _} -> true
_ -> false
end end)
end
Expand Down
1 change: 0 additions & 1 deletion lib/crontab/scheduler.ex
Expand Up @@ -290,7 +290,6 @@ defmodule Crontab.Scheduler do
defp reset(date = %NaiveDateTime{minute: minute}, :minutes), do: date |> reset(:seconds) |> Timex.shift(minutes: 0 - minute)

@spec upper(NaiveDateTime.t, :microseconds | :seconds | :minutes) :: NaiveDateTime.t
defp upper(date = %NaiveDateTime{}, :microseconds), do: Map.put(date, :microsecond, {0,0})
defp upper(date = %NaiveDateTime{second: second}, :seconds), do: date |> reset(:microseconds) |> Timex.shift(seconds: 59 - second)
defp upper(date = %NaiveDateTime{minute: minute}, :minutes), do: date |> reset(:seconds) |> Timex.shift(minutes: 59 - minute)

Expand Down

0 comments on commit 022dd16

Please sign in to comment.