Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode characters (arrows) that indicate priority of found issues not printed correctly #1137

Open
miguno opened this issue Jun 5, 2024 · 2 comments

Comments

@miguno
Copy link

miguno commented Jun 5, 2024

Precheck

Environment

  • Credo version (mix credo -v): 1.7.6-ref.main.a3c8308+uncommittedchanges
  • Erlang/Elixir version (elixir -v):
    • Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
    • Elixir 1.16.3 (compiled with Erlang/OTP 27)
  • Operating system: macOS 14.5 (Sonoma), Apple Silicon
  • Terminals: wezterm (20240203-110809-5046fc22) and iTerm (3.5.0) with zsh
  • The font I use (a Iosevka variant) does support the priority-indicating arrows (like → or ↗) when I enter them manually into the shell, or when I use elixir/iex to print the Unicode sequences.

Terminal environment:

$ echo $LANG
en_US.utf-8

$ echo $LC_ALL
en_US.utf-8

My terminal (wezterm) with the font I use (Iosevka) does support the respective arrow Unicode characters:

❯ iex
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Interactive Elixir (1.16.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>  to_string("\u{2192}")
""
iex(2)> to_string("\u{2197}")
""

Lastly, even with a "fresh" wezterm setup of all defaults (via wezterm -n) shows the same behavior: credo output has raw Unicode sequences, whereas other uses of the same Unicode characters (e.g. via iex or manually typed) do render correctly.

What were you trying to do?

I want to run a basic credo report with mix credo --strict and see correctly formatted output.

To make it easier to summarize the issue in this discussion, I also include the expected vs. actual output for the following credo command line:

$ mix credo list --format=oneline --strict

FWIW it didn't matter whether or not I added --no-color to the commands.

Expected outcome

I expected that the priority indicator arrows (like → or ↗) would be printed to the terminal, note the left-hand side of the output, right next to where the categories like [R] and [D] are printed.

$ mix credo list --format=oneline --strict
[R] → lib/hello_elixir.ex:1:11 Modules should have a @moduledoc tag.
[D] → lib/hello_elixir.ex:12 Found a TODO tag in a comment: # TODO: Remove
[W] ↗ lib/hello_elixir.ex:20:10 There are identical sub-expressions to the left and to the right of the '&&' operator.

Actual outcome

Instead, the raw Unicode sequence were printed.

$ mix credo list --format=oneline --strict
[R] \x{2192} lib/hello_elixir.ex:1:11 Modules should have a @moduledoc tag.
[D] \x{2192} lib/hello_elixir.ex:12 Found a TODO tag in a comment: # TODO: Remove
[W] \x{2197} lib/hello_elixir.ex:20:10 There are identical sub-expressions to the left and to the right of the '&&' operator.

Here is more verbose output:

$ mix credo --strict
mix credo --strict
Checking 3 source files ...

  Software Design
\x{2503}
\x{2503} [D] \x{2192} Found a TODO tag in a comment: # TODO: Remove
\x{2503}       lib/hello_elixir.ex:12 #(HelloElixir.hello)

  Code Readability
\x{2503}
\x{2503} [R] \x{2192} Modules should have a @moduledoc tag.
\x{2503}       lib/hello_elixir.ex:1:11 #(HelloElixir)

  Warnings - please take a look
\x{2503}
\x{2503} [W] \x{2197} There are identical sub-expressions to the left and to the right of the '&&' operator.
\x{2503}       lib/hello_elixir.ex:20:10 #(HelloElixir.baz)

Please report incorrect results: https://github.com/rrrene/credo/issues

Analysis took 0.06 seconds (0.04s to load, 0.02s running 67 checks on 3 files)
4 mods/funs, found 1 warning, 1 code readability issue, 1 software design suggestion.

Use `mix credo explain` to explain issues, `mix credo --help` for options.

As you can see, the priority-indicating arrows as well as further Unicode sequences are actually printed as \x{2192} etc.

  • The terminals I use and tested with (wezterm and iTerm) are correctly configured for Unicode. They do show the arrow characters when I enter them manually, for example.
  • $LANG and $LC_ALL are set to en_US.utf-8.
  • The font used in the terminals do support the arrow characters. I also tested with several fonts, including Iosevka, Fira Code, MesloLGF NF, Hack Nerd Font Mono.

Have you come across this before? I have not found any clearly related issue in the open or the closed GH issues.

@miguno
Copy link
Author

miguno commented Jun 5, 2024

I did find a semi-related issue for wezterm, but as far as I can tell the issue I describe above is different.

@rrrene
Copy link
Owner

rrrene commented Jun 12, 2024

Wow. Thanks for the super detailed issue! 🎉 👍

I am currently at a loss regarding the origin of this. If Credo can change anything to mitigate this issue, we will 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants