rrrene / credo

A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
http://credo-ci.org/
MIT License
4.94k stars 419 forks source link

Be explicit about steps to avoid warnings #1085

Closed PragTob closed 1 year ago

PragTob commented 1 year ago

Lots of warnings like this one on elixir 1.16.0-rc.0:

warning: negative steps are not supported in Enum.slice/2, pass 0..-2//1 instead
  (elixir 1.16.0-rc.0) lib/enum.ex:2994: Enum.slice/2
  (credo 1.7.0) lib/credo/check/consistency/multi_alias_import_require_use/collector.ex:27: Credo.Check.Consistency.MultiAliasImportRequireUse.Collector.traverse/2
  (elixir 1.16.0-rc.0) lib/macro.ex:637: anonymous fn/4 in Macro.do_traverse_args/4
  (stdlib 5.1.1) lists.erl:1706: :lists.mapfoldl_1/3
  (stdlib 5.1.1) lists.erl:1707: :lists.mapfoldl_1/3

Thanks for all the great work! :green-heart:

IMG_20220901_174517

PragTob commented 1 year ago

aight yeah that's what I feared..old elixir versions don't support the syntax and so the proper workaround would be to extract helpers that are compiled differently based on what elixir version is in use... fun :|

rrrene commented 1 year ago

v1.7.2-rc.0 should account for this. I implemented the backport based on your branch, but somehow lost your commits (probably a "fat finger rebase").

Could you have a look if it solves your issue? 😄

PragTob commented 1 year ago

@rrrene ah good to see you :green_heart: Yes, warnings are gone, there's one more, right now, I'll MR it :)

tobi@qiqi:~/github/benchee$ mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.04s
Unchanged:
  bunt 0.2.1
  deep_merge 1.0.0
  dialyxir 1.4.2
  earmark_parser 1.4.37
  erlex 0.2.6
  ex_doc 0.30.9
  ex_guard 1.6.1
  excoveralls 0.18.0
  file_system 0.2.10
  fs 8.6.1
  jason 1.4.1
  makeup 1.1.0
  makeup_elixir 0.16.1
  makeup_erlang 0.1.2
  nimble_parsec 1.3.1
  statistex 1.0.0
  table 0.1.2
Upgraded:
  credo 1.7.1 => 1.7.2-rc.0
* Updating credo (Hex package)
tobi@qiqi:~/github/benchee$ mix credo
==> credo
Compiling 252 files (.ex)
    warning: function traverse/4 is unused
    │
 56 │     defp traverse({unquote(op), _, nil} = ast, issues, _issue_meta, _parens?) do
    │          ~
    │
    └─ lib/credo/check/warning/mix_env.ex:56:10: Credo.Check.Warning.MixEnv (module)

Thanks for your work!

IMG_20220601_080610