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
818 stars 49 forks source link

Fix git metrics for languages that don't support entity parsing #41

Closed tonysyu closed 1 year ago

tonysyu commented 1 year ago

Summary

Check that currentGraph is defined addGitMetricToFileNodes before attempting to update git metrics.

Languages that don't support entity parsing attempted to update the graph with git metrics before currentGraph was defined on initial rendering.

Issue

To reproduce the issue (before this change), you can run the following in this repo:

python3 emerge.py -c py-template.yaml

using the following py-template.yaml (default python config with git_directory and git-metrics added):

---
project_name: py-example-project
loglevel: info
analyses:
- analysis_name: py check
  source_directory: emerge
  git_directory: ./.git
  only_permit_languages:
  - py
  only_permit_file_extensions:
  - .py
  file_scan:
  - git_metrics
  - number_of_methods
  - source_lines_of_code
  - dependency_graph
  - louvain_modularity
  - fan_in_out
  - tfidf
  export:
  - directory: emerge-output
  - graphml
  - json
  - tabular_file
  - tabular_console_overall
  - d3

Opening the output html (i.e. emerge-output/html/emerge.html) won't display a graph due to the error described above.

greenled commented 1 year ago

Tested it with a Go repo :+1: Thanks!

glato commented 1 year ago

@tonysyu Thanks for this fix 🚀, @greenled thanks for testing 💪.