Skip to main content

rebar.config

{erl_opts, [
    debug_info,
    warnings_as_errors
]}.

{deps, [
    {hlc, "3.0.4"},
    {quic, "1.4.2"},
    {instrument, "1.1.0"}
]}.

{minimum_otp_vsn, "27"}.

{project_plugins, [
    rebar3_hex,
    rebar3_ex_doc,
    {rebar3_lint, "~> 5.0"},
    {erlfmt, "~> 1.7"}
]}.

%% Publish HexDocs via ex_doc (the {ex_doc, [...]} config below drives it).
{hex, [{doc, ex_doc}]}.

{profiles, [
    {test, [
        {deps, [
            {meck, "0.9.2"},
            {proper, "1.4.0"}
        ]},
        {erl_opts, [nowarn_export_all]}
    ]}
]}.

{dialyzer, [
    {warnings, [
        unknown,
        error_handling
    ]},
    {plt_apps, all_deps},
    {plt_extra_apps, [hlc, quic, instrument, public_key, crypto, asn1, ssl, kernel, stdlib]}
]}.

{xref_checks, [
    undefined_function_calls,
    undefined_functions,
    locals_not_used,
    deprecated_function_calls
]}.

{alias, [
    {check, [xref, dialyzer, eunit, ct]}
]}.

{ct_opts, [{sys_config, ["config/sys.config"]}]}.

{erlfmt, [
    write,
    {files, [
        "{src,test,include}/**/*.{hrl,erl,app.src}",
        "rebar.config"
    ]}
]}.

{elvis, [
    {config, [
        #{
            files => ["src/**/*.erl"],
            rules => [
                %% Keep
                {elvis_style, no_macros, disable},
                {elvis_text_style, max_line_length, #{limit => 120}},
                {elvis_style, atom_naming_convention, #{
                    regex => "^[a-z](_?[a-zA-Z0-9]+)*(_SUITE)?$"
                }},
                %% Since OTP28 / new in elvis_core 5.x - disable for now
                {elvis_style, prefer_strict_generators, disable},
                {elvis_style, prefer_sigils, disable},
                {elvis_style, consistent_ok_error_spec, disable},
                {elvis_style, abc_size, disable},
                {elvis_style, code_complexity, disable},
                {elvis_style, consistent_variable_naming, disable},
                %% Too strict for this codebase
                {elvis_style, no_common_caveats_call, disable},
                {elvis_style, no_init_lists, disable},
                {elvis_style, no_spec_with_records, disable},
                {elvis_style, param_pattern_matching, disable},
                {elvis_style, no_used_ignored_variables, disable},
                %% Per-module exceptions (legitimate existing patterns)
                {elvis_style, no_god_modules, #{limit => 30, ignore => [barrel_p2p]}},
                {elvis_style, no_receive_without_timeout, #{ignore => [barrel_p2p]}},
                {elvis_style, no_if_expression, #{
                    ignore => [barrel_p2p_hlc, barrel_p2p_hyparview_shuffle, barrel_p2p_leader]
                }},
                {elvis_style, no_catch_expressions, #{
                    ignore => [
                        barrel_p2p_dist,
                        barrel_p2p_dist_auth_stream,
                        barrel_p2p_dist_gc,
                        barrel_p2p_file,
                        barrel_p2p_service_proxy
                    ]
                }},
                {elvis_style, no_invalid_dynamic_calls, #{
                    ignore => [barrel_p2p_discovery, barrel_p2p_map, barrel_p2p_source_monitor]
                }},
                {elvis_style, no_deep_nesting, #{ignore => [barrel_p2p_bridge]}},
                {elvis_style, simplify_anonymous_functions, #{ignore => [barrel_p2p_map]}},
                {elvis_style, no_boolean_in_comparison, #{
                    ignore => [barrel_p2p_crdt_wire, barrel_p2p_map]
                }},
                {elvis_style, private_data_types, #{ignore => [barrel_p2p_hlc]}},
                {elvis_style, export_used_types, #{
                    ignore => [barrel_p2p_protocol, barrel_p2p_rotate]
                }},
                {elvis_style, max_function_arity, #{ignore => [barrel_p2p_dist_auth_stream]}},
                {elvis_style, dont_repeat_yourself, #{
                    ignore => [
                        barrel_p2p,
                        barrel_p2p_dist_auth_stream,
                        barrel_p2p_ormap,
                        barrel_p2p_replica,
                        barrel_p2p_quic_cert,
                        barrel_p2p_plumtree,
                        barrel_p2p_service_proxy,
                        barrel_p2p_shard
                    ]
                }}
            ],
            ruleset => erl_files
        },
        #{
            files => ["include/*.hrl"],
            rules => [
                %% Shared protocol types intentionally live in the .hrl.
                {elvis_style, no_types, disable}
            ],
            ruleset => hrl_files
        },
        #{
            files => ["rebar.config"],
            ruleset => rebar_config
        }
    ]}
]}.

