{min_otp_version, "19.0"}.

{deps, [
    {lager, "~>3.5"},
    {plumtree, "0.5.0"},
    {partisan, "1.3.3"},
    {types, "~> 0.1"},
    time_compat,
    rand_compat,
    lasp_support,
    {gen_flow, "~> 0.0"}
]}.

%% leex options
{xrl_opts, []}.
%% leex files to compile first
{xrl_first_files, ["src/lasp_sql_lexer.xrl"]}.

%% yecc options
{yrl_opts, []}.
%% yecc files to compile first
{yrl_first_files, ["src/lasp_sql_parser.yrl"]}.

{cover_enabled, true}.

{erl_opts, [debug_info,
            warnings_as_errors,
            nowarn_deprecated_function,
            {platform_define, "^[0-9]+", namespaced_types},
            {parse_transform, lager_transform}]}.
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{edoc_opts, [{preprocess, true}]}.

{profiles, [
    {exp,
     [{erl_opts, [{d, experiments}]},
      {deps, [{jsx, "2.8.0"},
              {erlcloud, "2.0.4"},
              {webmachine, {git, "https://github.com/webmachine/webmachine", {tag, "master"}}},
              {sprinter, {git, "git://github.com/lasp-lang/sprinter.git", {tag, "master"}}},
              {eredis, {git, "git://github.com/wooga/eredis.git", {tag, "master"}}}]},
      {src_dirs, ["src", "simulations"]},
      {extra_src_dirs, ["simulations"]},
      {relx, [{release, {lasp, "0.8.2"}, [erlcloud, jsx, webmachine, eredis, sprinter, jsx, lasp]},
              {extended_start_script, true},

              {dev_mode, true},
              {include_erts, false},

              {sys_config, "config/sys.config"},
              {vm_args, "config/vm.args"},

              {overlay, [{mkdir, "log/sasl"},
                      {mkdir, "data/"},
                      {copy, "bin/env", "bin"},
                      {copy, "bin/ienv", "bin"}
                      ]}]}
          ]},
    {test,
     [{erl_opts, [nowarn_export_all, nowarn_deprecated_function]},
      {deps, [{jsx, "2.8.0"},
              {erlcloud, "2.0.4"},
              {webmachine, {git, "https://github.com/webmachine/webmachine", {tag, "master"}}},
              {sprinter, {git, "git://github.com/lasp-lang/sprinter.git", {tag, "master"}}},
              {eredis, {git, "git://github.com/wooga/eredis.git", {tag, "master"}}}]},
      {extra_src_dirs, ["simulations"]}
     ]},
    {auto,  [
        {plugins, [rebar3_auto]}
    ]},
    {package,  [
        {plugins, [rebar3_hex]}
    ]},
    {lint,  [
        {plugins, [rebar3_lint]}
    ]},
    {docs, [
        {deps, [edown]}
    ]}
]}.

