[mix format] What is considered to be relevant when calculating line length?

It seems to me that credo and mix format currently calculate the
line length differently.

This experiment is running

  • credo --strict (v0.8.10)
  • mix format --check-formatted (Elixir 1.6.1 on Erlang/OTP 20.2.3)

and here is the noticed behaviour and the change I did to reconcile:

         xxxxxxxxxxx: %{
           xxxxxxxxxxxxxxxx: %{
             xxxx: get_in(xxxxxxxxxxx, [:xxxxxxx, :xxxxxxxxxxxxxxxx, :xxxx]),
+            # credo:disable-for-lines:2 Credo.Check.Readability.MaxLineLength
             xxxxxxxxxxxxxx:
-              get_in(xxxxxxxxxxx,
-                [:xxxxxxx, :xxxxxxxxxxxxxxxx, :xxxxxxxxxxxxxx]),
+              get_in(xxxxxxxxxxx, [:xxxxxxx, :xxxxxxxxxxxxxxxx, :xxxxxxxxxxxxxx]),
             xxxxxxxx:
               get_in(xxxxxxxxxxx, [:xxxxxxx, :xxxxxxxxxxxxxxxx, :xxxxxxxx])
           },

The old code wrapped around the 80 character limit. credo is happy, but
mix format wants everything on one line, as the closing parenthesis and
comma seem to not be counted in the line length.

Don’t know if this is worth opening an issue on https://github.com/elixir-lang/elixir
or if this is desired and expected behaviour.

PS: @AstonJ please help me triage this post if I didn’t figure out the best place for it?

3 Likes

This actually sounds like the line-length bug that is fixed in elixir master’s formatter I would wager on initial guess?

1 Like

@OvermindDL1 after a quick glance, is it https://github.com/elixir-lang/elixir/issues/7379 that you’re referencing, or a different one?

1 Like

No there was another one, that one was just about length in strings.

1 Like

Gave Elixir 1.6.2 a shot this morning and the behaviour is the same.

Erlang/OTP 20 [erts-9.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.6.2 (compiled with OTP 20)

If this is not intended behaviour, is it worth migrating this to a GitHub issue on the elixir repo?
(cc @josevalim)

2 Likes

It is not intended behaviour. please open up an issue and we will investigate!

3 Likes

Thank you for looking into this. Migrated over.

3 Likes