Skip to content
Browse files

fix scoring function, use latest rugged build

  • Loading branch information...
1 parent 78b54c0 commit 09dd054a422e17531710f36eef106d6a2e8fe56e @igrigorik committed Feb 17, 2014
Showing with 12 additions and 6 deletions.
  1. +2 −0 Gemfile
  2. +1 −3 bin/bugspots
  3. +1 −1 bugspots.gemspec
  4. +8 −2 lib/bugspots/scanner.rb
View
2 Gemfile
@@ -1,4 +1,6 @@
source "http://rubygems.org"
+gem 'rugged', git: 'git://github.com/libgit2/rugged.git', branch: 'development', submodules: true
+
# Specify your gem's dependencies in bugspots.gemspec
gemspec
View
4 bin/bugspots
@@ -68,8 +68,6 @@ begin
puts "\t\t#{spot.score}".foreground(:red) + " - #{spot.file}".foreground(:yellow)
end
-rescue Exception => e
- p e
- p e.backtrace.first(5).join("\n")
+rescue Rugged::RepositoryError
puts "Invalid Git repository - please run from or specify the full path to the root of the project.".foreground(:red)
end
View
2 bugspots.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency "rugged"
+# s.add_dependency "rugged"
s.add_dependency "rainbow"
# specify any dependencies here; for example:
View
10 lib/bugspots/scanner.rb
@@ -14,7 +14,7 @@ def self.scan(repo, branch = "master", depth = 500, regex = nil)
end
walker = Rugged::Walker.new(repo)
- # walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
tip = Rugged::Branch.lookup(repo, branch).tip.oid
walker.push(tip)
@@ -31,7 +31,13 @@ def self.scan(repo, branch = "master", depth = 500, regex = nil)
hotspots = Hash.new(0)
fixes.each do |fix|
fix.files.each do |file|
- t = 1 - ((Time.now - fix.date).to_f / (Time.now - fixes.last.date))
+ # The timestamp used in the equation is normalized from 0 to 1, where
+ # 0 is the earliest point in the code base, and 1 is now (where now is
+ # when the algorithm was run). Note that the score changes over time
+ # with this algorithm due to the moving normalization; it's not meant
+ # to provide some objective score, only provide a means of comparison
+ # between one file and another at any one point in time
+ t = 1 - ((Time.now - fix.date).to_f / (Time.now - fixes.first.date))
hotspots[file] += 1/(1+Math.exp((-12*t)+12))
end
end

0 comments on commit 09dd054

Please sign in to comment.
Something went wrong with that request. Please try again.