How can I Suppress warnings! I've been looking for a while

I guess my point here would be that the behavior of mix deps.compile and mix compile can be different and hence one can see different sets of warnings. mix compile (provided that the packages were already compiled) should only show warnings on my code–not warnings on dependencies. But, as you say, it would depend on exactly what needs to be built.

Not in my experience. Now I’m curious what’s your machine setup like, sounds like something’s not right.

Ok, so looking more closely, I was wrong, it’s not all my deps that get recompiled, it’s just a handful. Here’s a brand new phoenix 1.7.10 project. This is the same list every time I run deps.compile, all of which appear to be compiled in my _build dir correctly. mix compile doesn’t try to recompile any of them, and I can iex -S mix without anything being recompiled either. Elixir 1.16.0 FWIW.

~/work/quick_test mix deps.compile                                                                                                                                                          13:48:21
===> Analyzing applications...
===> Compiling telemetry
===> Analyzing applications...
===> Compiling telemetry_poller
warning: in order to compile .yrl files, you must add "compilers: [:yecc] ++ Mix.compilers()" to the "def project" section of expo's mix.exs
  (mix 1.16.0) lib/mix/tasks/compile.yecc.ex:70: Mix.Tasks.Compile.Yecc.preload/1
  (mix 1.16.0) lib/mix/compilers/erlang.ex:66: Mix.Compilers.Erlang.compile/6
  (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:93: Mix.Tasks.Compile.All.with_logger_app/2

===> Analyzing applications...
===> Compiling ranch
==> tailwind
    warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
    │
 72 │       Logger.warn("""
    │              ~
    │
    └─ (tailwind 0.2.2) lib/tailwind.ex:72:14: Tailwind.start/2

    warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
    │
 86 │         Logger.warn("""
    │                ~
    │
    └─ (tailwind 0.2.2) lib/tailwind.ex:86:16: Tailwind.start/2

==> mint
    warning: function set_flag/2 is unused
    │
 69 │     defp set_flag(unquote(frame), unquote(flag_name)), do: unquote(flag_value)
    │          ~
    │
    └─ lib/mint/http2/frame.ex:69:10: Mint.HTTP2.Frame (module)

===> Analyzing applications...
===> Compiling cowlib
===> Analyzing applications...
===> Compiling cowboy
===> Analyzing applications...
===> Compiling cowboy_telemetry
==> phoenix_live_reload
    warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
    │
 32 │         Logger.warn("""
    │                ~
    │
    └─ (phoenix_live_reload 1.4.1) lib/phoenix_live_reload/application.ex:32:16: Phoenix.LiveReloader.Application.start_link/0

I upgraded to the latestish Phoenix 1.7.11 and Elixir 1.6.0 and do get some warnings which would be nice to suppress.

==> uri_query
Compiling 1 file (.ex)
    warning: missing parentheses for expression following "do:" keyword. Parentheses are required to solve ambiguity inside keywords.

    This error happens when you have function calls without parentheses inside keywords. For example:

        function(arg, one: nested_call a, b, c)
        function(arg, one: if expr, do: :this, else: :that)

    In the examples above, we don't know if the arguments "b" and "c" apply to the function "function" or "nested_call". Or if the keywords "do" and "else" apply to the function "function" or "if". You can solve this by explicitly adding parentheses:

        function(arg, one: if(expr, do: :this, else: :that))
        function(arg, one: nested_call(a, b, c))

    Ambiguity found at:
    │
 40 │   def params(_, _), do: raise ArgumentError, @noKVListError
    │   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/uri_query.ex:40

    warning: missing parentheses for expression following "do:" keyword. Parentheses are required to solve ambiguity inside keywords.

...

==> db_connection
Compiling 15 files (.ex)
Generated db_connection app
warning: in order to compile .yrl files, you must add "compilers: [:yecc] ++ Mix.compilers()" to the "def project" section of your mix.exs
  (mix 1.16.0) lib/mix/tasks/compile.yecc.ex:70: Mix.Tasks.Compile.Yecc.preload/1
  (mix 1.16.0) lib/mix/compilers/erlang.ex:66: Mix.Compilers.Erlang.compile/6
  (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4
  (mix 1.16.0) lib/mix/tasks/compile.all.ex:93: Mix.Tasks.Compile.All.with_logger_app/2

..
==> mint
Compiling 1 file (.erl)
Compiling 19 files (.ex)
    warning: function set_flag/2 is unused
    │
 69 │     defp set_flag(unquote(frame), unquote(flag_name)), do: unquote(flag_value)
    │          ~
    │
    └─ lib/mint/http2/frame.ex:69:10: Mint.HTTP2.Frame (module)

Generated mint app

Are all of these coming from packages? I only see the Logger one (and a lot of them) and they should just be fixed in the packages themselves (which I imagine they are). I’m also seeing ones from other packages I use. Seems to just be a particularly shifty Elixir update. I’ve never experienced this many before from a minor version update but I’m not super bothered by it since I know they’ll eventually get fixed.

Looks like it’s a dead-end for supressing warnings.

I created a barebones module to manipulate the string output of a compilation log file and posted it to Managing Warnings in Phoenix for some type of warning management, even if rudimentary.

Good luck with your debt!

Very safe if they are useless … Unused X,Y,Z …

Almost year 2025, no solution ?!

I respectfully disagree. Unused variables can be a sign that the developer has misspelled something. That strikes me as being quite useful.

7 Likes

It’s considered a feature, not a bug, so the year has nothing to do with it.

Hopefully you never have to write anything in Go!

2 Likes

An annoying so called feature filling ci/cd log with useless lines telling me that this and that are declared but not used. I will keep them there JUST to celebrate this so called feature. But seriously, I believe an option should be provided to suppress those warnings.

This thread has been necroed just to post a rant. Closing.

5 Likes