Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Add Dialyzer plugin
Browse files Browse the repository at this point in the history
Build project-specific PLT
$ rebar build-plt

Check the PLT for consistency and rebuild it if it is not up-to-date
$ rebar check-plt

Analyze the code for discrepancies
$ rebar dialyze

Delete project-specific PLT
$ rebar delete-plt

Valid rebar.config options:
  %% Store PLT in ~/.rebar/plt (Default)
  {dialyzer_plt_location,shared}
  %% Store PLT locally inside the project in .rebar
  {dialyzer_plt_location,local}
  %% Store PLT in custom directory
  {dialyzer_plt_location,"custom_path"}
  {dialyzer_plt_extra_apps,[app1,app2]}
  {dialyzer_warnings,[unmatched_returns,error_handling]}
  • Loading branch information
Tuncer Ayaz committed May 22, 2015
1 parent 094b74e commit 850a8a3
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 49 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*.orig
.*.swp
/rt.work
/dialyzer_warnings
/rebar.cmd
/.eunit
/deps
Expand Down
41 changes: 5 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
.PHONY: clean dialyzer_warnings xref_warnings deps test test_eunit test_inttest
.PHONY: clean xref_warnings deps test test_eunit test_inttest

REBAR=$(PWD)/rebar
RETEST=$(PWD)/deps/retest/retest
OTPVSNCMD='io:fwrite("~s",[rebar_utils:otp_release()]), halt().'
OTPVSN=$(shell erl -pa ebin/ -noshell -eval $(OTPVSNCMD))
PLT_FILENAME=~/.dialyzer_rebar_$(OTPVSN)_plt
LOG_LEVEL?=debug
RT_TARGETS?=inttest

all:
./bootstrap

clean:
@rm -rf rebar ebin/*.beam inttest/rt.work rt.work .eunit
@rm -f .rebarinfo
@rm -rf rebar .rebar ebin/*.beam inttest/rt.work rt.work .eunit

distclean: clean
@rm -f dialyzer_warnings
@rm -rf deps

debug:
Expand All @@ -28,36 +23,10 @@ xref:
@./rebar xref

build_plt:
-dialyzer --build_plt --output_plt $(PLT_FILENAME) --apps \
erts \
kernel \
stdlib \
crypto \
compiler \
asn1 \
eunit \
tools \
ssl \
edoc \
reltool \
snmp \
sasl
-dialyzer --add_to_plt --plt $(PLT_FILENAME) \
--output_plt $(PLT_FILENAME) \
--apps diameter
@./rebar build-plt

dialyzer: dialyzer_warnings
@diff -U0 dialyzer_reference dialyzer_warnings

dialyzer_warnings:
-@dialyzer --plt $(PLT_FILENAME) -q -nn -n ebin \
-Wunmatched_returns \
-Werror_handling \
-Wrace_conditions \
> dialyzer_warnings

typer:
typer -r --plt $(PLT_FILENAME) ./src -I ./include
dialyzer:
@./rebar dialyze

binary: VSN = $(shell ./rebar -V)
binary: clean all
Expand Down
3 changes: 0 additions & 3 deletions dialyzer_reference

This file was deleted.

25 changes: 18 additions & 7 deletions ebin/rebar.app
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
rebar_cover_utils,
rebar_ct,
rebar_deps,
rebar_dialyzer,
rebar_edoc,
rebar_erlc_compiler,
rebar_erlydtl_compiler,
Expand Down Expand Up @@ -46,13 +47,22 @@
rebar_getopt,
rebar_mustache ]},
{registered, []},
{applications, [kernel,
stdlib,
sasl,
compiler,
crypto,
syntax_tools,
tools]},
{applications,
[
kernel,
stdlib,
sasl,
compiler,
crypto,
syntax_tools,
tools,
eunit,
reltool,
dialyzer,
asn1,
snmp,
edoc
]},
{env, [
%% Default log level
{log_level, warn},
Expand All @@ -76,6 +86,7 @@
rebar_neotoma_compiler,
rebar_asn1_compiler,
rebar_dia_compiler,
rebar_dialyzer,
rebar_erlc_compiler,
rebar_lfe_compiler,
rebar_erlydtl_compiler,
Expand Down
6 changes: 5 additions & 1 deletion priv/shell-completion/bash/rebar
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ _rebar()
--keep-going \
--recursive \
--version"
cmdsnvars="check-deps \
cmdsnvars=" \
build-plt \
check-deps \
clean \
compile \
check-plt \
create \
create-app \
create-lib \
create-node \
ct \
dialyze \
doc \
delete-deps \
escriptize \
Expand Down
5 changes: 4 additions & 1 deletion priv/shell-completion/zsh/_rebar
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ _rebar () {
case $state in
cmd_and_var)
_values -S = 'variables' \
'dialyze[Analyze the code for discrepancies]' \
'build-plt[Build project-specific PLT]' \
'check-plt[Check the plt for consistency and rebuild it if it is not up-to-date]' \
'clean[Clean]' \
'compile[Compile sources]' \
'create[Create skel based on template and vars]' \
'create-app[Create simple app skel]' \
'create-lib[Create simple lib skel]' \
'create-node[Create simple node skel]' \
'list-template[List avaiavle templates]' \
'list-template[List available templates]' \
'doc[Generate Erlang program documentation]' \
'check-deps[Display to be fetched dependencies]' \
'prepare-deps[Fetch and build dependencies]' \
Expand Down
12 changes: 12 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@
- (\"diameter_dict_util\":\"format_error\"/\"1\")
- (\"diameter_dict_util\":\"parse\"/\"2\"))",
[]}]}.

{dialyzer_plt_extra_apps,
[
diameter
]}.

{dialyzer_warnings,
[
unmatched_returns,
error_handling,
race_conditions
]}.
16 changes: 16 additions & 0 deletions rebar.config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,19 @@
{xref_queries,
[{"(XC - UC) || (XU - X - B"
" - (\"mod\":\".*foo\"/\"4\"))",[]}]}.

%% == Dialyzer ==

%% Store PLT in ~/.rebar/plt (Default)
{dialyzer_plt_location, shared}.

%% Store PLT locally inside the project in .rebar
{dialyzer_plt_location, local}.

%% Store PLT in custom directory
{dialyzer_plt_location, "custom_path"}.

%% Extra apps to include in the PLT
{dialyzer_plt_extra_apps, [app1, app2]}.

{dialyzer_warnings, [unmatched_returns, error_handling]}.
10 changes: 10 additions & 0 deletions src/rebar.erl
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ qc Test QuickCheck properties
xref Run cross reference analysis
dialyze Analyze the code for discrepancies
build-plt Build project-specific PLT
check-plt Check the PLT for consistency and
rebuild it if it is not up-to-date
delete-plt Delete project-specific PLT
shell Start a shell similar to
'erl -pa ebin -pa deps/*/ebin'
Expand Down Expand Up @@ -527,15 +533,19 @@ filter_flags(Config, [Item | Rest], Commands) ->

command_names() ->
[
"build-plt",
"check-deps",
"check-plt",
"clean",
"compile",
"create",
"create-app",
"create-lib",
"create-node",
"ct",
"delete-plt",
"delete-deps",
"dialyze",
"doc",
"eunit",
"escriptize",
Expand Down
Loading

0 comments on commit 850a8a3

Please sign in to comment.