Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Update history comments
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Mar 30, 2024
1 parent 963e7dd commit ab3ea31
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/mosaik/extractors/history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def call
# Open the git repository
git = Git.open(MOSAIK.options.directory, log: ::Logger.new(File::NULL))

# Fetch commits, limited to the last 1000 commits
# Fetch commits, limited to the last N commits
commits = git.log(100)

# Limit commits to the load paths
Expand All @@ -18,10 +18,10 @@ def call

info "Analyzing #{commits.count} commits"

# Create a nested mapping for each pair of nodes in the graph
# Create a co-change matrix for each pair of files
matrix = Hash.new { |h, k| h[k] = Hash.new(0) }

# Calculate the aggregated local coupling
# Iterate over each commit
commits.each do |commit|
# Get the files for the commit
files = commit.diff_parent.stats[:files]
Expand All @@ -38,21 +38,21 @@ def call

debug "Commit #{commit.sha} (#{constants.count} constants: #{constants.join(', ')})"

# Calculate the local coupling
# Increment the local coupling between each pair of files
constants
.permutation(2)
.each { |(a, b)| matrix[a][b] += 1 }
end

debug "Building graph..."

# For each non-zero element in the matrix, add an edge to the graph
# For each non-zero element in the matrix, add a weighted edge to the graph
matrix.each do |a, row|
row.each do |b, value|
next if value.zero?

# Add an edge from the node to the receiver
graph.add_edge(a, b, label: value)
graph.add_directed_edge(a, b, label: value)
end
end
end
Expand Down

0 comments on commit ab3ea31

Please sign in to comment.