diff options
author | Vlad Ionescu <vlad@lshift.net> | 2009-09-02 20:01:38 +0100 |
---|---|---|
committer | Vlad Ionescu <vlad@lshift.net> | 2009-09-02 20:01:38 +0100 |
commit | b45448edcab38ae2c9a3ca52c450106a1ecf2634 (patch) | |
tree | c858d4c92f879c99cf370d17580a35b39e2fd5a7 /src | |
parent | f6768066d5c604ced90def93d78541f0eb25a492 (diff) | |
download | rabbitmq-server-b45448edcab38ae2c9a3ca52c450106a1ecf2634.tar.gz |
moving dialyzer stuff to src/rabbit_dialyzer.erl
Diffstat (limited to 'src')
-rw-r--r-- | src/rabbit_dialyzer.erl | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/rabbit_dialyzer.erl b/src/rabbit_dialyzer.erl new file mode 100644 index 00000000..cc3aaf12 --- /dev/null +++ b/src/rabbit_dialyzer.erl @@ -0,0 +1,93 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License at +%% http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +%% License for the specific language governing rights and limitations +%% under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developers of the Original Code are LShift Ltd, +%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, +%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd +%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial +%% Technologies LLC, and Rabbit Technologies Ltd. +%% +%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Ltd. Portions created by Cohesive Financial Technologies LLC are +%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% LLC. Portions created by Rabbit Technologies Ltd are Copyright +%% (C) 2007-2009 Rabbit Technologies Ltd. +%% +%% All Rights Reserved. +%% +%% Contributor(s): ______________________________________. +%% + +-module(rabbit_dialyzer). +-include("rabbit.hrl"). + +-export([create_basic_plt/1, update_plt/2, dialyze_files/2]). + +%%---------------------------------------------------------------------------- + +-ifdef(use_specs). + +-spec(create_basic_plt/1 :: (string()) -> 'ok'). +-spec(update_plt/2 :: (string(), string()) -> 'ok'). +-spec(dialyze_files/2 :: (string(), string()) -> 'ok'). + +-endif. + +%%---------------------------------------------------------------------------- + +create_basic_plt(BasicPltPath) -> + OptsRecord = dialyzer_options:build([ + {analysis_type, plt_build}, + {init_plt, BasicPltPath}, + {files_rec, otp_apps_dependencies_paths()}]), + dialyzer_cl:start(OptsRecord), + ok. + +update_plt(PltPath, ModifiedFiles) -> + {ok, Files} = regexp:split(ModifiedFiles, " "), + DialyzerWarnings = dialyzer:run([ + {analysis_type, plt_add}, + {init_plt, PltPath}, + {files, Files}]), + print_warnings(DialyzerWarnings), + ok. + +dialyze_files(PltPath, ModifiedFiles) -> + {ok, Files} = regexp:split(ModifiedFiles, " "), + DialyzerWarnings = dialyzer:run([ + {init_plt, PltPath}, + {files, Files}]), + case DialyzerWarnings of + [] -> + io:format("Ok, dialyzer returned no warnings.~n", []), + ok; + _ -> + io:format("~nFAILED! dialyzer returned the following warnings:~n", []), + print_warnings(DialyzerWarnings), + erlang:error({dialyzer_warnings, DialyzerWarnings}) + end. + +print_warnings(DialyzerWarnings) -> + lists:foreach( + fun + (Warning) -> io:format("~s", [dialyzer:format_warning(Warning)]) + end, + DialyzerWarnings), + io:format("~n", []), + ok. + +otp_apps_dependencies_paths() -> + lists:map( + fun(App) -> code:lib_dir(App, ebin) end, + [stdlib, kernel, mnesia, os_mon, ssl, eunit, tools, sasl]). |