glato / emerge

Emerge is a browser-based interactive codebase and dependency visualization tool for many different programming languages. It supports some basic code quality and graph metrics and provides a simple and intuitive way to explore and analyze a codebase by using graph structures.
MIT License
783 stars 46 forks source link

JS files got duplicated #4

Closed nicoespeon closed 3 years ago

nicoespeon commented 3 years ago

I noticed something while generating graphs for JS projects I'm working with:

image

These 2 files are the same, but they are imported from 2 distinct files relatively: image

I think a solution would be to resolve the path of imported files relative to the root of the project. What do you think? Is there a similar problem in other languages or is it specific to the JS parser?

glato commented 3 years ago

You're absolutely right, I've already started to migrate the path resolving in this direction. Will try to come up with a more robust path resolving in the following days that works exactly that way.

glato commented 3 years ago

@nicoespeon Just pushed the bugfix version 0.14.1, which should hopefully (mostly) fix the duplicate issues by using relative analysis/project paths as a base for file results and parsed dependencies. Need to test and maybe optimize that further in the coming days.

nicoespeon commented 3 years ago

Awesome news @glato πŸ‘

I'll test that this week and get back to you with results.

nicoespeon commented 3 years ago

It looks better indeed! But I still find some remaining duplication: image

The structure is the following:

app/
|__ pages/
|   |__ purchase.js               # imports "../components/purchase/detailed-logs" 
|
|__ components/
    |__ purchase/
        |__ simple-logs.js        # imports "./detailed-logs" 
        |__ detailed-logs.js

Somehow, one of them results in app/components/purchase/detailed-logs.js and the other in ../components/purchase/detailed-logs.

Do you need help to debug this one?

glato commented 3 years ago

Thatβ€˜s interesting. Iβ€˜ll try to create a unit test based on this setup, to better debug and solve this case. Iβ€˜ll get back to you @nicoespeon, thanks for the report πŸ˜‰

glato commented 3 years ago

@nicoespeon Your structure example was very helpful, I've constructed the same and hopefully found the bug. It looks promising so far:

correct_dependency_path_resolving

I'll test this with more path cases tomorrow and on bigger examples.

nicoespeon commented 3 years ago

Glad it was helpful! Improving the parser, one test at a time 🧱 πŸ‘

glato commented 3 years ago

@nicoespeon I've updated the (dependency) path resolving for TS and JS in the new version 0.15.1. This includes some smaller refactorings that allows to better unit test some path resolving methods. I've tested this with the source repos of Angular and React, seems to be promising so far. Would be great if you find some time to re-test this with version 0.15.1 and report back if this solved the problems?

nicoespeon commented 3 years ago

Did another try today and that worked wonderfully! image

Great job you did here πŸ‘

I'll experiment around, see if the graph is overall correct (this one is a reasonable-sized project I can grasp with my brain). Then I'll also experiment on a much bigger project I can't grasp.

I'll let you know if I find issues. If I can, I'll attempt to fix them too πŸ‘ In the meantime, this issue looks fixed to me. Thank you!

nicoespeon commented 3 years ago

@glato I just found a file that was a solo-node, floating around. Turns out this is a dead code that's not imported anywhere πŸ’―

Thank you for this quick win I got here!