浏览代码

Fix golint warnings unrelated to export and docs

Vadim Markovtsev 7 年之前
父节点
当前提交
44c4e38ac8
共有 20 个文件被更改,包括 216 次插入218 次删除
  1. 1 1
      Makefile
  2. 31 31
      blob_cache.go
  3. 48 47
      burndown.go
  4. 1 1
      cmd/hercules/combine.go
  5. 3 3
      cmd/hercules/root.go
  6. 11 11
      couples.go
  7. 3 3
      couples_test.go
  8. 9 9
      diff.go
  9. 23 23
      file.go
  10. 2 2
      file_test.go
  11. 18 18
      identity.go
  12. 3 3
      identity_test.go
  13. 1 2
      pipeline_test.go
  14. 1 2
      registry.go
  15. 49 49
      renames.go
  16. 2 2
      renames_test.go
  17. 1 1
      shotness.go
  18. 3 3
      tree_diff.go
  19. 3 4
      uast.go
  20. 3 3
      version.go

+ 1 - 1
Makefile

@@ -30,4 +30,4 @@ ${GOPATH}/src/gopkg.in/bblfsh/client-go.v2:
 .ONESHELL:
 ${GOPATH}/bin/hercules: dependencies *.go cmd/hercules/*.go rbtree/*.go yaml/*.go toposort/*.go pb/*.go
 	cd ${GOPATH}/src/gopkg.in/src-d/hercules.v3
-	go get -ldflags "-X gopkg.in/src-d/hercules.v3.GIT_HASH=$$(git rev-parse HEAD)" gopkg.in/src-d/hercules.v3/cmd/hercules
+	go get -ldflags "-X gopkg.in/src-d/hercules.v3.BinaryGitHash=$$(git rev-parse HEAD)" gopkg.in/src-d/hercules.v3/cmd/hercules

+ 31 - 31
blob_cache.go

@@ -12,8 +12,8 @@ import (
 )
 
 // This PipelineItem loads the blobs which correspond to the changed files in a commit.
-// It must provide the old and the new objects; "cache" rotates and allows to not load
-// the same blobs twice. Outdated objects are removed so "cache" never grows big.
+// It must provide the old and the new objects; "blobCache" rotates and allows to not load
+// the same blobs twice. Outdated objects are removed so "blobCache" never grows big.
 type BlobCache struct {
 	// Specifies how to handle the situation when we encounter a git submodule - an object without
 	// the blob. If false, we look inside .gitmodules and if don't find, raise an error.
@@ -29,21 +29,21 @@ const (
 	DependencyBlobCache                    = "blob_cache"
 )
 
-func (cache *BlobCache) Name() string {
+func (blobCache *BlobCache) Name() string {
 	return "BlobCache"
 }
 
-func (cache *BlobCache) Provides() []string {
+func (blobCache *BlobCache) Provides() []string {
 	arr := [...]string{DependencyBlobCache}
 	return arr[:]
 }
 
-func (cache *BlobCache) Requires() []string {
+func (blobCache *BlobCache) Requires() []string {
 	arr := [...]string{DependencyTreeChanges}
 	return arr[:]
 }
 
-func (cache *BlobCache) ListConfigurationOptions() []ConfigurationOption {
+func (blobCache *BlobCache) ListConfigurationOptions() []ConfigurationOption {
 	options := [...]ConfigurationOption{{
 		Name: ConfigBlobCacheIgnoreMissingSubmodules,
 		Description: "Specifies whether to panic if some submodules do not exist and thus " +
@@ -54,18 +54,18 @@ func (cache *BlobCache) ListConfigurationOptions() []ConfigurationOption {
 	return options[:]
 }
 
-func (cache *BlobCache) Configure(facts map[string]interface{}) {
+func (blobCache *BlobCache) Configure(facts map[string]interface{}) {
 	if val, exists := facts[ConfigBlobCacheIgnoreMissingSubmodules].(bool); exists {
-		cache.IgnoreMissingSubmodules = val
+		blobCache.IgnoreMissingSubmodules = val
 	}
 }
 
-func (cache *BlobCache) Initialize(repository *git.Repository) {
-	cache.repository = repository
-	cache.cache = map[plumbing.Hash]*object.Blob{}
+func (blobCache *BlobCache) Initialize(repository *git.Repository) {
+	blobCache.repository = repository
+	blobCache.cache = map[plumbing.Hash]*object.Blob{}
 }
 
-func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
+func (blobCache *BlobCache) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
 	commit := deps["commit"].(*object.Commit)
 	changes := deps[DependencyTreeChanges].(object.Changes)
 	cache := map[plumbing.Hash]*object.Blob{}
@@ -80,7 +80,7 @@ func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interfac
 		var blob *object.Blob
 		switch action {
 		case merkletrie.Insert:
-			blob, err = self.getBlob(&change.To, commit.File)
+			blob, err = blobCache.getBlob(&change.To, commit.File)
 			if err != nil {
 				fmt.Fprintf(os.Stderr, "file to %s %s\n", change.To.Name, change.To.TreeEntry.Hash)
 			} else {
@@ -88,9 +88,9 @@ func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interfac
 				newCache[change.To.TreeEntry.Hash] = blob
 			}
 		case merkletrie.Delete:
-			cache[change.From.TreeEntry.Hash], exists = self.cache[change.From.TreeEntry.Hash]
+			cache[change.From.TreeEntry.Hash], exists = blobCache.cache[change.From.TreeEntry.Hash]
 			if !exists {
-				cache[change.From.TreeEntry.Hash], err = self.getBlob(&change.From, commit.File)
+				cache[change.From.TreeEntry.Hash], err = blobCache.getBlob(&change.From, commit.File)
 				if err != nil {
 					if err.Error() != plumbing.ErrObjectNotFound.Error() {
 						fmt.Fprintf(os.Stderr, "file from %s %s\n", change.From.Name,
@@ -102,16 +102,16 @@ func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interfac
 				}
 			}
 		case merkletrie.Modify:
-			blob, err = self.getBlob(&change.To, commit.File)
+			blob, err = blobCache.getBlob(&change.To, commit.File)
 			if err != nil {
 				fmt.Fprintf(os.Stderr, "file to %s\n", change.To.Name)
 			} else {
 				cache[change.To.TreeEntry.Hash] = blob
 				newCache[change.To.TreeEntry.Hash] = blob
 			}
-			cache[change.From.TreeEntry.Hash], exists = self.cache[change.From.TreeEntry.Hash]
+			cache[change.From.TreeEntry.Hash], exists = blobCache.cache[change.From.TreeEntry.Hash]
 			if !exists {
-				cache[change.From.TreeEntry.Hash], err = self.getBlob(&change.From, commit.File)
+				cache[change.From.TreeEntry.Hash], err = blobCache.getBlob(&change.From, commit.File)
 				if err != nil {
 					fmt.Fprintf(os.Stderr, "file from %s\n", change.From.Name)
 				}
@@ -121,7 +121,7 @@ func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interfac
 			return nil, err
 		}
 	}
-	self.cache = newCache
+	blobCache.cache = newCache
 	return map[string]interface{}{DependencyBlobCache: cache}, nil
 }
 
@@ -131,9 +131,9 @@ func (self *BlobCache) Consume(deps map[string]interface{}) (map[string]interfac
 type FileGetter func(path string) (*object.File, error)
 
 // Returns the blob which corresponds to the specified ChangeEntry.
-func (cache *BlobCache) getBlob(entry *object.ChangeEntry, fileGetter FileGetter) (
+func (blobCache *BlobCache) getBlob(entry *object.ChangeEntry, fileGetter FileGetter) (
 	*object.Blob, error) {
-	blob, err := cache.repository.BlobObject(entry.TreeEntry.Hash)
+	blob, err := blobCache.repository.BlobObject(entry.TreeEntry.Hash)
 	if err != nil {
 		if err.Error() != plumbing.ErrObjectNotFound.Error() {
 			fmt.Fprintf(os.Stderr, "getBlob(%s)\n", entry.TreeEntry.Hash.String())
@@ -142,21 +142,21 @@ func (cache *BlobCache) getBlob(entry *object.ChangeEntry, fileGetter FileGetter
 		if entry.TreeEntry.Mode != 0160000 {
 			// this is not a submodule
 			return nil, err
-		} else if cache.IgnoreMissingSubmodules {
+		} else if blobCache.IgnoreMissingSubmodules {
 			return createDummyBlob(entry.TreeEntry.Hash)
 		}
-		file, err_modules := fileGetter(".gitmodules")
-		if err_modules != nil {
-			return nil, err_modules
+		file, errModules := fileGetter(".gitmodules")
+		if errModules != nil {
+			return nil, errModules
 		}
-		contents, err_modules := file.Contents()
-		if err_modules != nil {
-			return nil, err_modules
+		contents, errModules := file.Contents()
+		if errModules != nil {
+			return nil, errModules
 		}
 		modules := config.NewModules()
-		err_modules = modules.Unmarshal([]byte(contents))
-		if err_modules != nil {
-			return nil, err_modules
+		errModules = modules.Unmarshal([]byte(contents))
+		if errModules != nil {
+			return nil, errModules
 		}
 		_, exists := modules.Submodules[entry.Name]
 		if exists {

+ 48 - 47
burndown.go

@@ -263,9 +263,9 @@ func (analyser *BurndownAnalysis) Finalize() interface{} {
 		mrow := make([]int64, analyser.PeopleNumber+2)
 		peopleMatrix[i] = mrow
 		for key, val := range row {
-			if key == MISSING_AUTHOR {
+			if key == AuthorMissing {
 				key = -1
-			} else if key == SELF_AUTHOR {
+			} else if key == AuthorSelf {
 				key = -2
 			}
 			mrow[key+2] = val
@@ -772,55 +772,56 @@ func (analyser *BurndownAnalysis) packPersonWithDay(person int, day int) int {
 
 func (analyser *BurndownAnalysis) unpackPersonWithDay(value int) (int, int) {
 	if analyser.PeopleNumber == 0 {
-		return MISSING_AUTHOR, value
+		return AuthorMissing, value
 	}
 	return value >> 14, value & 0x3FFF
 }
 
 func (analyser *BurndownAnalysis) updateStatus(
-	status interface{}, _ int, previous_time_ int, delta int) {
+	status interface{}, _ int, previousValue int, delta int) {
 
-	_, previous_time := analyser.unpackPersonWithDay(previous_time_)
-	status.(map[int]int64)[previous_time] += int64(delta)
+	_, previousTime := analyser.unpackPersonWithDay(previousValue)
+	status.(map[int]int64)[previousTime] += int64(delta)
 }
 
-func (analyser *BurndownAnalysis) updatePeople(people interface{}, _ int, previous_time_ int, delta int) {
-	old_author, previous_time := analyser.unpackPersonWithDay(previous_time_)
-	if old_author == MISSING_AUTHOR {
+func (analyser *BurndownAnalysis) updatePeople(
+	peopleUncasted interface{}, _ int, previousValue int, delta int) {
+	previousAuthor, previousTime := analyser.unpackPersonWithDay(previousValue)
+	if previousAuthor == AuthorMissing {
 		return
 	}
-	casted := people.([]map[int]int64)
-	stats := casted[old_author]
+	people := peopleUncasted.([]map[int]int64)
+	stats := people[previousAuthor]
 	if stats == nil {
 		stats = map[int]int64{}
-		casted[old_author] = stats
+		people[previousAuthor] = stats
 	}
-	stats[previous_time] += int64(delta)
+	stats[previousTime] += int64(delta)
 }
 
 func (analyser *BurndownAnalysis) updateMatrix(
-	matrix_ interface{}, current_time int, previous_time int, delta int) {
+	matrixUncasted interface{}, currentTime int, previousTime int, delta int) {
 
-	matrix := matrix_.([]map[int]int64)
-	new_author, _ := analyser.unpackPersonWithDay(current_time)
-	old_author, _ := analyser.unpackPersonWithDay(previous_time)
-	if old_author == MISSING_AUTHOR {
+	matrix := matrixUncasted.([]map[int]int64)
+	newAuthor, _ := analyser.unpackPersonWithDay(currentTime)
+	oldAuthor, _ := analyser.unpackPersonWithDay(previousTime)
+	if oldAuthor == AuthorMissing {
 		return
 	}
-	if new_author == old_author && delta > 0 {
-		new_author = SELF_AUTHOR
+	if newAuthor == oldAuthor && delta > 0 {
+		newAuthor = AuthorSelf
 	}
-	row := matrix[old_author]
+	row := matrix[oldAuthor]
 	if row == nil {
 		row = map[int]int64{}
-		matrix[old_author] = row
+		matrix[oldAuthor] = row
 	}
-	cell, exists := row[new_author]
+	cell, exists := row[newAuthor]
 	if !exists {
-		row[new_author] = 0
+		row[newAuthor] = 0
 		cell = 0
 	}
-	row[new_author] = cell + int64(delta)
+	row[newAuthor] = cell + int64(delta)
 }
 
 func (analyser *BurndownAnalysis) newFile(
@@ -852,7 +853,7 @@ func (analyser *BurndownAnalysis) handleInsertion(
 	name := change.To.Name
 	file, exists := analyser.files[name]
 	if exists {
-		return errors.New(fmt.Sprintf("file %s already exists", name))
+		return fmt.Errorf("file %s already exists", name)
 	}
 	file = analyser.newFile(
 		author, analyser.day, lines, analyser.globalStatus, analyser.people, analyser.matrix)
@@ -899,9 +900,9 @@ func (analyser *BurndownAnalysis) handleModification(
 	thisDiffs := diffs[change.To.Name]
 	if file.Len() != thisDiffs.OldLinesOfCode {
 		fmt.Fprintf(os.Stderr, "====TREE====\n%s", file.Dump())
-		return errors.New(fmt.Sprintf("%s: internal integrity error src %d != %d %s -> %s",
+		return fmt.Errorf("%s: internal integrity error src %d != %d %s -> %s",
 			change.To.Name, thisDiffs.OldLinesOfCode, file.Len(),
-			change.From.TreeEntry.Hash.String(), change.To.TreeEntry.Hash.String()))
+			change.From.TreeEntry.Hash.String(), change.To.TreeEntry.Hash.String())
 	}
 
 	// we do not call RunesToDiffLines so the number of lines equals
@@ -923,17 +924,17 @@ func (analyser *BurndownAnalysis) handleModification(
 	}
 
 	for _, edit := range thisDiffs.Diffs {
-		dump_before := ""
+		dumpBefore := ""
 		if analyser.Debug {
-			dump_before = file.Dump()
+			dumpBefore = file.Dump()
 		}
 		length := utf8.RuneCountInString(edit.Text)
-		debug_error := func() {
+		debugError := func() {
 			fmt.Fprintf(os.Stderr, "%s: internal diff error\n", change.To.Name)
 			fmt.Fprintf(os.Stderr, "Update(%d, %d, %d (0), %d (0))\n", analyser.day, position,
 				length, utf8.RuneCountInString(pending.Text))
-			if dump_before != "" {
-				fmt.Fprintf(os.Stderr, "====TREE BEFORE====\n%s====END====\n", dump_before)
+			if dumpBefore != "" {
+				fmt.Fprintf(os.Stderr, "====TREE BEFORE====\n%s====END====\n", dumpBefore)
 			}
 			fmt.Fprintf(os.Stderr, "====TREE AFTER====\n%s====END====\n", file.Dump())
 		}
@@ -947,7 +948,7 @@ func (analyser *BurndownAnalysis) handleModification(
 		case diffmatchpatch.DiffInsert:
 			if pending.Text != "" {
 				if pending.Type == diffmatchpatch.DiffInsert {
-					debug_error()
+					debugError()
 					return errors.New("DiffInsert may not appear after DiffInsert")
 				}
 				file.Update(analyser.packPersonWithDay(author, analyser.day), position, length,
@@ -962,13 +963,13 @@ func (analyser *BurndownAnalysis) handleModification(
 			}
 		case diffmatchpatch.DiffDelete:
 			if pending.Text != "" {
-				debug_error()
+				debugError()
 				return errors.New("DiffDelete may not appear after DiffInsert/DiffDelete")
 			}
 			pending = edit
 		default:
-			debug_error()
-			return errors.New(fmt.Sprintf("diff operation is not supported: %d", edit.Type))
+			debugError()
+			return fmt.Errorf("diff operation is not supported: %d", edit.Type)
 		}
 	}
 	if pending.Text != "" {
@@ -976,8 +977,8 @@ func (analyser *BurndownAnalysis) handleModification(
 		pending.Text = ""
 	}
 	if file.Len() != thisDiffs.NewLinesOfCode {
-		return errors.New(fmt.Sprintf("%s: internal integrity error dst %d != %d",
-			change.To.Name, thisDiffs.NewLinesOfCode, file.Len()))
+		return fmt.Errorf("%s: internal integrity error dst %d != %d",
+			change.To.Name, thisDiffs.NewLinesOfCode, file.Len())
 	}
 	return nil
 }
@@ -985,7 +986,7 @@ func (analyser *BurndownAnalysis) handleModification(
 func (analyser *BurndownAnalysis) handleRename(from, to string) error {
 	file, exists := analyser.files[from]
 	if !exists {
-		return errors.New(fmt.Sprintf("file %s does not exist", from))
+		return fmt.Errorf("file %s does not exist", from)
 	}
 	analyser.files[to] = file
 	delete(analyser.files, from)
@@ -1053,15 +1054,15 @@ func (analyser *BurndownAnalysis) groupStatus() ([]int64, map[string][]int64, []
 }
 
 func (analyser *BurndownAnalysis) updateHistories(
-	globalStatus []int64, file_statuses map[string][]int64, people_statuses [][]int64, delta int) {
+	globalStatus []int64, fileStatuses map[string][]int64, peopleStatuses [][]int64, delta int) {
 	for i := 0; i < delta; i++ {
 		analyser.globalHistory = append(analyser.globalHistory, globalStatus)
 	}
-	to_delete := make([]string, 0)
+	toDelete := make([]string, 0)
 	for key, fh := range analyser.fileHistories {
-		ls, exists := file_statuses[key]
+		ls, exists := fileStatuses[key]
 		if !exists {
-			to_delete = append(to_delete, key)
+			toDelete = append(toDelete, key)
 		} else {
 			for i := 0; i < delta; i++ {
 				fh = append(fh, ls)
@@ -1069,10 +1070,10 @@ func (analyser *BurndownAnalysis) updateHistories(
 			analyser.fileHistories[key] = fh
 		}
 	}
-	for _, key := range to_delete {
+	for _, key := range toDelete {
 		delete(analyser.fileHistories, key)
 	}
-	for key, ls := range file_statuses {
+	for key, ls := range fileStatuses {
 		fh, exists := analyser.fileHistories[key]
 		if exists {
 			continue
@@ -1084,7 +1085,7 @@ func (analyser *BurndownAnalysis) updateHistories(
 	}
 
 	for key, ph := range analyser.peopleHistories {
-		ls := people_statuses[key]
+		ls := peopleStatuses[key]
 		for i := 0; i < delta; i++ {
 			ph = append(ph, ls)
 		}

+ 1 - 1
cmd/hercules/combine.go

@@ -51,7 +51,7 @@ var combineCmd = &cobra.Command{
 		mergedMessage := pb.AnalysisResults{
 			Header: &pb.Metadata{
 				Version:    2,
-				Hash:       hercules.GIT_HASH,
+				Hash:       hercules.BinaryGitHash,
 				Repository: strings.Join(repos, " & "),
 			},
 			Contents: map[string][]byte{},

+ 3 - 3
cmd/hercules/root.go

@@ -235,7 +235,7 @@ func printResults(
 
 	fmt.Println("hercules:")
 	fmt.Println("  version: 3")
-	fmt.Println("  hash:", hercules.GIT_HASH)
+	fmt.Println("  hash:", hercules.BinaryGitHash)
 	fmt.Println("  repository:", uri)
 	fmt.Println("  begin_unix_time:", commonResult.BeginTime)
 	fmt.Println("  end_unix_time:", commonResult.EndTime)
@@ -257,7 +257,7 @@ func protobufResults(
 
 	header := pb.Metadata{
 		Version:    2,
-		Hash:       hercules.GIT_HASH,
+		Hash:       hercules.BinaryGitHash,
 		Repository: uri,
 	}
 	results[nil].(*hercules.CommonAnalysisResult).FillMetadata(&header)
@@ -368,7 +368,7 @@ var versionCmd = &cobra.Command{
 	Long:  ``,
 	Args:  cobra.MaximumNArgs(0),
 	Run: func(cmd *cobra.Command, args []string) {
-		fmt.Printf("Version: %d\nGit:     %s\n", hercules.VERSION, hercules.GIT_HASH)
+		fmt.Printf("Version: %d\nGit:     %s\n", hercules.BinaryVersion, hercules.BinaryGitHash)
 	},
 }
 

+ 11 - 11
couples.go

@@ -19,8 +19,8 @@ type CouplesAnalysis struct {
 
 	// people store how many times every developer committed to every file.
 	people []map[string]int
-	// people_commits is the number of commits each author made
-	people_commits []int
+	// peopleCommits is the number of commits each author made
+	peopleCommits []int
 	// files store every file occurred in the same commit with every other file.
 	files map[string]map[string]int
 	// references IdentityDetector.ReversedPeopleDict
@@ -70,17 +70,17 @@ func (couples *CouplesAnalysis) Initialize(repository *git.Repository) {
 	for i := range couples.people {
 		couples.people[i] = map[string]int{}
 	}
-	couples.people_commits = make([]int, couples.PeopleNumber+1)
+	couples.peopleCommits = make([]int, couples.PeopleNumber+1)
 	couples.files = map[string]map[string]int{}
 }
 
 func (couples *CouplesAnalysis) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
 	author := deps[DependencyAuthor].(int)
-	if author == MISSING_AUTHOR {
+	if author == AuthorMissing {
 		author = couples.PeopleNumber
 	}
-	couples.people_commits[author] += 1
-	tree_diff := deps[DependencyTreeChanges].(object.Changes)
+	couples.peopleCommits[author]++
+	treeDiff := deps[DependencyTreeChanges].(object.Changes)
 	context := make([]string, 0)
 	deleteFile := func(name string) {
 		// we do not remove the file from people - the context does not expire
@@ -89,7 +89,7 @@ func (couples *CouplesAnalysis) Consume(deps map[string]interface{}) (map[string
 			delete(otherFiles, name)
 		}
 	}
-	for _, change := range tree_diff {
+	for _, change := range treeDiff {
 		action, err := change.Action()
 		if err != nil {
 			return nil, err
@@ -99,10 +99,10 @@ func (couples *CouplesAnalysis) Consume(deps map[string]interface{}) (map[string
 		switch action {
 		case merkletrie.Insert:
 			context = append(context, toName)
-			couples.people[author][toName] += 1
+			couples.people[author][toName]++
 		case merkletrie.Delete:
 			deleteFile(fromName)
-			couples.people[author][fromName] += 1
+			couples.people[author][fromName]++
 		case merkletrie.Modify:
 			if fromName != toName {
 				// renamed
@@ -123,7 +123,7 @@ func (couples *CouplesAnalysis) Consume(deps map[string]interface{}) (map[string
 				}
 			}
 			context = append(context, toName)
-			couples.people[author][toName] += 1
+			couples.people[author][toName]++
 		}
 	}
 	for _, file := range context {
@@ -133,7 +133,7 @@ func (couples *CouplesAnalysis) Consume(deps map[string]interface{}) (map[string
 				lane = map[string]int{}
 				couples.files[file] = lane
 			}
-			lane[otherFile] += 1
+			lane[otherFile]++
 		}
 	}
 	return nil, nil

+ 3 - 3
couples_test.go

@@ -116,9 +116,9 @@ func TestCouplesConsumeFinalize(t *testing.T) {
 	assert.Equal(t, c.files["five"]["five"], 3)
 	assert.Equal(t, c.files["five"]["one"], 1)
 	assert.Equal(t, c.files["five"]["three"], 1)
-	assert.Equal(t, c.people_commits[0], 2)
-	assert.Equal(t, c.people_commits[1], 1)
-	assert.Equal(t, c.people_commits[2], 1)
+	assert.Equal(t, c.peopleCommits[0], 2)
+	assert.Equal(t, c.peopleCommits[1], 1)
+	assert.Equal(t, c.peopleCommits[2], 1)
 	cr := c.Finalize().(CouplesResult)
 	assert.Equal(t, len(cr.Files), 3)
 	assert.Equal(t, cr.Files[0], "five")

+ 9 - 9
diff.go

@@ -66,28 +66,28 @@ func (diff *FileDiff) Initialize(repository *git.Repository) {}
 func (diff *FileDiff) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
 	result := map[string]FileDiffData{}
 	cache := deps[DependencyBlobCache].(map[plumbing.Hash]*object.Blob)
-	tree_diff := deps[DependencyTreeChanges].(object.Changes)
-	for _, change := range tree_diff {
+	treeDiff := deps[DependencyTreeChanges].(object.Changes)
+	for _, change := range treeDiff {
 		action, err := change.Action()
 		if err != nil {
 			return nil, err
 		}
 		switch action {
 		case merkletrie.Modify:
-			blob_from := cache[change.From.TreeEntry.Hash]
-			blob_to := cache[change.To.TreeEntry.Hash]
+			blobFrom := cache[change.From.TreeEntry.Hash]
+			blobTo := cache[change.To.TreeEntry.Hash]
 			// we are not validating UTF-8 here because for example
 			// git/git 4f7770c87ce3c302e1639a7737a6d2531fe4b160 fetch-pack.c is invalid UTF-8
-			str_from, err := BlobToString(blob_from)
+			strFrom, err := BlobToString(blobFrom)
 			if err != nil {
 				return nil, err
 			}
-			str_to, err := BlobToString(blob_to)
+			strTo, err := BlobToString(blobTo)
 			if err != nil {
 				return nil, err
 			}
 			dmp := diffmatchpatch.New()
-			src, dst, _ := dmp.DiffLinesToRunes(str_from, str_to)
+			src, dst, _ := dmp.DiffLinesToRunes(strFrom, strTo)
 			diffs := dmp.DiffMainRunes(src, dst, false)
 			if !diff.CleanupDisabled {
 				diffs = dmp.DiffCleanupSemanticLossless(diffs)
@@ -106,7 +106,7 @@ func (diff *FileDiff) Consume(deps map[string]interface{}) (map[string]interface
 
 func CountLines(file *object.Blob) (int, error) {
 	if file == nil {
-		return -1, errors.New("Blob is nil: probably not cached.")
+		return -1, errors.New("blob is nil: probably not cached")
 	}
 	reader, err := file.Reader()
 	if err != nil {
@@ -134,7 +134,7 @@ func CountLines(file *object.Blob) (int, error) {
 
 func BlobToString(file *object.Blob) (string, error) {
 	if file == nil {
-		return "", errors.New("Blob is nil: probably not cached.")
+		return "", errors.New("blob is nil: probably not cached")
 	}
 	reader, err := file.Reader()
 	if err != nil {

+ 23 - 23
file.go

@@ -77,9 +77,9 @@ func abs64(v int64) int64 {
 	return v
 }
 
-func (file *File) updateTime(current_time int, previous_time int, delta int) {
+func (file *File) updateTime(currentTime int, previousTime int, delta int) {
 	for _, status := range file.statuses {
-		status.update(status.data, current_time, previous_time, delta)
+		status.update(status.data, currentTime, previousTime, delta)
 	}
 }
 
@@ -146,17 +146,17 @@ func (file *File) Len() int {
 // The code inside this function is probably the most important one throughout
 // the project. It is extensively covered with tests. If you find a bug, please
 // add the corresponding case in file_test.go.
-func (file *File) Update(time int, pos int, ins_length int, del_length int) {
+func (file *File) Update(time int, pos int, insLength int, delLength int) {
 	if time < 0 {
 		panic("time may not be negative")
 	}
 	if pos < 0 {
 		panic("attempt to insert/delete at a negative position")
 	}
-	if ins_length < 0 || del_length < 0 {
-		panic("ins_length and del_length must be nonnegative")
+	if insLength < 0 || delLength < 0 {
+		panic("insLength and delLength must be non-negative")
 	}
-	if ins_length|del_length == 0 {
+	if insLength|delLength == 0 {
 		return
 	}
 	tree := file.tree
@@ -169,19 +169,19 @@ func (file *File) Update(time int, pos int, ins_length int, del_length int) {
 	}
 	iter := tree.FindLE(pos)
 	origin := *iter.Item()
-	file.updateTime(time, time, ins_length)
-	if del_length == 0 {
+	file.updateTime(time, time, insLength)
+	if delLength == 0 {
 		// simple case with insertions only
 		if origin.Key < pos || (origin.Value == time && pos == 0) {
 			iter = iter.Next()
 		}
 		for ; !iter.Limit(); iter = iter.Next() {
-			iter.Item().Key += ins_length
+			iter.Item().Key += insLength
 		}
 		if origin.Value != time {
 			tree.Insert(rbtree.Item{Key: pos, Value: time})
 			if origin.Key < pos {
-				tree.Insert(rbtree.Item{Key: pos + ins_length, Value: origin.Value})
+				tree.Insert(rbtree.Item{Key: pos + insLength, Value: origin.Value})
 			}
 		}
 		return
@@ -190,14 +190,14 @@ func (file *File) Update(time int, pos int, ins_length int, del_length int) {
 	// delete nodes
 	for true {
 		node := iter.Item()
-		next_iter := iter.Next()
-		if next_iter.Limit() {
-			if pos+del_length > node.Key {
+		nextIter := iter.Next()
+		if nextIter.Limit() {
+			if pos+delLength > node.Key {
 				panic("attempt to delete after the end of the file")
 			}
 			break
 		}
-		delta := min(next_iter.Item().Key, pos+del_length) - max(node.Key, pos)
+		delta := min(nextIter.Item().Key, pos+delLength) - max(node.Key, pos)
 		if delta <= 0 {
 			break
 		}
@@ -206,12 +206,12 @@ func (file *File) Update(time int, pos int, ins_length int, del_length int) {
 			origin = *node
 			tree.DeleteWithIterator(iter)
 		}
-		iter = next_iter
+		iter = nextIter
 	}
 
 	// prepare for the keys update
 	var previous *rbtree.Item
-	if ins_length > 0 && (origin.Value != time || origin.Key == pos) {
+	if insLength > 0 && (origin.Value != time || origin.Key == pos) {
 		// insert our new interval
 		if iter.Item().Value == time {
 			prev := iter.Prev()
@@ -232,21 +232,21 @@ func (file *File) Update(time int, pos int, ins_length int, del_length int) {
 	}
 
 	// update the keys of all subsequent nodes
-	delta := ins_length - del_length
+	delta := insLength - delLength
 	if delta != 0 {
 		for iter = iter.Next(); !iter.Limit(); iter = iter.Next() {
 			// we do not need to re-balance the tree
 			iter.Item().Key += delta
 		}
-		// have to adjust origin in case ins_length == 0
+		// have to adjust origin in case insLength == 0
 		if origin.Key > pos {
 			origin.Key += delta
 		}
 	}
 
-	if ins_length > 0 {
+	if insLength > 0 {
 		if origin.Value != time {
-			tree.Insert(rbtree.Item{Key: pos + ins_length, Value: origin.Value})
+			tree.Insert(rbtree.Item{Key: pos + insLength, Value: origin.Value})
 		} else if pos == 0 {
 			// recover the beginning
 			tree.Insert(rbtree.Item{Key: pos, Value: time})
@@ -292,12 +292,12 @@ func (file *File) Validate() {
 	if file.tree.Max().Item().Value != TreeEnd {
 		panic(fmt.Sprintf("the last value in the tree must be %d", TreeEnd))
 	}
-	prev_key := -1
+	prevKey := -1
 	for iter := file.tree.Min(); !iter.Limit(); iter = iter.Next() {
 		node := iter.Item()
-		if node.Key == prev_key {
+		if node.Key == prevKey {
 			panic(fmt.Sprintf("duplicate tree key: %d", node.Key))
 		}
-		prev_key = node.Key
+		prevKey = node.Key
 	}
 }

+ 2 - 2
file_test.go

@@ -8,8 +8,8 @@ import (
 )
 
 func updateStatusFile(
-	status interface{}, _ int, previous_time int, delta int) {
-	status.(map[int]int64)[previous_time] += int64(delta)
+	status interface{}, _ int, previousTime int, delta int) {
+	status.(map[int]int64)[previousTime] += int64(delta)
 }
 
 func fixtureFile() (*File, map[int]int64) {

+ 18 - 18
identity.go

@@ -18,9 +18,9 @@ type IdentityDetector struct {
 }
 
 const (
-	MISSING_AUTHOR   = (1 << 18) - 1
-	SELF_AUTHOR      = (1 << 18) - 2
-	UNMATCHED_AUTHOR = "<unmatched>"
+	AuthorMissing   = (1 << 18) - 1
+	AuthorSelf      = (1 << 18) - 2
+	AuthorUnmatched = "<unmatched>"
 
 	FactIdentityDetectorPeopleDict         = "IdentityDetector.PeopleDict"
 	FactIdentityDetectorReversedPeopleDict = "IdentityDetector.ReversedPeopleDict"
@@ -83,17 +83,17 @@ func (id *IdentityDetector) Configure(facts map[string]interface{}) {
 func (id *IdentityDetector) Initialize(repository *git.Repository) {
 }
 
-func (self *IdentityDetector) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
+func (id *IdentityDetector) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
 	commit := deps["commit"].(*object.Commit)
 	signature := commit.Author
-	id, exists := self.PeopleDict[strings.ToLower(signature.Email)]
+	authorID, exists := id.PeopleDict[strings.ToLower(signature.Email)]
 	if !exists {
-		id, exists = self.PeopleDict[strings.ToLower(signature.Name)]
+		authorID, exists = id.PeopleDict[strings.ToLower(signature.Name)]
 		if !exists {
-			id = MISSING_AUTHOR
+			authorID = AuthorMissing
 		}
 	}
-	return map[string]interface{}{DependencyAuthor: id}, nil
+	return map[string]interface{}{DependencyAuthor: authorID}, nil
 }
 
 func (id *IdentityDetector) LoadPeopleDict(path string) error {
@@ -104,19 +104,19 @@ func (id *IdentityDetector) LoadPeopleDict(path string) error {
 	defer file.Close()
 	scanner := bufio.NewScanner(file)
 	dict := make(map[string]int)
-	reverse_dict := []string{}
+	reverseDict := []string{}
 	size := 0
 	for scanner.Scan() {
 		ids := strings.Split(scanner.Text(), "|")
 		for _, id := range ids {
 			dict[strings.ToLower(id)] = size
 		}
-		reverse_dict = append(reverse_dict, ids[0])
-		size += 1
+		reverseDict = append(reverseDict, ids[0])
+		size++
 	}
-	reverse_dict = append(reverse_dict, UNMATCHED_AUTHOR)
+	reverseDict = append(reverseDict, AuthorUnmatched)
 	id.PeopleDict = dict
-	id.ReversedPeopleDict = reverse_dict
+	id.ReversedPeopleDict = reverseDict
 	return nil
 }
 
@@ -203,20 +203,20 @@ func (id *IdentityDetector) GeneratePeopleDict(commits []*object.Commit) {
 		dict[name] = size
 		emails[size] = append(emails[size], email)
 		names[size] = append(names[size], name)
-		size += 1
+		size++
 	}
-	reverse_dict := make([]string, size)
+	reverseDict := make([]string, size)
 	for _, val := range dict {
 		sort.Strings(names[val])
 		sort.Strings(emails[val])
-		reverse_dict[val] = strings.Join(names[val], "|") + "|" + strings.Join(emails[val], "|")
+		reverseDict[val] = strings.Join(names[val], "|") + "|" + strings.Join(emails[val], "|")
 	}
 	id.PeopleDict = dict
-	id.ReversedPeopleDict = reverse_dict
+	id.ReversedPeopleDict = reverseDict
 }
 
 // MergeReversedDicts joins two identity lists together, excluding duplicates, in-order.
-func (_ IdentityDetector) MergeReversedDicts(rd1, rd2 []string) (map[string][3]int, []string) {
+func (id IdentityDetector) MergeReversedDicts(rd1, rd2 []string) (map[string][3]int, []string) {
 	people := map[string][3]int{}
 	for i, pid := range rd1 {
 		ptrs := people[pid]

+ 3 - 3
identity_test.go

@@ -141,7 +141,7 @@ func TestIdentityDetectorConsume(t *testing.T) {
 	deps["commit"] = commit
 	res, err = fixtureIdentityDetector().Consume(deps)
 	assert.Nil(t, err)
-	assert.Equal(t, res[DependencyAuthor].(int), MISSING_AUTHOR)
+	assert.Equal(t, res[DependencyAuthor].(int), AuthorMissing)
 }
 
 func TestIdentityDetectorLoadPeopleDict(t *testing.T) {
@@ -160,7 +160,7 @@ func TestIdentityDetectorLoadPeopleDict(t *testing.T) {
 	assert.Equal(t, id.ReversedPeopleDict[0], "Linus Torvalds")
 	assert.Equal(t, id.ReversedPeopleDict[1], "Vadim Markovtsev")
 	assert.Equal(t, id.ReversedPeopleDict[2], "Máximo Cuadros")
-	assert.Equal(t, id.ReversedPeopleDict[3], UNMATCHED_AUTHOR)
+	assert.Equal(t, id.ReversedPeopleDict[3], AuthorUnmatched)
 }
 
 /*
@@ -229,7 +229,7 @@ func TestIdentityDetectorGeneratePeopleDict(t *testing.T) {
 	assert.Equal(t, id.ReversedPeopleDict[0], "vadim markovtsev|gmarkhor@gmail.com|vadim@sourced.tech")
 	assert.Equal(t, id.ReversedPeopleDict[1], "alexander bezzubov|bzz@apache.org")
 	assert.Equal(t, id.ReversedPeopleDict[2], "máximo cuadros|mcuadros@gmail.com")
-	assert.NotEqual(t, id.ReversedPeopleDict[len(id.ReversedPeopleDict)-1], UNMATCHED_AUTHOR)
+	assert.NotEqual(t, id.ReversedPeopleDict[len(id.ReversedPeopleDict)-1], AuthorUnmatched)
 }
 
 func TestIdentityDetectorLoadPeopleDictInvalidPath(t *testing.T) {

+ 1 - 2
pipeline_test.go

@@ -135,9 +135,8 @@ func (item *dependingTestPipelineItem) Consume(deps map[string]interface{}) (map
 	item.DependencySatisfied = exists
 	if !item.TestNilConsumeReturn {
 		return map[string]interface{}{"test2": item}, nil
-	} else {
-		return nil, nil
 	}
+	return nil, nil
 }
 
 func (item *dependingTestPipelineItem) Finalize() interface{} {

+ 1 - 2
registry.go

@@ -1,7 +1,6 @@
 package hercules
 
 import (
-	"errors"
 	"fmt"
 	"reflect"
 	"sort"
@@ -129,7 +128,7 @@ func (acf *arrayFeatureFlags) String() string {
 
 func (acf *arrayFeatureFlags) Set(value string) error {
 	if _, exists := acf.Choices[value]; !exists {
-		return errors.New(fmt.Sprintf("Feature \"%s\" is not registered.", value))
+		return fmt.Errorf("feature \"%s\" is not registered", value)
 	}
 	acf.Flags = append(acf.Flags, value)
 	return nil

+ 49 - 49
renames.go

@@ -23,7 +23,7 @@ type RenameAnalysis struct {
 }
 
 const (
-	RENAME_ANALYSIS_DEFAULT_THRESHOLD = 90
+	RenameAnalysisDefaultThreshold = 90
 
 	ConfigRenameAnalysisSimilarityThreshold = "RenameAnalysis.SimilarityThreshold"
 )
@@ -48,7 +48,7 @@ func (ra *RenameAnalysis) ListConfigurationOptions() []ConfigurationOption {
 		Description: "The threshold on the similarity index used to detect renames.",
 		Flag:        "M",
 		Type:        IntConfigurationOption,
-		Default:     RENAME_ANALYSIS_DEFAULT_THRESHOLD},
+		Default:     RenameAnalysisDefaultThreshold},
 	}
 	return options[:]
 }
@@ -62,8 +62,8 @@ func (ra *RenameAnalysis) Configure(facts map[string]interface{}) {
 func (ra *RenameAnalysis) Initialize(repository *git.Repository) {
 	if ra.SimilarityThreshold < 0 || ra.SimilarityThreshold > 100 {
 		fmt.Fprintf(os.Stderr, "Warning: adjusted the similarity threshold to %d\n",
-			RENAME_ANALYSIS_DEFAULT_THRESHOLD)
-		ra.SimilarityThreshold = RENAME_ANALYSIS_DEFAULT_THRESHOLD
+			RenameAnalysisDefaultThreshold)
+		ra.SimilarityThreshold = RenameAnalysisDefaultThreshold
 	}
 	ra.repository = repository
 }
@@ -72,7 +72,7 @@ func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]inter
 	changes := deps[DependencyTreeChanges].(object.Changes)
 	cache := deps[DependencyBlobCache].(map[plumbing.Hash]*object.Blob)
 
-	reduced_changes := make(object.Changes, 0, changes.Len())
+	reducedChanges := make(object.Changes, 0, changes.Len())
 
 	// Stage 1 - find renames by matching the hashes
 	// n log(n)
@@ -91,92 +91,92 @@ func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]inter
 		case merkletrie.Delete:
 			deleted = append(deleted, sortableChange{change, change.From.TreeEntry.Hash})
 		case merkletrie.Modify:
-			reduced_changes = append(reduced_changes, change)
+			reducedChanges = append(reducedChanges, change)
 		}
 	}
 	sort.Sort(deleted)
 	sort.Sort(added)
 	a := 0
 	d := 0
-	still_deleted := make(object.Changes, 0, deleted.Len())
-	still_added := make(object.Changes, 0, added.Len())
+	stillDeleted := make(object.Changes, 0, deleted.Len())
+	stillAdded := make(object.Changes, 0, added.Len())
 	for a < added.Len() && d < deleted.Len() {
 		if added[a].hash == deleted[d].hash {
-			reduced_changes = append(
-				reduced_changes,
+			reducedChanges = append(
+				reducedChanges,
 				&object.Change{From: deleted[d].change.From, To: added[a].change.To})
 			a++
 			d++
 		} else if added[a].Less(&deleted[d]) {
-			still_added = append(still_added, added[a].change)
+			stillAdded = append(stillAdded, added[a].change)
 			a++
 		} else {
-			still_deleted = append(still_deleted, deleted[d].change)
+			stillDeleted = append(stillDeleted, deleted[d].change)
 			d++
 		}
 	}
 	for ; a < added.Len(); a++ {
-		still_added = append(still_added, added[a].change)
+		stillAdded = append(stillAdded, added[a].change)
 	}
 	for ; d < deleted.Len(); d++ {
-		still_deleted = append(still_deleted, deleted[d].change)
+		stillDeleted = append(stillDeleted, deleted[d].change)
 	}
 
 	// Stage 2 - apply the similarity threshold
 	// n^2 but actually linear
 	// We sort the blobs by size and do the single linear scan.
-	added_blobs := make(sortableBlobs, 0, still_added.Len())
-	deleted_blobs := make(sortableBlobs, 0, still_deleted.Len())
-	for _, change := range still_added {
+	addedBlobs := make(sortableBlobs, 0, stillAdded.Len())
+	deletedBlobs := make(sortableBlobs, 0, stillDeleted.Len())
+	for _, change := range stillAdded {
 		blob := cache[change.To.TreeEntry.Hash]
-		added_blobs = append(
-			added_blobs, sortableBlob{change: change, size: blob.Size})
+		addedBlobs = append(
+			addedBlobs, sortableBlob{change: change, size: blob.Size})
 	}
-	for _, change := range still_deleted {
+	for _, change := range stillDeleted {
 		blob := cache[change.From.TreeEntry.Hash]
-		deleted_blobs = append(
-			deleted_blobs, sortableBlob{change: change, size: blob.Size})
+		deletedBlobs = append(
+			deletedBlobs, sortableBlob{change: change, size: blob.Size})
 	}
-	sort.Sort(added_blobs)
-	sort.Sort(deleted_blobs)
-	d_start := 0
-	for a = 0; a < added_blobs.Len(); a++ {
-		my_blob := cache[added_blobs[a].change.To.TreeEntry.Hash]
-		my_size := added_blobs[a].size
-		for d = d_start; d < deleted_blobs.Len() && !ra.sizesAreClose(my_size, deleted_blobs[d].size); d++ {
+	sort.Sort(addedBlobs)
+	sort.Sort(deletedBlobs)
+	dStart := 0
+	for a = 0; a < addedBlobs.Len(); a++ {
+		myBlob := cache[addedBlobs[a].change.To.TreeEntry.Hash]
+		mySize := addedBlobs[a].size
+		for d = dStart; d < deletedBlobs.Len() && !ra.sizesAreClose(mySize, deletedBlobs[d].size); d++ {
 		}
-		d_start = d
-		found_match := false
-		for d = d_start; d < deleted_blobs.Len() && ra.sizesAreClose(my_size, deleted_blobs[d].size); d++ {
+		dStart = d
+		foundMatch := false
+		for d = dStart; d < deletedBlobs.Len() && ra.sizesAreClose(mySize, deletedBlobs[d].size); d++ {
 			blobsAreClose, err := ra.blobsAreClose(
-				my_blob, cache[deleted_blobs[d].change.From.TreeEntry.Hash])
+				myBlob, cache[deletedBlobs[d].change.From.TreeEntry.Hash])
 			if err != nil {
 				return nil, err
 			}
 			if blobsAreClose {
-				found_match = true
-				reduced_changes = append(
-					reduced_changes,
-					&object.Change{From: deleted_blobs[d].change.From,
-						To: added_blobs[a].change.To})
+				foundMatch = true
+				reducedChanges = append(
+					reducedChanges,
+					&object.Change{From: deletedBlobs[d].change.From,
+						To:                addedBlobs[a].change.To})
 				break
 			}
 		}
-		if found_match {
-			added_blobs = append(added_blobs[:a], added_blobs[a+1:]...)
+		if foundMatch {
+			addedBlobs = append(addedBlobs[:a], addedBlobs[a+1:]...)
 			a--
-			deleted_blobs = append(deleted_blobs[:d], deleted_blobs[d+1:]...)
+			deletedBlobs = append(deletedBlobs[:d], deletedBlobs[d+1:]...)
 		}
 	}
 
 	// Stage 3 - we give up, everything left are independent additions and deletions
-	for _, blob := range added_blobs {
-		reduced_changes = append(reduced_changes, blob.change)
+	for _, blob := range addedBlobs {
+		reducedChanges = append(reducedChanges, blob.change)
 	}
-	for _, blob := range deleted_blobs {
-		reduced_changes = append(reduced_changes, blob.change)
+	for _, blob := range deletedBlobs {
+		reducedChanges = append(reducedChanges, blob.change)
 	}
-	return map[string]interface{}{DependencyTreeChanges: reduced_changes}, nil
+	return map[string]interface{}{DependencyTreeChanges: reducedChanges}, nil
 }
 
 func (ra *RenameAnalysis) sizesAreClose(size1 int64, size2 int64) bool {
@@ -186,16 +186,16 @@ func (ra *RenameAnalysis) sizesAreClose(size1 int64, size2 int64) bool {
 
 func (ra *RenameAnalysis) blobsAreClose(
 	blob1 *object.Blob, blob2 *object.Blob) (bool, error) {
-	str_from, err := BlobToString(blob1)
+	strFrom, err := BlobToString(blob1)
 	if err != nil {
 		return false, err
 	}
-	str_to, err := BlobToString(blob2)
+	strTo, err := BlobToString(blob2)
 	if err != nil {
 		return false, err
 	}
 	dmp := diffmatchpatch.New()
-	src, dst, _ := dmp.DiffLinesToRunes(str_from, str_to)
+	src, dst, _ := dmp.DiffLinesToRunes(strFrom, strTo)
 	diffs := dmp.DiffMainRunes(src, dst, false)
 	common := 0
 	for _, edit := range diffs {

+ 2 - 2
renames_test.go

@@ -51,10 +51,10 @@ func TestRenameAnalysisRegistration(t *testing.T) {
 func TestRenameAnalysisInitializeInvalidThreshold(t *testing.T) {
 	ra := RenameAnalysis{SimilarityThreshold: -10}
 	ra.Initialize(testRepository)
-	assert.Equal(t, ra.SimilarityThreshold, RENAME_ANALYSIS_DEFAULT_THRESHOLD)
+	assert.Equal(t, ra.SimilarityThreshold, RenameAnalysisDefaultThreshold)
 	ra = RenameAnalysis{SimilarityThreshold: 110}
 	ra.Initialize(testRepository)
-	assert.Equal(t, ra.SimilarityThreshold, RENAME_ANALYSIS_DEFAULT_THRESHOLD)
+	assert.Equal(t, ra.SimilarityThreshold, RenameAnalysisDefaultThreshold)
 	ra = RenameAnalysis{SimilarityThreshold: 0}
 	ra.Initialize(testRepository)
 	ra = RenameAnalysis{SimilarityThreshold: 100}

+ 1 - 1
shotness.go

@@ -65,7 +65,7 @@ func (shotness *ShotnessAnalysis) Provides() []string {
 	return []string{}
 }
 
-func (ref *ShotnessAnalysis) Features() []string {
+func (shotness *ShotnessAnalysis) Features() []string {
 	arr := [...]string{FeatureUast}
 	return arr[:]
 }

+ 3 - 3
tree_diff.go

@@ -53,10 +53,10 @@ func (treediff *TreeDiff) Consume(deps map[string]interface{}) (map[string]inter
 	} else {
 		diff = []*object.Change{}
 		err = func() error {
-			file_iter := tree.Files()
-			defer file_iter.Close()
+			fileIter := tree.Files()
+			defer fileIter.Close()
 			for {
-				file, err := file_iter.Next()
+				file, err := fileIter.Next()
 				if err != nil {
 					if err == io.EOF {
 						break

+ 3 - 4
uast.go

@@ -41,7 +41,7 @@ type UASTExtractor struct {
 }
 
 const (
-	UAST_EXTRACTION_SKIPPED = -(1 << 31)
+	uastExtractionSkipped = -(1 << 31)
 
 	ConfigUASTEndpoint     = "ConfigUASTEndpoint"
 	ConfigUASTTimeout      = "ConfigUASTTimeout"
@@ -211,7 +211,7 @@ func (exr *UASTExtractor) Consume(deps map[string]interface{}) (map[string]inter
 			}
 			lang := enry.GetLanguage(change.To.Name, buf.Bytes())
 			if _, exists := exr.Languages[lang]; !exists {
-				exr.ProcessedFiles[change.To.Name] = UAST_EXTRACTION_SKIPPED
+				exr.ProcessedFiles[change.To.Name] = uastExtractionSkipped
 				return
 			}
 			exr.ProcessedFiles[change.To.Name]++
@@ -248,9 +248,8 @@ func (exr *UASTExtractor) Consume(deps map[string]interface{}) (map[string]inter
 		joined := strings.Join(msgs, "\n")
 		if exr.FailOnErrors {
 			return nil, errors.New(joined)
-		} else {
-			fmt.Fprintln(os.Stderr, joined)
 		}
+		fmt.Fprintln(os.Stderr, joined)
 	}
 	return map[string]interface{}{DependencyUasts: uasts}, nil
 }

+ 3 - 3
version.go

@@ -6,13 +6,13 @@ import (
 	"strings"
 )
 
-var GIT_HASH = "<unknown>"
+var BinaryGitHash = "<unknown>"
 
-var VERSION = 0
+var BinaryVersion = 0
 
 type versionProbe struct{}
 
 func init() {
 	parts := strings.Split(reflect.TypeOf(versionProbe{}).PkgPath(), ".")
-	VERSION, _ = strconv.Atoi(parts[len(parts)-1][1:])
+	BinaryVersion, _ = strconv.Atoi(parts[len(parts)-1][1:])
 }