{elvis,
 [#{dirs => ["src"],
       filter => "*.erl",
       ignore => [lasp_sql_lexer, lasp_sql_parser],
       rules => [
                 %% {elvis_style, line_length,
                 %%  #{ignore => [],
                 %%    limit => 80,
                 %%    skip_comments => false}},
                 {elvis_style, no_tabs},
                 %% {elvis_style, no_trailing_whitespace},
                 {elvis_style, macro_names, #{ignore => []}},
                 %% {elvis_style, macro_module_names},
                 {elvis_style, operator_spaces, #{rules => [{right, ","},
                                                            {right, "++"},
                                                            {left, "++"}]}},
                 %% {elvis_style, nesting_level, #{level => 3}},
                 {elvis_style, god_modules,
                  #{limit => 25,
                    ignore => []}},
                 {elvis_style, no_if_expression},
                 %% {elvis_style, invalid_dynamic_call, #{ignore => []}},
                 %% {elvis_style, used_ignored_variable},
                 {elvis_style, no_behavior_info},
                 {
                   elvis_style,
                   module_naming_convention,
                   #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$",
                     ignore => []}
                 },
                 %% {
                 %%   elvis_style,
                 %%   function_naming_convention,
                 %%   #{regex => "^([a-z][a-z0-9]*_?)*$"}
                 %% },
                 {elvis_style, state_record_and_type},
                 {elvis_style, no_spec_with_records}
                 %% {elvis_style, dont_repeat_yourself, #{min_complexity => 10}}
                 %% {elvis_style, no_debug_call, #{ignore => []}}
                ]
      },
     #{dirs => ["."],
       filter => "Makefile",
       rules => [{elvis_project, no_deps_master_erlang_mk, #{ignore => []}},
                 {elvis_project, protocol_for_deps_erlang_mk, #{ignore => []}}]
      },
     #{dirs => ["."],
       filter => "rebar.config",
       rules => [{elvis_project, no_deps_master_rebar, #{ignore => []}},
                 {elvis_project, protocol_for_deps_rebar, #{ignore => []}}]
      }
    ]
}.

{relx, [{release, {lasp, "0.8.2"}, [lasp]},
        {extended_start_script, true},

        {dev_mode, true},
        {include_erts, false},

        {sys_config, "config/sys.config"},
        {vm_args, "config/vm.args"},

        {overlay, [{mkdir, "log/sasl"},
                   {mkdir, "data/"},
                   {copy, "bin/env", "bin"},
                   {copy, "bin/ienv", "bin"}
                  ]}]}.

{xref_checks, [undefined_function_calls, undefined_functions,
               deprecated_function_calls, deprecated_functions]}.
{xref_ignores, [{erlcloud_s3, configure, 3},
                {erlcloud_s3, create_bucket, 1},
                {erlcloud_s3, put_object, 3},
                {lasp_instrumentation, event_number, 1},
                {lasp_instrumentation, overcounting, 1},
                {eredis,q,2},
                {eredis,start_link,2},
                {lasp_advertisement_counter_server,stop_simulation,0},
                {lasp_advertisement_counter_server,wait_for_connectedness,0},
                {lasp_core,start,1},
                {lasp_default_broadcast_distribution_backend,init,1},
                {lasp_default_broadcast_distribution_backend,servers,0},
                {lasp_game_tournament_server,stop_simulation,0},
                {lasp_game_tournament_server,wait_for_connectedness,0},
                {lasp_instrumentation,batch,3},
                {lasp_instrumentation,event,1},
                {lasp_instrumentation,simulation_id,0},
                {lasp_plumtree_backend,servers,0},
                {lasp_state_based_synchronization_backend,handle_info,2},
                {lasp_status_resource,to_json,2},
                {lasp_support,push_logs,0},
                {lasp_throughput_client,log_batch,3},
                {lasp_throughput_client,log_event,1},
                {lasp_throughput_server,stop_simulation,0},
                {lasp_throughput_server,wait_for_connectedness,0},
                {lasp_workflow,handle_call,3},
                {lasp_workflow,init,1},
                {plumtree_gossip_peers,1},
                {sprinter,debug_get_tree,2},
                {sprinter,nodes,0},
                {sprinter,orchestrated,0},
                {sprinter,orchestration,0},
                {sprinter,servers,0},
                {sprinter_backend,debug_get_tree,2},
                {sprinter_backend,graph,0},
                {sprinter_backend,nodes,0},
                {sprinter_backend,servers,0},
                {sprinter_backend,tree,0},
                {sprinter_backend,was_connected,0},
                {lasp_delta_based_synchronization_backend, handle_cast, 2},
                {lasp_delta_based_synchronization_backend, handle_info, 2},
                {lasp_distribution_backend, handle_call, 3},
                {lasp_memory_utilization_report, handle_info, 2},
                {lasp_plumtree_memory_report, handle_info, 2},
                {lasp_state_based_synchronization_backend, handle_cast, 2},
                {lasp_state_based_synchronization_backend, handle_info, 2},
                {lasp_support, push_logs, 0},
                {lasp_synchronization_backend, log_transmission, 2},
                {lasp_throughput_client, handle_info, 2},
                {lasp_throughput_client, handle_info, 2},
                {lasp_throughput_client, log_convergence, 0},
                {lasp_throughput_server, handle_info, 2},
                {lasp_throughput_server, handle_info, 2},
                {lasp_throughput_server, init, 1},
                {lasp_throughput_server, log_convergence, 0},
                {lasp_throughput_server, stop_simulation, 0},
                {lasp_throughput_server, stop_simulation, 0},
                {lasp_instrumentation, convergence, 0},
                {lasp_instrumentation, experiment_started, 0},
                {lasp_instrumentation, log_files, 0},
                {lasp_instrumentation, stop, 0},
                {lasp_instrumentation, transmission, 3},
                {lasp_kubernetes_simulations, stop, 0},
                {lasp_marathon_simulations, log_message_queue_size, 1},
                {lasp_marathon_simulations, stop, 0}]}.
