<commit_before>%% Code for testing during development. Finds misspelled function 
%% names and incorrect arity usage. It requiers that the modules 
%% tested, have already been debug compiled - use erlc with the 
%% +debug_info flag, e.g. :
%% 
%% erlc +debug_info xxxx.erl
%%
%% This code assumes that the current directory (when calling 
%% xref_test:run) is the build folder (the directory where the .beam 
%% files are). 
%% This code has been tested on my (hsten) local machine, with a
%%
%% > cd src
%% > erlc -W +debug_info *.erl
%% > erl
%% 1> xref_test:run().
%%
%% in the source directory, but should also work in the build 
%% directory using the yxa Makefile to compile it.
%%--------------------------------------------------------------------

-module(xref_test).

%%--------------------------------------------------------------------
%% External exports
%%--------------------------------------------------------------------
-export([
	 run/0
	]).

%%--------------------------------------------------------------------
%% Internal exports
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Include files
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Records
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Macros
%%--------------------------------------------------------------------

%%====================================================================
%% External functions
%%====================================================================

%%--------------------------------------------------------------------
%% Function: run()
%% Descrip.: run xref on yxa code, to look for bugs
%% Returns : -
%%--------------------------------------------------------------------
run() ->

    Xref = foobar,  

    %% stop any old xref process
    xref:stop(Xref),
    %% start new "empty" xref process
    xref:start(Xref, {xref_mode, functions}),

    %% add path to OTP modules - they should not be detected as unkown modules
    OTP = code:get_path(),
    xref:set_library_path(Xref, OTP, [{verbose, true}]),


    AddOptions = [
		  {builtins, false}, 
		  {recurse, false}, 
		  {verbose, true}, 
		  {warnings, true}
		 ],

    %% tell xref where to look for modules to check    
    Res = xref:add_directory(Xref, ".", []), 
    io:format("add_directory: ~n~p~n", [Res]),
    


    %% determine which properties to check with xref
    Analysis = [
		undefined_function_calls,
		undefined_functions,
		locals_not_used,

		%% this lists lots of functions - some are exported 
		%% behaviour callbacks, others are unused functions intended
		%% for future use (to expose a useful interface to the module)
		%% and some are probably callback functions not related to
		%% behaviours.

		%% exports_not_used, 
		deprecated_function_calls, 
		deprecated_functions 
		
		%% {deprecated_function_calls, DeprFlag}, 
		%% {deprecated_functions, DeprFlag}, 
		%% {call, FuncSpec}, 
		%% {use, FuncSpec}, 
		%% {module_call, ModSpec}, 
		%% {module_use, ModSpec}, 
		%% {application_call, AppSpec}, 
		%% {application_use, AppSpec}, 
		%% {release_call, RelSpec}, 
		%% {release_use, RelSpec} 
	       ],<commit_msg>Handle recursive operations, and make work. Committing for <NAME> <<EMAIL>>.<commit_after>%% Code for testing during development. Finds misspelled function 
%% names and incorrect arity usage. It requiers that the modules 
%% tested, have already been debug compiled - use erlc with the 
%% +debug_info flag, e.g. :
%% 
%% erlc +debug_info xxxx.erl
%%
%% This code assumes that the current directory (when calling 
%% xref_test:run) is the build folder (the directory where the .beam 
%% files are). 
%% This code has been tested on my (hsten) local machine, with a
%%
%% > cd src
%% > erlc -W +debug_info *.erl
%% > erl
%% 1> xref_test:run().
%%
%% in the source directory, but should also work in the build 
%% directory using the yxa Makefile to compile it.
%%--------------------------------------------------------------------

-module(xref_test).

%%--------------------------------------------------------------------
%% External exports
%%--------------------------------------------------------------------
-export([
	 run/0
	]).

%%--------------------------------------------------------------------
%% Internal exports
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Include files
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Records
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Macros
%%--------------------------------------------------------------------

%%====================================================================
%% External functions
%%====================================================================

%%--------------------------------------------------------------------
%% Function: run()
%% Descrip.: run xref on yxa code, to look for bugs
%% Returns : -
%%--------------------------------------------------------------------
run() ->

    Xref = foobar,  

    %% stop any old xref process
    try xref:stop(Xref)
    catch
	throw: _ -> ok;
	  error: _ -> ok;
	  exit: _ -> ok
    end,
    %% start new "empty" xref process
    xref:start(Xref, {xref_mode, functions}),

    %% add path to OTP modules - they should not be detected as unkown modules
    OTP = code:get_path(),
    xref:set_library_path(Xref, OTP, [{verbose, true}]),


    AddOptions = [
		  {builtins, false}, 
		  {recurse, false}, 
		  {verbose, true}, 
		  {warnings, true}
		 ],

    %% tell xref where to look for modules to check    
    Res = xref:add_directory(Xref, ".", [{recurse, true}]), 
    io:format("add_directory: ~n~p~n", [Res]),
    


    %% determine which properties to check with xref
    Analysis = [
		undefined_function_calls,
		undefined_functions,
		locals_not_used,

		%% this lists lots of functions - some are exported 
		%% behaviour callbacks, others are unused functions intended
		%% for future use (to expose a useful interface to the module)
		%% and some are probably callback functions not related to
		%% behaviours.

		%% exports_not_used, 
		deprecated_function_calls, 
		deprecated_functions 
		
		%% {deprecated_function_calls, DeprFlag}, 
		%% {deprecated_functions, DeprFlag}, 
		%% {call, FuncSpec}, 
		%% {use, FuncSpec}, 
		%% {module_call, ModSpec}, 
		%% {module_use, ModSpec}, 
		%% {application_call, AppSpec}, 
		%% {application_use, AppSpec}, 
		%% {release_call, RelSpec}, 
		%% {release_use, RelSpec} 
	       ],
{'fraction_non_alphanumeric': 0.38602258110618837, 'fraction_numerical': 0.0005716735743890238, 'mean_word_length': 1.409779614325069, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3339402', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1630, 'n_words': 522}