AdRoll / rebar3_format

Erlang Formatter for Rebar3
https://tech.nextroll.com/blog/dev/2020/02/25/erlang-rebar3-format.html
MIT License
108 stars 21 forks source link

Notify escript not supported #332

Closed Olivier-Boudeville closed 1 year ago

Olivier-Boudeville commented 1 year ago

Notifying that rebar_format must be run as a plugin, not as an escript.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

Olivier-Boudeville commented 1 year ago

Sorry, I have still something to fix, the linting actually fails (with a rather vague message), whereas I thought it was ok

>ERL_FLAGS="-enable-feature all" rebar3 test
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> elvis analysis starting, this may take a while...
===> Linting failed

I will have to investigate

Olivier-Boudeville commented 1 year ago

I found this page, tried with ERL_FLAGS="-enable-feature all" rebar3 test with a few inline/define-like Elvis spec candidates:

As for Hank:

- ===> Looking for code to kill with fire...
===> error analyzing files: {case_clause,
                                    {unnecessary_function_argument,
                                     [{main,1,1}]}}
Stack: [{lists,map,2,[{file,"lists.erl"},{line,1314}]},
        {hank,'-analyze/5-lc$^3/1-2-',3,
              [{file,"EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/default/plugins/rebar3_hank/src/hank.erl"},
               {line,40}]},

Trying this time with -hank([{unnecessary_function_argument, [{main, 1, 1}]}]). we have:

===> Looking for code to kill with fire...
===> The following ignore specs are no longer needed and can be removed:
* src/rebar3_format.erl: unnecessary_function_argument: [{main,1,1}]

===> The following pieces of code are dead and should be removed:
src/rebar3_format.erl:17: main/1 doesn't need its #1 argument

Actually unnecessary_function_argument should have been unnecessary_function_arguments.

So with the last version that I committed (https://github.com/AdRoll/rebar3_format/commit/41ffa167ad6e538d6833893ddfa060ccce6c7288), everything seems ok:

$ ERL_FLAGS="-enable-feature all" rebar3 test 
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> elvis analysis starting, this may take a while...
===> Looking for code to kill with fire...
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> Dialyzer starting, this may take a while...
===> Updating plt...
===> Resolving project files...
===> Updating base plt...
===> Resolving base files...
===> Building with 206 files in EDITED/.cache/rebar3/rebar3_25.1_plt...
===> Copying EDITED/.cache/rebar3/rebar3_25.1_plt to EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/default/rebar3_25.1_plt...
===> Checking 206 files in _build/default/rebar3_25.1_plt...
===> Adding 23 files to _build/default/rebar3_25.1_plt...
===> Doing success typing analysis...
===> Resolving project warning files...
===> Analyzing 8 files with _build/default/rebar3_25.1_plt...
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> Running Common Test suites...

Common Test starting (cwd is EDITED/Software/rebar3_format-my-fork-for-escript-notification)

CWD set to: "EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/test/logs/ct_run.nonode@nohost.2022-11-11_20.02.00"

TEST INFO: 1 test(s), 26 case(s) in 5 suite(s)

Testing lib.rebar3_format: Starting test, 26 test cases
%%% complete_coverage_SUITE: ..........
%%% erlfmt_formatter_SUITE: .......
%%% otp_formatter_SUITE: ...
%%% sr_formatter_SUITE: ....
%%% test_app_SUITE: ..
Testing lib.rebar3_format: TEST COMPLETE, 26 ok, 0 failed of 26 test cases

Updating EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/test/logs/index.html ... done
Updating EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/test/logs/all_runs.html ... done
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> Performing cover analysis...
  |------------------------|------------|
  |                module  |  coverage  |
  |------------------------|------------|
  |     default_formatter  |       98%  |
  |      erlfmt_formatter  |      100%  |
  |         otp_formatter  |       94%  |
  |  rebar3_ast_formatter  |       96%  |
  |         rebar3_format  |       25%  |
  |     rebar3_format_prv  |       98%  |
  |      rebar3_formatter  |      100%  |
  |          sr_formatter  |      100%  |
  |------------------------|------------|
  |                 total  |       97%  |
  |------------------------|------------|
  coverage calculated from:
    EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/test/cover/ct.coverdata
  cover summary written to: EDITED/Software/rebar3_format-my-fork-for-escript-notification/_build/test/cover/index.html
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling rebar3_format
===> Running edoc for rebar3_format

I guess Elvis and Hank could better test their wild attributes!