From db4e1f532110c8b2d6d294ede560e84519579f75 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Tue, 22 Oct 2024 16:14:41 +0200 Subject: [PATCH 01/13] elbrujohalcon.otp_formatter.update- Update otp_formatter with changes from OTP 26 --- rebar.config | 3 ++- src/formatters/otp_formatter.erl | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 80a70ad..8a24fe0 100644 --- a/rebar.config +++ b/rebar.config @@ -18,7 +18,8 @@ {rebar3_sheldon, "~> 0.4.3"}, {rebar3_ex_doc, "~> 0.2.23"}]}. -{dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}. +{dialyzer, + [{warnings, [no_unknown, no_return, unmatched_returns, error_handling, underspecs]}]}. {edoc_opts, [{todo, true}, {overview, "priv/overview.edoc"}]}. diff --git a/src/formatters/otp_formatter.erl b/src/formatters/otp_formatter.erl index 2302e8d..56e1bd5 100644 --- a/src/formatters/otp_formatter.erl +++ b/src/formatters/otp_formatter.erl @@ -664,6 +664,11 @@ lay_no_comments(Node, Ctxt) -> D1 = lay(erl_syntax:binary_generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:binary_generator_body(Node), Ctxt1), par([D1, beside(text("<= "), D2)], Ctxt1#ctxt.break_indent); + map_generator -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_generator_pattern(Node), Ctxt1), + D2 = lay(erl_syntax:map_generator_body(Node), Ctxt1), + par([D1, beside(text("<- "), D2)], Ctxt1#ctxt.break_indent); implicit_fun -> D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)), beside(lay_text_float("fun "), D); @@ -679,6 +684,12 @@ lay_no_comments(Node, Ctxt) -> D2 = par(seq(erl_syntax:binary_comp_body(Node), lay_text_float(","), Ctxt1, fun lay/2)), beside(lay_text_float("<< "), par([D1, beside(lay_text_float(" || "), beside(D2, lay_text_float(" >>")))])); + map_comp -> + Ctxt1 = set_prec(Ctxt, max_prec()), + D1 = lay(erl_syntax:map_comp_template(Node), Ctxt1), + D2 = par(seq(erl_syntax:map_comp_body(Node), lay_text_float(","), Ctxt1, fun lay/2)), + beside(lay_text_float("#{"), + par([D1, beside(lay_text_float("|| "), beside(D2, lay_text_float("}")))])); macro -> %% This is formatted similar to a normal function call, but %% prefixed with a "?". From 3800fe33b547f4d7ff8d5f6302c0e95ac991c12b Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Tue, 22 Oct 2024 16:19:12 +0200 Subject: [PATCH 02/13] elbrujohalcon.otp_formatter.update- Revert dialyzer change --- rebar.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index 8a24fe0..80a70ad 100644 --- a/rebar.config +++ b/rebar.config @@ -18,8 +18,7 @@ {rebar3_sheldon, "~> 0.4.3"}, {rebar3_ex_doc, "~> 0.2.23"}]}. -{dialyzer, - [{warnings, [no_unknown, no_return, unmatched_returns, error_handling, underspecs]}]}. +{dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}. {edoc_opts, [{todo, true}, {overview, "priv/overview.edoc"}]}. From 89297c0dc5a575f5d9103f1396b9ad6f4403f6ea Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Wed, 23 Oct 2024 09:18:21 +0200 Subject: [PATCH 03/13] elbrujohalcon.otp_formatter.update- Update deps --- rebar.config | 8 ++++---- rebar.lock | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rebar.config b/rebar.config index 80a70ad..9fad0bb 100644 --- a/rebar.config +++ b/rebar.config @@ -2,7 +2,7 @@ {minimum_otp_vsn, "24"}. -{deps, [{katana_code, "~> 2.1.0"}]}. +{deps, [{katana_code, "~> 2.2.0"}]}. {ex_doc, [{source_url, <<"https://github.com/AdRoll/rebar3_format">>}, @@ -13,10 +13,10 @@ {project_plugins, [{rebar3_hex, "~> 7.0.8"}, - {rebar3_hank, "~> 1.4.0"}, - {rebar3_lint, "~> 3.2.5"}, + {rebar3_hank, "~> 1.4.1"}, + {rebar3_lint, "~> 3.2.6"}, {rebar3_sheldon, "~> 0.4.3"}, - {rebar3_ex_doc, "~> 0.2.23"}]}. + {rebar3_ex_doc, "~> 0.2.24"}]}. {dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}. diff --git a/rebar.lock b/rebar.lock index 31c3009..6d13613 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,8 +1,8 @@ {"1.2.0", -[{<<"katana_code">>,{pkg,<<"katana_code">>,<<"2.1.0">>},0}]}. +[{<<"katana_code">>,{pkg,<<"katana_code">>,<<"2.2.0">>},0}]}. [ {pkg_hash,[ - {<<"katana_code">>, <<"0C42BDCD7E59995876AED9F678CF62E3D12EF42E0FBB2190556E64BFEBDD15C6">>}]}, + {<<"katana_code">>, <<"B67EAA70022702AFEC2803E33C89ABE3D817197E7A16246614FED42E03AA8753">>}]}, {pkg_hash_ext,[ - {<<"katana_code">>, <<"AE3BBACA187511588F69695A9FF22251CB2CC672FDCCC180289779BDD25175EF">>}]} + {<<"katana_code">>, <<"A01F9FDBA838478FDFDE183A324FA12ECE9BA127935065395D01427FC5110CBB">>}]} ]. From 84733777f38a6812a37c7ec923e0c9ace7ce52fb Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Wed, 23 Oct 2024 15:16:39 +0200 Subject: [PATCH 04/13] elbrujohalcon.otp_formatter.update- Remove OTP 24 and update rebar3 --- .github/workflows/erlang.yml | 4 ++-- rebar.config | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 91ffcd5..f75915c 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -13,8 +13,8 @@ jobs: strategy: matrix: - otp: ['24.3', '25.2.1'] - rebar: ['3.20.0'] + otp: ['25'] + rebar: ['3.24'] steps: - uses: actions/checkout@v2 diff --git a/rebar.config b/rebar.config index 9fad0bb..65e75ef 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,6 @@ {erl_opts, [warn_unused_import, warn_export_vars, verbose, report, debug_info]}. -{minimum_otp_vsn, "24"}. +{minimum_otp_vsn, "25"}. {deps, [{katana_code, "~> 2.2.0"}]}. From 8ffc18bac3f8e818a494675da6abd558d231560a Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Wed, 23 Oct 2024 15:23:41 +0200 Subject: [PATCH 05/13] elbrujohalcon.otp_formatter.update- Update actions for GH --- .github/workflows/erlang.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index f75915c..99cdf3a 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -17,19 +17,19 @@ jobs: rebar: ['3.24'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 id: setup-beam with: otp-version: ${{matrix.otp}} rebar3-version: ${{matrix.rebar}} - name: Restore _build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: _build key: _build-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}} - name: Restore rebar3's cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/rebar3 key: rebar3-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}} From 070fccd92e1a200e7572101dc58bde942f92d941 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Thu, 24 Oct 2024 14:36:57 +0200 Subject: [PATCH 06/13] elbrujohalcon.otp_formatter.update- Get all formatters to work on OTP26 --- .github/workflows/erlang.yml | 2 +- rebar.config | 3 ++- src/formatters/default_formatter.erl | 11 +++++++++++ test_app/after/src/brackets.erl | 2 +- .../after/src/inline_items/inline_items_when_over.erl | 2 +- .../src/inline_items/inline_items_when_under.erl | 2 +- test_app/after/src/inline_items/inline_no_items.erl | 2 +- test_app/after/src/paper_and_ribbon/indent_18.erl | 6 +++--- test_app/after/src/paper_and_ribbon/indent_81.erl | 6 +++--- 9 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 99cdf3a..f1f40b9 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - otp: ['25'] + otp: ['26'] rebar: ['3.24'] steps: diff --git a/rebar.config b/rebar.config index 65e75ef..7f77978 100644 --- a/rebar.config +++ b/rebar.config @@ -18,7 +18,8 @@ {rebar3_sheldon, "~> 0.4.3"}, {rebar3_ex_doc, "~> 0.2.24"}]}. -{dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}. +{dialyzer, + [{warnings, [no_unknown, no_return, unmatched_returns, error_handling, underspecs]}]}. {edoc_opts, [{todo, true}, {overview, "priv/overview.edoc"}]}. diff --git a/src/formatters/default_formatter.erl b/src/formatters/default_formatter.erl index ba37528..c98db7e 100644 --- a/src/formatters/default_formatter.erl +++ b/src/formatters/default_formatter.erl @@ -606,6 +606,11 @@ lay_no_comments(Node, Ctxt) -> prettypr:beside( prettypr:text("<= "), D2)], Ctxt1#ctxt.break_indent); + map_generator -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_generator_pattern(Node), Ctxt1), + D2 = lay(erl_syntax:map_generator_body(Node), Ctxt1), + prettypr:par([D1, prettypr:beside(prettypr:text("<- "), D2)], Ctxt1#ctxt.break_indent); implicit_fun -> D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)), prettypr:beside(lay_text_float("fun "), D); @@ -621,6 +626,12 @@ lay_no_comments(Node, Ctxt) -> D2 = lay_items(erl_syntax:binary_comp_body(Node), Ctxt1, fun lay/2), D3 = prettypr:beside(lay_text_float("|| "), prettypr:beside(D2, lay_text_float(" >>"))), prettypr:beside(lay_text_float("<< "), prettypr:par([D1, D3])); + map_comp -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_comp_template(Node), Ctxt1), + D2 = lay_items(erl_syntax:map_comp_body(Node), Ctxt1, fun lay/2), + D3 = prettypr:beside(lay_text_float("|| "), prettypr:beside(D2, lay_text_float("}"))), + prettypr:beside(lay_text_float("#{"),prettypr:par([D1, D3])); macro -> %% This is formatted similar to a normal function call or a variable N = macro_name(Node, variable), diff --git a/test_app/after/src/brackets.erl b/test_app/after/src/brackets.erl index 7c9a386..895c33d 100644 --- a/test_app/after/src/brackets.erl +++ b/test_app/after/src/brackets.erl @@ -1,6 +1,6 @@ -module(brackets). --format #{inline_items => all, paper => 50}. +-format #{paper => 50, inline_items => all}. -compile(export_all). diff --git a/test_app/after/src/inline_items/inline_items_when_over.erl b/test_app/after/src/inline_items/inline_items_when_over.erl index c77e270..ba744a1 100644 --- a/test_app/after/src/inline_items/inline_items_when_over.erl +++ b/test_app/after/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,7 @@ %% per line if they're larger than 5 elements. -module(inline_items_when_over). --format #{inline_items => {when_over, 5}, paper => 80}. +-format #{paper => 80, inline_items => {when_over, 5}}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_items_when_under.erl b/test_app/after/src/inline_items/inline_items_when_under.erl index 55bc77c..b26e42c 100644 --- a/test_app/after/src/inline_items/inline_items_when_under.erl +++ b/test_app/after/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,6 @@ -module(inline_items_when_under). --format #{inline_items => {when_under, 5}, paper => 80}. +-format #{paper => 80, inline_items => {when_under, 5}}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_no_items.erl b/test_app/after/src/inline_items/inline_no_items.erl index 0ab7b30..86db03c 100644 --- a/test_app/after/src/inline_items/inline_no_items.erl +++ b/test_app/after/src/inline_items/inline_no_items.erl @@ -3,7 +3,7 @@ %% per line if they're large. -module(inline_no_items). --format #{inline_items => none, paper => 80}. +-format #{paper => 80, inline_items => none}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/paper_and_ribbon/indent_18.erl b/test_app/after/src/paper_and_ribbon/indent_18.erl index c342542..dc7f951 100644 --- a/test_app/after/src/paper_and_ribbon/indent_18.erl +++ b/test_app/after/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format #{break_indent => 1, - inline_clause_bodies => true, +-format #{sub_indent => 8, + break_indent => 1, paper => 50, - sub_indent => 8}. + inline_clause_bodies => true}. -record(record, {fields = diff --git a/test_app/after/src/paper_and_ribbon/indent_81.erl b/test_app/after/src/paper_and_ribbon/indent_81.erl index 4b00c9d..b4324a8 100644 --- a/test_app/after/src/paper_and_ribbon/indent_81.erl +++ b/test_app/after/src/paper_and_ribbon/indent_81.erl @@ -1,8 +1,8 @@ -module(indent_81). --format #{break_indent => 8, - paper => 50, - sub_indent => 1}. +-format #{sub_indent => 1, + break_indent => 8, + paper => 50}. -format #{inline_clause_bodies => true}. -record(record, From 80dd8756b8bd30985f31a933909dc71c685cd9c1 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Thu, 24 Oct 2024 14:41:52 +0200 Subject: [PATCH 07/13] elbrujohalcon.otp_formatter.update- Reduce code duplication --- src/formatters/default_formatter.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/formatters/default_formatter.erl b/src/formatters/default_formatter.erl index c98db7e..9ca4c67 100644 --- a/src/formatters/default_formatter.erl +++ b/src/formatters/default_formatter.erl @@ -594,23 +594,17 @@ lay_no_comments(Node, Ctxt) -> Ctxt1 = reset_prec(Ctxt), D1 = lay(erl_syntax:generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:generator_body(Node), Ctxt1), - prettypr:par([D1, - prettypr:beside( - prettypr:text("<- "), D2)], - Ctxt1#ctxt.break_indent); + lay_generator(D1, D2, "<- ", Ctxt1); binary_generator -> Ctxt1 = reset_prec(Ctxt), D1 = lay(erl_syntax:binary_generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:binary_generator_body(Node), Ctxt1), - prettypr:par([D1, - prettypr:beside( - prettypr:text("<= "), D2)], - Ctxt1#ctxt.break_indent); + lay_generator(D1, D2, "<= ", Ctxt1); map_generator -> Ctxt1 = reset_prec(Ctxt), D1 = lay(erl_syntax:map_generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:map_generator_body(Node), Ctxt1), - prettypr:par([D1, prettypr:beside(prettypr:text("<- "), D2)], Ctxt1#ctxt.break_indent); + lay_generator(D1, D2, "<- ", Ctxt1); implicit_fun -> D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)), prettypr:beside(lay_text_float("fun "), D); @@ -631,7 +625,7 @@ lay_no_comments(Node, Ctxt) -> D1 = lay(erl_syntax:map_comp_template(Node), Ctxt1), D2 = lay_items(erl_syntax:map_comp_body(Node), Ctxt1, fun lay/2), D3 = prettypr:beside(lay_text_float("|| "), prettypr:beside(D2, lay_text_float("}"))), - prettypr:beside(lay_text_float("#{"),prettypr:par([D1, D3])); + prettypr:beside(lay_text_float("#{"), prettypr:par([D1, D3])); macro -> %% This is formatted similar to a normal function call or a variable N = macro_name(Node, variable), @@ -1095,6 +1089,12 @@ maybe_convert_to_qualifier(Node, #ctxt{force_arity_qualifiers = true}) -> Node end. +lay_generator(D1, D2, Connector, Ctxt) -> + prettypr:par([D1, + prettypr:beside( + prettypr:text(Connector), D2)], + Ctxt#ctxt.break_indent). + lay_nested_infix_expr(Node, #ctxt{parenthesize_infix_operations = false} = Ctxt) -> lay(Node, Ctxt); lay_nested_infix_expr(Node, #ctxt{parenthesize_infix_operations = true} = Ctxt) -> From c2e8da8278534af4c824da9c77f0dd3fde2e1690 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Thu, 24 Oct 2024 14:56:29 +0200 Subject: [PATCH 08/13] =?UTF-8?q?elbrujohalcon.otp=5Fformatter.update-=20A?= =?UTF-8?q?llow=20tests=20to=20work=20with=20OTP25=20and=20OTP26=E2=80=A6?= =?UTF-8?q?=20hopefully?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/erlang.yml | 2 +- test_app/after/src/brackets.erl | 2 +- test_app/after/src/inline_items/inline_items_when_over.erl | 2 +- test_app/after/src/inline_items/inline_items_when_under.erl | 2 +- test_app/after/src/inline_items/inline_no_items.erl | 2 +- test_app/after/src/paper_and_ribbon/indent_18.erl | 6 +++--- test_app/after/src/paper_and_ribbon/indent_81.erl | 6 +++--- test_app/src/brackets.erl | 2 +- test_app/src/paper_and_ribbon/indent_18.erl | 4 ++-- test_app/src/paper_and_ribbon/indent_81.erl | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index f1f40b9..e4dd9d5 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - otp: ['26'] + otp: ['25', '26'] rebar: ['3.24'] steps: diff --git a/test_app/after/src/brackets.erl b/test_app/after/src/brackets.erl index 895c33d..7c9a386 100644 --- a/test_app/after/src/brackets.erl +++ b/test_app/after/src/brackets.erl @@ -1,6 +1,6 @@ -module(brackets). --format #{paper => 50, inline_items => all}. +-format #{inline_items => all, paper => 50}. -compile(export_all). diff --git a/test_app/after/src/inline_items/inline_items_when_over.erl b/test_app/after/src/inline_items/inline_items_when_over.erl index ba744a1..c77e270 100644 --- a/test_app/after/src/inline_items/inline_items_when_over.erl +++ b/test_app/after/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,7 @@ %% per line if they're larger than 5 elements. -module(inline_items_when_over). --format #{paper => 80, inline_items => {when_over, 5}}. +-format #{inline_items => {when_over, 5}, paper => 80}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_items_when_under.erl b/test_app/after/src/inline_items/inline_items_when_under.erl index b26e42c..55bc77c 100644 --- a/test_app/after/src/inline_items/inline_items_when_under.erl +++ b/test_app/after/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,6 @@ -module(inline_items_when_under). --format #{paper => 80, inline_items => {when_under, 5}}. +-format #{inline_items => {when_under, 5}, paper => 80}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_no_items.erl b/test_app/after/src/inline_items/inline_no_items.erl index 86db03c..0ab7b30 100644 --- a/test_app/after/src/inline_items/inline_no_items.erl +++ b/test_app/after/src/inline_items/inline_no_items.erl @@ -3,7 +3,7 @@ %% per line if they're large. -module(inline_no_items). --format #{paper => 80, inline_items => none}. +-format #{inline_items => none, paper => 80}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/paper_and_ribbon/indent_18.erl b/test_app/after/src/paper_and_ribbon/indent_18.erl index dc7f951..c342542 100644 --- a/test_app/after/src/paper_and_ribbon/indent_18.erl +++ b/test_app/after/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format #{sub_indent => 8, - break_indent => 1, +-format #{break_indent => 1, + inline_clause_bodies => true, paper => 50, - inline_clause_bodies => true}. + sub_indent => 8}. -record(record, {fields = diff --git a/test_app/after/src/paper_and_ribbon/indent_81.erl b/test_app/after/src/paper_and_ribbon/indent_81.erl index b4324a8..4b00c9d 100644 --- a/test_app/after/src/paper_and_ribbon/indent_81.erl +++ b/test_app/after/src/paper_and_ribbon/indent_81.erl @@ -1,8 +1,8 @@ -module(indent_81). --format #{sub_indent => 1, - break_indent => 8, - paper => 50}. +-format #{break_indent => 8, + paper => 50, + sub_indent => 1}. -format #{inline_clause_bodies => true}. -record(record, diff --git a/test_app/src/brackets.erl b/test_app/src/brackets.erl index ff9a912..4d5fbc5 100644 --- a/test_app/src/brackets.erl +++ b/test_app/src/brackets.erl @@ -1,6 +1,6 @@ -module(brackets). --format(#{paper => 50, inline_items => all}). +-format(#{inline_items => all, paper => 50}). -compile(export_all). diff --git a/test_app/src/paper_and_ribbon/indent_18.erl b/test_app/src/paper_and_ribbon/indent_18.erl index fa528a8..3db4754 100644 --- a/test_app/src/paper_and_ribbon/indent_18.erl +++ b/test_app/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). -format(#{break_indent => 1, - sub_indent => 8, + inline_clause_bodies => true, paper => 50, - inline_clause_bodies => true}). + sub_indent => 8}). -record( record, {fields = should:be(indented_using:break_indent(1)), diff --git a/test_app/src/paper_and_ribbon/indent_81.erl b/test_app/src/paper_and_ribbon/indent_81.erl index ecf2a63..511595b 100644 --- a/test_app/src/paper_and_ribbon/indent_81.erl +++ b/test_app/src/paper_and_ribbon/indent_81.erl @@ -1,6 +1,6 @@ -module(indent_81). --format(#{break_indent => 8, sub_indent => 1, paper => 50}). +-format(#{break_indent => 8, paper => 50, sub_indent => 1}). -format(#{inline_clause_bodies => true}). -record( From 420203a7d8506af6b9babe80a3a3631e769d50ce Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Thu, 24 Oct 2024 15:08:25 +0200 Subject: [PATCH 09/13] =?UTF-8?q?Fix=20tests=E2=80=A6=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_app/after/src/paper_and_ribbon/indent_18.erl | 8 ++++---- test_app/after/src/paper_and_ribbon/indent_81.erl | 6 +++--- test_app/src/inline_items/inline_no_items.erl | 3 +-- test_app/src/paper_and_ribbon/indent_18.erl | 8 ++++---- test_app/src/paper_and_ribbon/indent_81.erl | 4 +++- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test_app/after/src/paper_and_ribbon/indent_18.erl b/test_app/after/src/paper_and_ribbon/indent_18.erl index c342542..e2c62e1 100644 --- a/test_app/after/src/paper_and_ribbon/indent_18.erl +++ b/test_app/after/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format #{break_indent => 1, - inline_clause_bodies => true, - paper => 50, - sub_indent => 8}. +-format #{break_indent => 1}. +-format #{inline_clause_bodies => true}. +-format #{paper => 50}. +-format #{sub_indent => 8}. -record(record, {fields = diff --git a/test_app/after/src/paper_and_ribbon/indent_81.erl b/test_app/after/src/paper_and_ribbon/indent_81.erl index 4b00c9d..fe9d3a7 100644 --- a/test_app/after/src/paper_and_ribbon/indent_81.erl +++ b/test_app/after/src/paper_and_ribbon/indent_81.erl @@ -1,8 +1,8 @@ -module(indent_81). --format #{break_indent => 8, - paper => 50, - sub_indent => 1}. +-format #{break_indent => 8}. +-format #{paper => 50}. +-format #{sub_indent => 1}. -format #{inline_clause_bodies => true}. -record(record, diff --git a/test_app/src/inline_items/inline_no_items.erl b/test_app/src/inline_items/inline_no_items.erl index 5195c4e..ce7d89b 100644 --- a/test_app/src/inline_items/inline_no_items.erl +++ b/test_app/src/inline_items/inline_no_items.erl @@ -3,7 +3,7 @@ %% per line if they're large. -module inline_no_items. --format #{paper => 80, inline_items => none}. +-format #{inline_items => none, paper => 80}. -export [short_tuple/0, short_list/0, short_fun/0]. -export [short_bin/0, short_guard/1, short_lc/0]. @@ -106,4 +106,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/paper_and_ribbon/indent_18.erl b/test_app/src/paper_and_ribbon/indent_18.erl index 3db4754..421942a 100644 --- a/test_app/src/paper_and_ribbon/indent_18.erl +++ b/test_app/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format(#{break_indent => 1, - inline_clause_bodies => true, - paper => 50, - sub_indent => 8}). +-format(#{break_indent => 1}). +-format(#{inline_clause_bodies => true}). +-format(#{paper => 50}). +-format(#{sub_indent => 8}). -record( record, {fields = should:be(indented_using:break_indent(1)), diff --git a/test_app/src/paper_and_ribbon/indent_81.erl b/test_app/src/paper_and_ribbon/indent_81.erl index 511595b..82a8048 100644 --- a/test_app/src/paper_and_ribbon/indent_81.erl +++ b/test_app/src/paper_and_ribbon/indent_81.erl @@ -1,6 +1,8 @@ -module(indent_81). --format(#{break_indent => 8, paper => 50, sub_indent => 1}). +-format(#{break_indent => 8}). +-format(#{paper => 50}). +-format(#{sub_indent => 1}). -format(#{inline_clause_bodies => true}). -record( From 97fca074ee46033466b2db7e657c52241c652213 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Thu, 24 Oct 2024 18:30:17 +0200 Subject: [PATCH 10/13] Adjust tests for OTP26 --- nextroll.dict | 2 ++ test/otp_formatter_SUITE.erl | 11 ++++++++++- test/test_app_SUITE.erl | 5 ++++- test_app/after/src/strings/non_heredoc.erl | 15 +++++++++++++++ test_app/after/src/strings/strings.erl | 12 +----------- test_app/src/strings/non_heredoc.erl | 15 +++++++++++++++ test_app/src/strings/strings.erl | 9 --------- 7 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 test_app/after/src/strings/non_heredoc.erl create mode 100644 test_app/src/strings/non_heredoc.erl diff --git a/nextroll.dict b/nextroll.dict index 580276f..af41619 100644 --- a/nextroll.dict +++ b/nextroll.dict @@ -35,6 +35,8 @@ lay_clauses lay_items old-reliable otp25 +otp26 +otp27 paragraph-format per-file plugin diff --git a/test/otp_formatter_SUITE.erl b/test/otp_formatter_SUITE.erl index 55e9f4f..078d7b0 100644 --- a/test/otp_formatter_SUITE.erl +++ b/test/otp_formatter_SUITE.erl @@ -17,7 +17,16 @@ test_app(_Config) -> case string:to_integer( erlang:system_info(otp_release)) of - {N, _} when N >= 25 -> + {N, _} when N >= 26 -> + {ignore, + ["src/strings/non_heredoc.erl", %% newlines in strings are treated differently since OTP26 + "src/*_ignore.erl", + "src/comments.erl", + "src/ignored_file_config.erl", + "src/dodge_macros.erl", + "src/macros_in_specs.erl", + "src/receive_after.erl"]}; + {25, _} -> {ignore, ["src/*_ignore.erl", "src/comments.erl", diff --git a/test/test_app_SUITE.erl b/test/test_app_SUITE.erl index 0917321..a2ebc1f 100644 --- a/test/test_app_SUITE.erl +++ b/test/test_app_SUITE.erl @@ -50,7 +50,10 @@ init_test_app() -> case string:to_integer( erlang:system_info(otp_release)) of - {N, []} when N >= 25 -> + {N, _} when N >= 26 -> + %% newlines in strings are treated differently since OTP26 + {ignore, ["src/strings/non_heredoc.erl", "src/*_ignore.erl", "src/ignored_file_config.erl"]}; + {25, _} -> {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl"]}; _ -> {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl", "src/otp25.erl"]} diff --git a/test_app/after/src/strings/non_heredoc.erl b/test_app/after/src/strings/non_heredoc.erl new file mode 100644 index 0000000..9de6ef5 --- /dev/null +++ b/test_app/after/src/strings/non_heredoc.erl @@ -0,0 +1,15 @@ +-module(strings). + +-export([heredoc/0]). + +-format #{inline_expressions => true}. + +heredoc() -> + {ok, + "" " +This is +a multiline +heredoc but there are +no multiline heredocs in Erlang :'( +" + ""}. diff --git a/test_app/after/src/strings/strings.erl b/test_app/after/src/strings/strings.erl index d08e8fd..027f81a 100644 --- a/test_app/after/src/strings/strings.erl +++ b/test_app/after/src/strings/strings.erl @@ -7,22 +7,12 @@ -attr({with, "a string"}). all() -> - heredoc(), superlong(), repeat(), multiple_calls(), characters(), multiline_with_spaces(). + superlong(), repeat(), multiple_calls(), characters(), multiline_with_spaces(). superlong() -> "This is a super super super super super super super super super super super super super super super super super super super super super super super super super super super super super long string!" "Shouldn't be truncated since truncate_strings => false by default". -heredoc() -> - {ok, - "" " -This is -a multiline -heredoc but there are -no multiline heredocs in Erlang :'( -" - ""}. - repeat() -> ["hello", "there", "hello", "there", "hello", "there" | repeat_more()]. diff --git a/test_app/src/strings/non_heredoc.erl b/test_app/src/strings/non_heredoc.erl new file mode 100644 index 0000000..9de6ef5 --- /dev/null +++ b/test_app/src/strings/non_heredoc.erl @@ -0,0 +1,15 @@ +-module(strings). + +-export([heredoc/0]). + +-format #{inline_expressions => true}. + +heredoc() -> + {ok, + "" " +This is +a multiline +heredoc but there are +no multiline heredocs in Erlang :'( +" + ""}. diff --git a/test_app/src/strings/strings.erl b/test_app/src/strings/strings.erl index 50e2347..87048ee 100644 --- a/test_app/src/strings/strings.erl +++ b/test_app/src/strings/strings.erl @@ -7,7 +7,6 @@ -attr({with, "a string"}). all() -> - heredoc(), superlong(), repeat(), multiple_calls(), @@ -19,14 +18,6 @@ superlong() -> "This is a super super super super super super super super super super super super super super super super super super super super super super super super super super super super super long string!" "Shouldn't be truncated since truncate_strings => false by default". -heredoc() -> -{ok, """ -This is -a multiline -heredoc but there are -no multiline heredocs in Erlang :'( -"""}. - repeat() -> ["hello", "there", "hello", "there", From 361bcd28245c18ef14c8e8f59381a91f1c49f7c7 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Fri, 25 Oct 2024 08:42:15 +0200 Subject: [PATCH 11/13] Add tests for map comprehensions --- test/otp_formatter_SUITE.erl | 4 +++- test/test_app_SUITE.erl | 13 ++++++++++--- test_app/after/src/otp26.erl | 24 ++++++++++++++++++++++++ test_app/src/otp26.erl | 14 ++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 test_app/after/src/otp26.erl create mode 100644 test_app/src/otp26.erl diff --git a/test/otp_formatter_SUITE.erl b/test/otp_formatter_SUITE.erl index 078d7b0..8f918aa 100644 --- a/test/otp_formatter_SUITE.erl +++ b/test/otp_formatter_SUITE.erl @@ -33,7 +33,8 @@ test_app(_Config) -> "src/ignored_file_config.erl", "src/dodge_macros.erl", "src/macros_in_specs.erl", - "src/receive_after.erl"]}; + "src/receive_after.erl", + "src/otp26.erl"]}; _ -> {ignore, ["src/*_ignore.erl", @@ -42,6 +43,7 @@ test_app(_Config) -> "src/dodge_macros.erl", "src/macros_in_specs.erl", "src/receive_after.erl", + "src/otp26.erl", "src/otp25.erl"]} end, State2 = rebar_state:set(State1, format, [Files, Formatter, IgnoredFiles]), diff --git a/test/test_app_SUITE.erl b/test/test_app_SUITE.erl index a2ebc1f..533ceca 100644 --- a/test/test_app_SUITE.erl +++ b/test/test_app_SUITE.erl @@ -52,11 +52,18 @@ init_test_app() -> of {N, _} when N >= 26 -> %% newlines in strings are treated differently since OTP26 - {ignore, ["src/strings/non_heredoc.erl", "src/*_ignore.erl", "src/ignored_file_config.erl"]}; + {ignore, + ["src/strings/non_heredoc.erl", + "src/*_ignore.erl", + "src/ignored_file_config.erl"]}; {25, _} -> - {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl"]}; + {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl", "src/otp26.erl"]}; _ -> - {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl", "src/otp25.erl"]} + {ignore, + ["src/*_ignore.erl", + "src/ignored_file_config.erl", + "src/otp26.erl", + "src/otp25.erl"]} end, rebar_state:set(State1, format, [Files, IgnoredFiles]). diff --git a/test_app/after/src/otp26.erl b/test_app/after/src/otp26.erl new file mode 100644 index 0000000..1046753 --- /dev/null +++ b/test_app/after/src/otp26.erl @@ -0,0 +1,24 @@ +%% @doc New stuff introduced in OTP26. +-module(otp26). + +-export([map_comprehensions/3]). + +map_comprehensions(Map, List, Binary) -> + MapFromList = #{{k, Key} => {value, Value} || Key <- List, Value <- List}, + MapFromBinary = + #{{k, Key} => {value, Value} + || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, + MapFromMap = + #{#{key => Key} => [value, Value, is_a_value] + || {k, Key} := {value, Value} <- MapFromList, is_integer(Key)}, + MapFromCombo = #{Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, + ListFromMap = + [{Key, Value} + || {k, Key} := Value <- MapFromBinary, + with:one_filter(Key), + with:another_filter(Value) == <<"a good value">>], + BinaryFromMap = + << <> + || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, + NoGenerator = #{k => v || this:is_true()}, + #{MapFromCombo => ListFromMap, BinaryFromMap => NoGenerator}. diff --git a/test_app/src/otp26.erl b/test_app/src/otp26.erl new file mode 100644 index 0000000..65147eb --- /dev/null +++ b/test_app/src/otp26.erl @@ -0,0 +1,14 @@ +%% @doc New stuff introduced in OTP26. +-module(otp26). + +-export([map_comprehensions/3]). + +map_comprehensions(Map, List, Binary) -> + MapFromList = #{ {k, Key} => {value, Value} || Key <- List, Value <- List }, + MapFromBinary = #{ {k, Key} => {value, Value} || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, + MapFromMap = #{ #{key => Key} => [value, Value, is_a_value] || {k, Key} := {value, Value} <- MapFromList, is_integer(Key) }, + MapFromCombo = #{ Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, + ListFromMap = [{Key, Value} || {k, Key} := Value <- MapFromBinary, with:one_filter(Key), with:another_filter(Value) == <<"a good value">>], + BinaryFromMap = << <> || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, + NoGenerator = #{k => v || this:is_true()}, + #{MapFromCombo => ListFromMap, BinaryFromMap => NoGenerator}. From 2954616cb9193acc65fdec1043fdcc54d5ec4eb6 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Fri, 25 Oct 2024 11:59:28 +0200 Subject: [PATCH 12/13] Fix test inconsistencies --- test_app/after/src/brackets.erl | 3 ++- test_app/after/src/brackets_ignore.erl | 3 ++- test_app/after/src/inline_items/inline_items_when_over.erl | 3 ++- test_app/after/src/inline_items/inline_items_when_under.erl | 3 ++- test_app/after/src/inline_items/inline_no_items.erl | 3 ++- .../function_composition_spaces.erl | 3 ++- test_app/after/src/matches.erl | 3 ++- test_app/src/brackets.erl | 3 ++- test_app/src/brackets_ignore.erl | 3 ++- test_app/src/inline_items/inline_items_when_over.erl | 4 ++-- test_app/src/inline_items/inline_items_when_under.erl | 4 ++-- test_app/src/inline_items/inline_no_items.erl | 3 ++- .../function_composition_spaces.erl | 3 ++- test_app/src/matches.erl | 3 ++- 14 files changed, 28 insertions(+), 16 deletions(-) diff --git a/test_app/after/src/brackets.erl b/test_app/after/src/brackets.erl index 7c9a386..a130179 100644 --- a/test_app/after/src/brackets.erl +++ b/test_app/after/src/brackets.erl @@ -1,6 +1,7 @@ -module(brackets). --format #{inline_items => all, paper => 50}. +-format #{inline_items => all}. +-format #{paper => 50}. -compile(export_all). diff --git a/test_app/after/src/brackets_ignore.erl b/test_app/after/src/brackets_ignore.erl index 6b08080..6877fa0 100644 --- a/test_app/after/src/brackets_ignore.erl +++ b/test_app/after/src/brackets_ignore.erl @@ -1,7 +1,8 @@ %% This module should not be formatted since it's in the list of ignored modules -module(brackets_ignore). --format(#{paper => 50, inline_items => all}). +-format(#{paper => 50}). +-format(#{inline_items => all}). -compile(export_all). diff --git a/test_app/after/src/inline_items/inline_items_when_over.erl b/test_app/after/src/inline_items/inline_items_when_over.erl index c77e270..4ad7a16 100644 --- a/test_app/after/src/inline_items/inline_items_when_over.erl +++ b/test_app/after/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,8 @@ %% per line if they're larger than 5 elements. -module(inline_items_when_over). --format #{inline_items => {when_over, 5}, paper => 80}. +-format #{paper => 80}. +-format #{inline_items => {when_over, 5}}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_items_when_under.erl b/test_app/after/src/inline_items/inline_items_when_under.erl index 55bc77c..d4d9fb4 100644 --- a/test_app/after/src/inline_items/inline_items_when_under.erl +++ b/test_app/after/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,7 @@ -module(inline_items_when_under). --format #{inline_items => {when_under, 5}, paper => 80}. +-format #{paper => 80}. +-format #{inline_items => {when_under, 5}}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_items/inline_no_items.erl b/test_app/after/src/inline_items/inline_no_items.erl index 0ab7b30..a097236 100644 --- a/test_app/after/src/inline_items/inline_no_items.erl +++ b/test_app/after/src/inline_items/inline_no_items.erl @@ -3,7 +3,8 @@ %% per line if they're large. -module(inline_no_items). --format #{inline_items => none, paper => 80}. +-format #{inline_items => none}. +-format #{paper => 80}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl b/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl index 753be77..3d54dbe 100644 --- a/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl +++ b/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl @@ -1,6 +1,7 @@ -module(function_composition_spaces). --format #{inline_qualified_function_composition => true, spaces_around_arguments => true}. +-format #{inline_qualified_function_composition => true}. +-format #{spaces_around_arguments => true}. -export([local_calls/3, external_calls/0]). diff --git a/test_app/after/src/matches.erl b/test_app/after/src/matches.erl index 4c11c7e..3723362 100644 --- a/test_app/after/src/matches.erl +++ b/test_app/after/src/matches.erl @@ -1,6 +1,7 @@ -compile(export_all). --format #{paper => 80, ribbon => 75}. +-format #{paper => 80}. +-format #{ribbon => 75}. matches() -> % Short diff --git a/test_app/src/brackets.erl b/test_app/src/brackets.erl index 4d5fbc5..f78373e 100644 --- a/test_app/src/brackets.erl +++ b/test_app/src/brackets.erl @@ -1,6 +1,7 @@ -module(brackets). --format(#{inline_items => all, paper => 50}). +-format(#{inline_items => all}). +-format(#{paper => 50}). -compile(export_all). diff --git a/test_app/src/brackets_ignore.erl b/test_app/src/brackets_ignore.erl index 6b08080..6877fa0 100644 --- a/test_app/src/brackets_ignore.erl +++ b/test_app/src/brackets_ignore.erl @@ -1,7 +1,8 @@ %% This module should not be formatted since it's in the list of ignored modules -module(brackets_ignore). --format(#{paper => 50, inline_items => all}). +-format(#{paper => 50}). +-format(#{inline_items => all}). -compile(export_all). diff --git a/test_app/src/inline_items/inline_items_when_over.erl b/test_app/src/inline_items/inline_items_when_over.erl index bf9f5d7..a60ae84 100644 --- a/test_app/src/inline_items/inline_items_when_over.erl +++ b/test_app/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,8 @@ %% per line if they're larger than 5 elements. -module inline_items_when_over. --format #{paper => 80, inline_items => {when_over, 5}}. +-format #{paper => 80}. +-format #{inline_items => {when_over, 5}}. -export [short_tuple/0, short_list/0, short_fun/0]. -export [short_bin/0, short_guard/1, short_lc/0]. @@ -106,4 +107,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/inline_items/inline_items_when_under.erl b/test_app/src/inline_items/inline_items_when_under.erl index c3f3186..8443a8f 100644 --- a/test_app/src/inline_items/inline_items_when_under.erl +++ b/test_app/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,7 @@ -module inline_items_when_under. --format #{paper => 80, inline_items => {when_under, 5}}. +-format #{paper => 80}. +-format #{inline_items => {when_under, 5}}. -export [short_tuple/0, short_list/0, short_fun/0]. -export [short_bin/0, short_guard/1, short_lc/0]. @@ -103,4 +104,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/inline_items/inline_no_items.erl b/test_app/src/inline_items/inline_no_items.erl index ce7d89b..c8f135b 100644 --- a/test_app/src/inline_items/inline_no_items.erl +++ b/test_app/src/inline_items/inline_no_items.erl @@ -3,7 +3,8 @@ %% per line if they're large. -module inline_no_items. --format #{inline_items => none, paper => 80}. +-format #{inline_items => none}. +-format #{paper => 80}. -export [short_tuple/0, short_list/0, short_fun/0]. -export [short_bin/0, short_guard/1, short_lc/0]. diff --git a/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl b/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl index 108d977..6d969c1 100644 --- a/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl +++ b/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl @@ -1,6 +1,7 @@ -module(function_composition_spaces). --format #{spaces_around_arguments => true, inline_qualified_function_composition => true}. +-format #{inline_qualified_function_composition => true}. +-format #{spaces_around_arguments => true}. -export([local_calls/3, external_calls/0]). diff --git a/test_app/src/matches.erl b/test_app/src/matches.erl index f745eb9..2c336e8 100644 --- a/test_app/src/matches.erl +++ b/test_app/src/matches.erl @@ -1,6 +1,7 @@ -compile(export_all). --format #{paper => 80, ribbon => 75}. +-format #{paper => 80}. +-format #{ribbon => 75}. matches() -> % Short From 12dded7436dc56d325081d83789669a598908824 Mon Sep 17 00:00:00 2001 From: elbrujohalcon Date: Fri, 25 Oct 2024 12:02:41 +0200 Subject: [PATCH 13/13] Fix for OTP25 --- test_app/src/otp26.erl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test_app/src/otp26.erl b/test_app/src/otp26.erl index 65147eb..1046753 100644 --- a/test_app/src/otp26.erl +++ b/test_app/src/otp26.erl @@ -4,11 +4,21 @@ -export([map_comprehensions/3]). map_comprehensions(Map, List, Binary) -> - MapFromList = #{ {k, Key} => {value, Value} || Key <- List, Value <- List }, - MapFromBinary = #{ {k, Key} => {value, Value} || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, - MapFromMap = #{ #{key => Key} => [value, Value, is_a_value] || {k, Key} := {value, Value} <- MapFromList, is_integer(Key) }, - MapFromCombo = #{ Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, - ListFromMap = [{Key, Value} || {k, Key} := Value <- MapFromBinary, with:one_filter(Key), with:another_filter(Value) == <<"a good value">>], - BinaryFromMap = << <> || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, + MapFromList = #{{k, Key} => {value, Value} || Key <- List, Value <- List}, + MapFromBinary = + #{{k, Key} => {value, Value} + || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, + MapFromMap = + #{#{key => Key} => [value, Value, is_a_value] + || {k, Key} := {value, Value} <- MapFromList, is_integer(Key)}, + MapFromCombo = #{Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, + ListFromMap = + [{Key, Value} + || {k, Key} := Value <- MapFromBinary, + with:one_filter(Key), + with:another_filter(Value) == <<"a good value">>], + BinaryFromMap = + << <> + || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, NoGenerator = #{k => v || this:is_true()}, #{MapFromCombo => ListFromMap, BinaryFromMap => NoGenerator}.