{ex_doc, [
    {source_url, <<"https://github.com/barrel-platform/barrel_p2p">>},
    {output, "_build/doc"},
    %% ex_doc flattens all extras into _build/doc/. README references
    %% diagrams as `docs/diagrams/...' (so GitHub renders them when
    %% browsing the repo); the in-docs/ pages reference them as
    %% `diagrams/...' (so GitHub renders them when browsing docs/).
    %% Both paths must resolve in the published HTML. The
    %% docs/diagrams_root symlink lets us copy the same source under
    %% two destination names without duplicating the PNGs in git.
    {assets, #{
        <<"docs/diagrams">> => <<"diagrams">>,
        <<"docs/diagrams_root">> => <<"docs/diagrams">>
    }},
    {extras, [
        <<"README.md">>,
        <<"CHANGELOG.md">>,
        <<"SECURITY.md">>,
        <<"docs/features.md">>,
        %% Overview
        <<"docs/overview/index.md">>,
        <<"docs/overview/what-is-barrel_p2p.md">>,
        <<"docs/overview/benefits.md">>,
        <<"docs/overview/introduction.md">>,
        <<"docs/overview/getting-started.md">>,
        %% Concepts
        <<"docs/concepts/index.md">>,
        <<"docs/concepts/cluster-membership.md">>,
        <<"docs/concepts/service-registry.md">>,
        <<"docs/concepts/gossip-broadcast.md">>,
        <<"docs/concepts/dist-channel.md">>,
        <<"docs/concepts/authentication.md">>,
        <<"docs/concepts/streams.md">>,
        <<"docs/concepts/connection-migration.md">>,
        <<"docs/concepts/hybrid-logical-clocks.md">>,
        <<"docs/concepts/leader-election.md">>,
        <<"docs/concepts/sharded-placement.md">>,
        <<"docs/concepts/durable-reminders.md">>,
        <<"docs/concepts/replicated-maps.md">>,
        %% Tutorials
        <<"docs/tutorials/index.md">>,
        <<"docs/tutorials/hello-cluster.md">>,
        <<"docs/tutorials/create-an-application.md">>,
        <<"docs/tutorials/distributed-chat.md">>,
        %% How-to guides
        <<"docs/how-to/index.md">>,
        <<"docs/how-to/run-in-production.md">>,
        <<"docs/how-to/configure-authentication.md">>,
        <<"docs/how-to/manage-node-keys.md">>,
        <<"docs/how-to/observe-cluster.md">>,
        <<"docs/how-to/troubleshoot.md">>,
        <<"docs/how-to/migrate-connections.md">>,
        <<"docs/how-to/route-through-relay.md">>,
        <<"docs/how-to/run-tests.md">>,
        <<"docs/how-to/partition-state.md">>,
        <<"docs/how-to/schedule-durable-jobs.md">>,
        <<"docs/how-to/share-replicated-state.md">>,
        %% Reference
        <<"docs/reference/index.md">>,
        <<"docs/reference/api-overview.md">>,
        <<"docs/reference/configuration.md">>,
        <<"docs/reference/architecture.md">>,
        <<"docs/reference/comparison-with-partisan.md">>,
        <<"docs/reference/replicated-substrate.md">>
    ]},
    {groups_for_extras, [
        {<<"Overview">>, [
            <<"docs/overview/index.md">>,
            <<"docs/overview/what-is-barrel_p2p.md">>,
            <<"docs/overview/benefits.md">>,
            <<"docs/overview/introduction.md">>,
            <<"docs/overview/getting-started.md">>
        ]},
        {<<"Core concepts">>, [
            <<"docs/concepts/index.md">>,
            <<"docs/concepts/cluster-membership.md">>,
            <<"docs/concepts/service-registry.md">>,
            <<"docs/concepts/gossip-broadcast.md">>,
            <<"docs/concepts/dist-channel.md">>,
            <<"docs/concepts/authentication.md">>,
            <<"docs/concepts/streams.md">>,
            <<"docs/concepts/connection-migration.md">>,
            <<"docs/concepts/hybrid-logical-clocks.md">>,
            <<"docs/concepts/leader-election.md">>,
            <<"docs/concepts/sharded-placement.md">>,
            <<"docs/concepts/durable-reminders.md">>,
            <<"docs/concepts/replicated-maps.md">>
        ]},
        {<<"Tutorials">>, [
            <<"docs/tutorials/index.md">>,
            <<"docs/tutorials/hello-cluster.md">>,
            <<"docs/tutorials/create-an-application.md">>,
            <<"docs/tutorials/distributed-chat.md">>
        ]},
        {<<"How-to guides">>, [
            <<"docs/how-to/index.md">>,
            <<"docs/how-to/run-in-production.md">>,
            <<"docs/how-to/configure-authentication.md">>,
            <<"docs/how-to/manage-node-keys.md">>,
            <<"docs/how-to/observe-cluster.md">>,
            <<"docs/how-to/troubleshoot.md">>,
            <<"docs/how-to/migrate-connections.md">>,
            <<"docs/how-to/route-through-relay.md">>,
            <<"docs/how-to/run-tests.md">>,
            <<"docs/how-to/partition-state.md">>,
            <<"docs/how-to/schedule-durable-jobs.md">>,
            <<"docs/how-to/share-replicated-state.md">>
        ]},
        {<<"Reference">>, [
            <<"docs/reference/index.md">>,
            <<"docs/reference/api-overview.md">>,
            <<"docs/reference/configuration.md">>,
            <<"docs/reference/architecture.md">>,
            <<"docs/reference/comparison-with-partisan.md">>,
            <<"docs/reference/replicated-substrate.md">>
        ]},
        {<<"Project">>, [
            <<"CHANGELOG.md">>,
            <<"SECURITY.md">>,
            <<"docs/features.md">>
        ]}
    ]},
    {main, <<"README.md">>},
    {api_reference, true}
]}.