githubcode-analysisstatic-code-analysis

How can I detect the frameworks and/or libraries used in any Source Code Repository/Directory programatically?


Suppose I have a source code directory, I want to run a script that would scan the code in the directory and return the languages, frameworks and libraries used in it. I've tried github/linguist, its a great tool which even Github uses to detect the programming languages used in a source code, however I am not able go beyond that and detect the framework exactly.

I even tried tools like it-depends, to fetch the dependencies but, its getting messed up.

Could someone help me out to figure out how I can do this stuff, with an existing tool or if have to make one such tool how should I approach it.

Thanks in Advance


Solution

  • This is, in the general case, impossible. The halting problem precludes any program from being able to compute, in finite time, what other programs may or may not do - including what dependencies it requires to run. Sure, you can make it work for some inputs - but never for all.

    So you have to compromise:

    Therefore the answer to your question is that... it depends (they go into a fair amount of detail regarding limitations). For the specific case of Java + Maven, which is not covered by it-depends, you can use Maven itself, via mvn dependency:tree. Choose a subset of the problem instead of trying to solve it all at once.