Skip to content

Commit 6e8cdfa

Browse files
authored
Merge pull request #10 from zhongwencool/fixed-dialyzer
Fixed dialyzer
2 parents 01f6918 + 4ae313b commit 6e8cdfa

4 files changed

Lines changed: 25 additions & 15 deletions

File tree

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ otp_release:
99
- 21.0
1010
script:
1111
- ./rebar3 as test get-deps
12+
- ./rebar3 xref
1213
- epmd -daemon
1314
- ./rebar3 as test proper -c
1415
- ./rebar3 as test ct -c
1516
- ./rebar3 as test cover
16-
- ./rebar3 as test coveralls send
17+
- ./rebar3 as test coveralls send

rebar.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@
1010
{cover_export_enabled , true}.
1111
{coveralls_coverdata , "_build/test/cover/*.coverdata"}. % or a string with wildcards or a list of files
1212
{coveralls_service_name , "travis-ci"}.
13+
14+
15+
{xref_warnings,true}.
16+
{xref_extra_paths,[]}.
17+
{xref_checks,[undefined_function_calls,undefined_functions,locals_not_used,
18+
deprecated_function_calls,
19+
deprecated_functions]}.

src/ecron.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{application, ecron,
22
[{description, "cron-like/crontab job scheduling library"},
3-
{vsn, "0.5.2"},
3+
{vsn, "0.5.3"},
44
{registered, [ecron_sup, ecron, ecron_monitor]},
55
{mod, {ecron_app, []}},
66
{applications, [kernel, stdlib, telemetry]},

src/ecron.erl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ month => '*' | [1..12 | {1..11, 2..12}, ...],
2323
day_of_month => '*' | [1..31 | {1..30, 2..31}, ...],
2424
day_of_week => '*' | [0..6 | {0..5, 1..6}, ...]}.
2525

26+
-type mfargs() :: {M :: module(), F :: atom(), A :: [term()]}.
2627
-type ecron() :: #{name => name(),
2728
crontab => crontab(),
2829
start_time => calendar:rfc3339_string() | unlimited,
2930
end_time => calendar:rfc3339_string() | unlimited,
30-
mfa => mfa(),
31+
mfa => mfargs(),
3132
type => cron | every}.
3233

3334
-type status() :: deactivate | activate.
@@ -49,31 +50,31 @@ next => [calendar:datetime()]}.
4950
-type options() :: [option()].
5051

5152
%% @equiv add(JobName, Spec, MFA, unlimited, unlimited, [])
52-
-spec add(name(), crontab_spec(), mfa()) ->
53+
-spec add(name(), crontab_spec(), mfargs()) ->
5354
{ok, name()} | {error, parse_error(), term()} | {error, already_exist}.
5455
add(JobName, Spec, MFA) ->
5556
add(JobName, Spec, MFA, unlimited, unlimited, []).
5657

5758
%% @equiv add_with_count(make_ref(), Spec, MFA, RunCount)
58-
-spec add_with_count(crontab_spec(), mfa(), pos_integer()) ->
59+
-spec add_with_count(crontab_spec(), mfargs(), pos_integer()) ->
5960
{ok, name()} | {error, parse_error(), term()}.
6061
add_with_count(Spec, MFA, RunCount) when is_integer(RunCount) ->
6162
add_with_count(make_ref(), Spec, MFA, RunCount).
6263

6364
%% @equiv add(make_ref(), Spec, MFA, unlimited, unlimited, [{max_count, RunCount}])
64-
-spec add_with_count(name(), crontab_spec(), mfa(), pos_integer()) ->
65+
-spec add_with_count(name(), crontab_spec(), mfargs(), pos_integer()) ->
6566
{ok, name()} | {error, parse_error(), term()}.
6667
add_with_count(JobName, Spec, MFA, RunCount) when is_integer(RunCount) ->
6768
add(JobName, Spec, MFA, unlimited, unlimited, [{max_count, RunCount}]).
6869

6970
%% @equiv add(make_ref(), Spec, MFA, Start, End, [])
70-
-spec add_with_datetime(crontab_spec(), mfa(), start_datetime(), end_datetime()) ->
71+
-spec add_with_datetime(crontab_spec(), mfargs(), start_datetime(), end_datetime()) ->
7172
{ok, name()} | {error, parse_error(), term()}.
7273
add_with_datetime(Spec, MFA, Start, End) ->
7374
add(make_ref(), Spec, MFA, Start, End, []).
7475

7576
%% @equiv add(JobName, Spec, MFA, Start, End, [])
76-
-spec add_with_datetime(name(), crontab_spec(), mfa(), start_datetime(), end_datetime()) ->
77+
-spec add_with_datetime(name(), crontab_spec(), mfargs(), start_datetime(), end_datetime()) ->
7778
{ok, name()} | {error, parse_error(), term()} | {error, already_exist}.
7879
add_with_datetime(JobName, Spec, MFA, Start, End) ->
7980
add(JobName, Spec, MFA, Start, End, []).
@@ -91,7 +92,7 @@ add_with_datetime(JobName, Spec, MFA, Start, End) ->
9192
%% </li>
9293
%% </ul>
9394
%%
94-
-spec add(name(), crontab_spec(), mfa(), start_datetime(), end_datetime(), options()) ->
95+
-spec add(name(), crontab_spec(), mfargs(), start_datetime(), end_datetime(), options()) ->
9596
{ok, name()} | {error, parse_error(), term()} | {error, already_exist}.
9697
add(JobName, Spec, MFA, Start, End, Option) ->
9798
case valid_datetime(Start, End) of
@@ -203,17 +204,18 @@ reload() ->
203204
-spec parse_spec(crontab_spec(), pos_integer()) ->
204205
{ok, #{type => cron | every, crontab => crontab_spec(), next => [calendar:rfc3339_string()]}} |
205206
{error, atom(), term()}.
206-
parse_spec({ok, Type, JobSpec}, Num) ->
207-
Job = #{type => Type, crontab => JobSpec},
208-
Next = ecron_tick:predict_datetime(Job, Num),
209-
{ok, Job#{next => Next}};
210-
parse_spec({error, _Field, _Value} = Error, _Num) -> Error;
211207
parse_spec(Spec, Num) when is_integer(Num) andalso Num > 0 ->
212-
parse_spec(parse_spec(Spec), Num).
208+
parse_spec_2(parse_spec(Spec), Num).
213209

214210
%%%===================================================================
215211
%%% Internal functions
216212
%%%===================================================================
213+
parse_spec_2({ok, Type, JobSpec}, Num) ->
214+
Job = #{type => Type, crontab => JobSpec},
215+
Next = ecron_tick:predict_datetime(Job, Num),
216+
{ok, Job#{next => Next}};
217+
parse_spec_2({error, _Field, _Value} = Error, _Num) -> Error.
218+
217219
%% @private
218220
valid_datetime(Start, End) ->
219221
case valid_datetime(Start) andalso valid_datetime(End) of

0 commit comments

Comments
 (0)