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

Invalid unused include warning when including eunit.hrl #1047

Closed
eproxus opened this issue Jun 29, 2021 · 6 comments
Closed

Invalid unused include warning when including eunit.hrl #1047

eproxus opened this issue Jun 29, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@eproxus
Copy link

eproxus commented Jun 29, 2021

Describe the bug
Consider the following module:

-module(my_tests).
-include_lib("eunit/include/eunit.hrl").
the_test() -> ok.

A warning will be generated on line 2: warning Unused file: eunit.hrl ​UnusedIncludes

To Reproduce
Create the module.

Expected behavior
No warning is issued since the include file is used, because it exports the the_test/0 function. If the file is not included, the test doesn't work.

Actual behavior
A false warning is issued: warning Unused file: eunit.hrl ​UnusedIncludes

Context

  • erlang_ls version (tag/sha): 0.17.0
  • Editor used: Sublime Text 4 (4109)
  • LSP client used: Sublime LSP v1.6.1
@eproxus eproxus added the bug Something isn't working label Jun 29, 2021
@gomoripeti
Copy link
Contributor

thanks Adam, this is indeed a bug. Just cross-linking with the related #964

@robertoaloi
Copy link
Member

What we could have (unless we manage to fix all corner cases) is a ignore-list for header files. Candidates could be:

eunit/include/eunit.hrl
proper/include/proper.hrl
eqc/include/eqc.hrl
pmod_transform/include/pmod.hrl
stdlib/include/qlc.hrl
stdlib/include/ms_transform.hrl

The user could customize the list if required. Similar to the Exclude OTP Apps list

@michalmuskala
Copy link
Contributor

Shouldn't any header file that includes -parse_transform attribute be excluded like this? I think this should cover all of the above

@robertoaloi
Copy link
Member

That should work. I was thinking to cases "other" than parse transforms, but maybe there isn't any.

@gomoripeti
Copy link
Contributor

to be very precise it is not a -parse_transform attribute, but a compiler option in a -compile attribute, but probably the presence of any compiler option should make the header be excluded.
for "other" cases Daniel brings up in the other ticket wild attributes that are not known by the compiler.

@robertoaloi
Copy link
Member

@eproxus This should now be solved in the lastest HEAD, let me know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants