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

Lint the *.app and/or *.app.src files #980

Closed
peerst opened this issue Dec 14, 2015 · 6 comments · Fixed by #2035
Closed

Lint the *.app and/or *.app.src files #980

peerst opened this issue Dec 14, 2015 · 6 comments · Fixed by #2035
Labels
beginner enhancement new behaviour or additional functionality

Comments

@peerst
Copy link

peerst commented Dec 14, 2015

It would be nice if 'rebar compile" could check *.app and *.app.src files for problems which can cause a hickup later when generating a release. e.g.

All later required fields are present.

Bonus: they have the right format.

@ferd ferd added the enhancement new behaviour or additional functionality label Jan 6, 2016
@ferd ferd added the beginner label Aug 27, 2016
@CrowdHailer
Copy link
Contributor

What is the status of this issue? still relevant? still beginner friendly?

@fenollp
Copy link
Contributor

fenollp commented May 21, 2018

Sounds to me like it should just be:

  • wrapping the file:consult call in a try...catch and display a nice syntax error
  • then check for expected/required keys and their types (verify applications is a well formed list of atoms, ...)

So yes :)

@peerst
Copy link
Author

peerst commented May 21, 2018

IIRC: one thing I stumbled upon was: relx requires stdlib and kernel as explicit deps while reltool didn’t care.

Also relx requires quite a bunch of keys which reltool didn’t care about.

@ferd
Copy link
Collaborator

ferd commented May 21, 2018

Yeah. IIRC those keys ended up being useful for relups whole reltool was glad to let this part of the procedure kind of die.

For example, not including stdlib and kernel can lead to edge cases where either (or both) libraries are unloaded before a custom one, and then the node becomes zombified on shutdown since it can't execute any other code to unload the libs leftover. description is also mandatory as a key once SASL starts dealing with relups iirc, and not having them kind of breaks a few things.

Can't remember the other ones off the top of my head, but those forced to be mandatory were usually there for a reason, and so early linting would probably be nice there yeah.

@CrowdHailer
Copy link
Contributor

This is sounding less beginner friendly. unless a try catch as suggested by @fenollp is enough

@ferd
Copy link
Collaborator

ferd commented May 21, 2018

I think the relevant code is in https://github.com/erlang/rebar3/blob/master/src/rebar_app_utils.erl#L97-L109

This function is called by the compiler task along with the discovery task, and basically ensures that the right fields are present (by default, it checks only for modules to be there and complete). Rebar3 automatically generates some mandatory fields (description, registered, and modules), but does no other validation than the modules list.

We could instead use that function and add warnings based on the content of these values:

validate_application_info(AppInfo, AppDetail) ->
    EbinDir = rebar_app_info:ebin_dir(AppInfo),
    case rebar_app_info:app_file(AppInfo) of
        undefined ->
            false;
        AppFile ->
            lint_detail(AppDetail),
            case proplists:get_value(modules, AppDetail) of
                undefined ->
                   ?PRV_ERROR({module_list, AppFile});
                List ->
                    has_all_beams(EbinDir, List)
            end
    end.

lint_detail(AppDetail) ->
    case proplists:get_value(description, AppDetail, "") of
        "" -> ?WARN("~p is missing description entry", [AppFile]);
        _ -> ok
    end,
    ... % more checks

and add all kinds of checks such as missing applications tuple, or a tuple without kernel and stdlib.

We should keep them warnings for now to prevent breaking builds that already worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner enhancement new behaviour or additional functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants