unused-code / unused

A tool to identify potentially unused code.
https://unused.codes
MIT License
283 stars 11 forks source link

Is this project limited to Rails/Phoenix code? #50

Open mausch opened 1 year ago

mausch commented 1 year ago

Hi, this project looks very interesting! Just wondering if it's only meant to work on Rails/Phoenix code? I generated tags using universal-ctags on C# and Python projects but unused doesn't seem to find any unused code (there's obvious unused code that I introduced on purpose to test this).

Maybe I'm misunderstanding what "unused code" means in the context of this tool?

For example given this Python code:

xx=1
print("Hello World")

I get this output from nix shell nixpkgs#universal-ctags nixpkgs#unused -c sh -c "ctags -R; unused":

== UNUSED SUMMARY ==
   Tokens found: 0
   Files found: 0
   Applied language filters: except Markdown, JSON
   Sort order: token (asc)
   Usage likelihood: high
   Configuration setting: Default

I was expecting it to find xx=1 as unused code.

$ nix shell nixpkgs#universal-ctags nixpkgs#unused -c sh -c "unused doctor"
Unused Doctor

[OK] Check: Is the tags file not present in the list of files searched?
     The tags file loaded ("/home/mauricio/prg/unused-python-test/tags") is not present in the list of files searched
[Warning] Check: Are tokens found in the application?
     1 token(s) found
[OK] Check: Are files found in the application?
     2 file(s) found
[OK] Check: Is the tags file generated with Universal Ctags?
     Using tags program: Universal Ctags (Derived from Exuberant Ctags)
[OK] Check: Does the loaded configuration have available project types?
     Loaded the following project configurations: Rails, Phoenix

Outcome: 4 OK, 1 warnings, 0 errors
joshuaclayton commented 1 year ago

Hi @mausch !

It's not just geared towards Ruby and Elixir codebases, no.

unused doctor is hinting at a warning around the number of tags unused is finding (just 1) - it looks like Ctags may not be picking up tags. Can you check the tags file unused is finding and see if you can generate more tags?