inaka / elvis_core

The core of an Erlang linter
Other
61 stars 56 forks source link

New rule: consistent deps applications #334

Open paulo-ferraz-oliveira opened 9 months ago

paulo-ferraz-oliveira commented 9 months ago

Name

consistent_deps_applications

Brief Description

It's common to have .app.src updated with the dep names from rebar.config. This rule would look at rebar.config's deps, and compare them with the first found .app.src file in src/.

Reasoning

One less thing to remember when you're adding dependencies to your projects.

Refactoring Proposal

Make sure their list, in .app.src, is the same as deps. We could output the comma-separated list that could be simply copy-and-pasted, then formatted, as well as present an option to exclude applications when these aren't supposed to be in the .app.src file.

elbrujohalcon commented 9 months ago

It probably shouldn't be "the same list", since some applications are libraries and therefore there is no need to start them as part of the main application startup procedure, but the .app.src list should 100% be "a sublist" of deps.

elbrujohalcon commented 9 months ago

Oh, and we need to be careful with umbrella repos, too.

elbrujohalcon commented 9 months ago

On the other hand, if there is an app on .app.src that's not on deps (i.e., the list is not a sublist), the main app will fail on initialization (i.e. ensure_all_started(the_main_app)), or (if the app is never initialized - again, library apps) it will fail on Dialyzer/Xref checks when they find unknown function calls. That is, unless the app is never used, in which case this should be a more suitable rule for Hank than Elvis.