Browse Source

Run gofmt and require it in CI

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 years ago
parent
commit
9498e343e5

+ 2 - 1
.travis.yml

@@ -40,7 +40,7 @@ env:
 before_install:
   - wget -O protoc.zip https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip
   - unzip -d ~/.local protoc.zip && rm protoc.zip
-  - go get -v github.com/golang/lint/golint
+  - go get -v golang.org/x/lint/golint
   - rm -rf $GOPATH/src/gopkg.in/src-d/go-git.v4
   - git clone --depth 1 --single-branch --branch $GOGIT_TAG https://github.com/src-d/go-git $GOPATH/src/gopkg.in/src-d/go-git.v4
   - (wget https://bootstrap.pypa.io/get-pip.py || wget https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py) && python3 get-pip.py --user && rm get-pip.py
@@ -59,6 +59,7 @@ install:
   - make
 script:
   - set -e
+  - test -z "$(gofmt -s -l .)"
   - go vet -tags tensorflow ./...
   - golint -set_exit_status ./...
   - flake8

+ 9 - 9
cmd/hercules/root.go

@@ -16,8 +16,9 @@ import (
 	"strings"
 	_ "unsafe" // for go:linkname
 
-	"github.com/gogo/protobuf/proto"
 	"github.com/Masterminds/sprig"
+	"github.com/gogo/protobuf/proto"
+	"github.com/mitchellh/go-homedir"
 	"github.com/spf13/cobra"
 	"github.com/spf13/pflag"
 	"golang.org/x/crypto/ssh/terminal"
@@ -27,13 +28,12 @@ import (
 	"gopkg.in/src-d/go-billy.v4/osfs"
 	"gopkg.in/src-d/go-git.v4"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
+	"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
 	"gopkg.in/src-d/go-git.v4/storage"
 	"gopkg.in/src-d/go-git.v4/storage/filesystem"
 	"gopkg.in/src-d/go-git.v4/storage/memory"
 	"gopkg.in/src-d/hercules.v5"
 	"gopkg.in/src-d/hercules.v5/internal/pb"
-	"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
-	"github.com/mitchellh/go-homedir"
 )
 
 // oneLineWriter splits the output data by lines and outputs one on top of another using '\r'.
@@ -56,9 +56,9 @@ func (writer oneLineWriter) Write(p []byte) (n int, err error) {
 }
 
 func loadSSHIdentity(sshIdentity string) (*ssh.PublicKeys, error) {
-	actual, err := homedir.Expand(sshIdentity);
+	actual, err := homedir.Expand(sshIdentity)
 	if err != nil {
-		return nil, err;
+		return nil, err
 	}
 	return ssh.NewPublicKeysFromFile("git", actual, "")
 }
@@ -88,7 +88,7 @@ func loadRepository(uri string, cachePath string, disableStatus bool, sshIdentit
 		}
 
 		if sshIdentity != "" {
-			auth, err := loadSSHIdentity(sshIdentity);
+			auth, err := loadSSHIdentity(sshIdentity)
 			if err != nil {
 				log.Printf("Failed loading SSH Identity %s\n", err)
 			}
@@ -209,7 +209,7 @@ targets can be added using the --plugin system.`,
 					bar.SetMaxWidth(80)
 					bar.Start()
 				}
-				if commit == length - 1 {
+				if commit == length-1 {
 					bar.Finish()
 					fmt.Fprint(os.Stderr, "\r"+strings.Repeat(" ", 80)+"\rfinalizing...")
 				} else {
@@ -430,11 +430,11 @@ func init() {
 	rootCmd.MarkFlagFilename("plugin")
 	rootFlags := rootCmd.Flags()
 	rootFlags.String("commits", "", "Path to the text file with the "+
-		"commit history to follow instead of the default `git log`. " +
+		"commit history to follow instead of the default `git log`. "+
 		"The format is the list of hashes, each hash on a "+
 		"separate line. The first hash is the root.")
 	rootCmd.MarkFlagFilename("commits")
-	rootFlags.Bool("first-parent", false, "Follow only the first parent in the commit history - " +
+	rootFlags.Bool("first-parent", false, "Follow only the first parent in the commit history - "+
 		"\"git log --first-parent\".")
 	rootFlags.Bool("pb", false, "The output format will be Protocol Buffers instead of YAML.")
 	rootFlags.Bool("quiet", !terminal.IsTerminal(int(os.Stdin.Fd())),

+ 1 - 2
cmd/hercules/root_test.go

@@ -10,8 +10,8 @@ import (
 
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/src-d/go-billy.v4/osfs"
-	"gopkg.in/src-d/go-git.v4/storage/filesystem"
 	"gopkg.in/src-d/go-git.v4"
+	"gopkg.in/src-d/go-git.v4/storage/filesystem"
 )
 
 func TestLoadRepository(t *testing.T) {
@@ -37,7 +37,6 @@ func TestLoadRepository(t *testing.T) {
 		assert.FailNow(t, "filesystem.NewStorage")
 	}
 
-
 	repo = loadRepository(tempdir, "", true, "")
 	assert.NotNil(t, repo)
 	log.Println("TestLoadRepository: 2/3")

+ 2 - 2
core.go

@@ -87,12 +87,12 @@ func LoadCommitsFromFile(path string, repository *git.Repository) ([]*object.Com
 
 // ForkSamePipelineItem clones items by referencing the same origin.
 func ForkSamePipelineItem(origin PipelineItem, n int) []PipelineItem {
-	return core.ForkSamePipelineItem(origin ,n)
+	return core.ForkSamePipelineItem(origin, n)
 }
 
 // ForkCopyPipelineItem clones items by copying them by value from the origin.
 func ForkCopyPipelineItem(origin PipelineItem, n int) []PipelineItem {
-	return core.ForkCopyPipelineItem(origin ,n)
+	return core.ForkCopyPipelineItem(origin, n)
 }
 
 // PipelineItemRegistry contains all the known PipelineItem-s.

+ 10 - 8
internal/burndown/file.go

@@ -29,20 +29,22 @@ type File struct {
 
 // TreeEnd denotes the value of the last leaf in the tree.
 const TreeEnd = -1
+
 // TreeMaxBinPower is the binary power value which corresponds to the maximum day which
 // can be stored in the tree.
 const TreeMaxBinPower = 14
+
 // TreeMergeMark is the special day which disables the status updates and is used in File.Merge().
 const TreeMergeMark = (1 << TreeMaxBinPower) - 1
 
 func (file *File) updateTime(currentTime, previousTime, delta int) {
-	if previousTime & TreeMergeMark == TreeMergeMark {
+	if previousTime&TreeMergeMark == TreeMergeMark {
 		if currentTime == previousTime {
 			return
 		}
 		panic("previousTime cannot be TreeMergeMark")
 	}
-	if currentTime & TreeMergeMark == TreeMergeMark {
+	if currentTime&TreeMergeMark == TreeMergeMark {
 		// merge mode - `delta` is negative and we have already applied it in a branch
 		return
 	}
@@ -193,7 +195,7 @@ func (file *File) Update(time int, pos int, insLength int, delLength int) {
 	var previous *rbtree.Item
 	if insLength > 0 && (origin.Value != time || origin.Key == pos) {
 		// insert our new interval
-		if iter.Item().Value == time && iter.Item().Key - delLength == pos {
+		if iter.Item().Value == time && iter.Item().Key-delLength == pos {
 			prev := iter.Prev()
 			if prev.Item().Value != time {
 				iter.Item().Key = pos
@@ -238,7 +240,7 @@ func (file *File) Update(time int, pos int, insLength int, delLength int) {
 }
 
 // Merge combines several prepared File-s together.
-func (file *File) Merge(day int, others... *File) {
+func (file *File) Merge(day int, others ...*File) {
 	myself := file.flatten()
 	for _, other := range others {
 		if other == nil {
@@ -251,10 +253,10 @@ func (file *File) Merge(day int, others... *File) {
 		}
 		for i, l := range myself {
 			ol := lines[i]
-			if ol & TreeMergeMark == TreeMergeMark {
+			if ol&TreeMergeMark == TreeMergeMark {
 				continue
 			}
-			if l & TreeMergeMark == TreeMergeMark || l & TreeMergeMark > ol & TreeMergeMark {
+			if l&TreeMergeMark == TreeMergeMark || l&TreeMergeMark > ol&TreeMergeMark {
 				// the line is merged in myself and exists in other
 				// OR the same line introduced in different branches
 				// consider the oldest version as the ground truth in that case
@@ -264,7 +266,7 @@ func (file *File) Merge(day int, others... *File) {
 		}
 	}
 	for i, l := range myself {
-		if l & TreeMergeMark == TreeMergeMark {
+		if l&TreeMergeMark == TreeMergeMark {
 			// original merge conflict resolution
 			myself[i] = day
 			file.updateTime(day, day, 1)
@@ -273,7 +275,7 @@ func (file *File) Merge(day int, others... *File) {
 	// now we need to reconstruct the tree from the discrete values
 	tree := &rbtree.RBTree{}
 	for i, v := range myself {
-		if i == 0 || v != myself[i - 1] {
+		if i == 0 || v != myself[i-1] {
 			tree.Insert(rbtree.Item{Key: i, Value: v})
 		}
 	}

+ 1 - 2
internal/burndown/file_test.go

@@ -600,7 +600,6 @@ func TestFileMergeMark(t *testing.T) {
 	assert.NotContains(t, status, TreeMergeMark)
 }
 
-
 func TestFileMerge(t *testing.T) {
 	file1, status := fixtureFile()
 	// 0 0 | 100 -1                             [0]: 100
@@ -685,4 +684,4 @@ func TestBug6File(t *testing.T) {
 	// 0 7 | 112 10 | 153 7 | 154 -1
 	dump = file.Dump()
 	assert.Equal(t, "0 7\n112 10\n153 7\n154 -1\n", dump)
-}
+}

+ 12 - 12
internal/core/forks.go

@@ -5,8 +5,8 @@ import (
 	"reflect"
 	"sort"
 
-	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/go-git.v4/plumbing"
+	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/hercules.v5/internal/toposort"
 )
 
@@ -84,7 +84,7 @@ const (
 type runAction struct {
 	Action int
 	Commit *object.Commit
-	Items []int
+	Items  []int
 }
 
 type orderer = func(reverse, direction bool) []string
@@ -104,7 +104,7 @@ func cloneItems(origin []PipelineItem, n int) [][]PipelineItem {
 }
 
 func mergeItems(branches [][]PipelineItem) {
-	buffer := make([]PipelineItem, len(branches) - 1)
+	buffer := make([]PipelineItem, len(branches)-1)
 	for i, item := range branches[0] {
 		for j := 0; j < len(branches)-1; j++ {
 			buffer[j] = branches[j+1][i]
@@ -350,14 +350,14 @@ func mergeDag(
 // collapseFastForwards removes the fast forward merges.
 func collapseFastForwards(
 	orderNodes orderer, hashes map[string]*object.Commit,
-	mergedDag, dag, mergedSeq map[plumbing.Hash][]*object.Commit)  {
+	mergedDag, dag, mergedSeq map[plumbing.Hash][]*object.Commit) {
 
 	parents := buildParents(mergedDag)
 	processed := map[plumbing.Hash]bool{}
 	for _, strkey := range orderNodes(false, true) {
 		key := hashes[strkey].Hash
 		processed[key] = true
-		repeat:
+	repeat:
 		vals, exists := mergedDag[key]
 		if !exists {
 			continue
@@ -482,7 +482,7 @@ func generatePlan(
 			plan = append(plan, runAction{
 				Action: runActionEmerge,
 				Commit: commit,
-				Items: []int{counter},
+				Items:  []int{counter},
 			})
 			counter++
 		}
@@ -502,7 +502,7 @@ func generatePlan(
 			plan = append(plan, runAction{
 				Action: runActionCommit,
 				Commit: c,
-				Items: []int{branch},
+				Items:  []int{branch},
 			})
 		}
 		appendMergeIfNeeded := func() {
@@ -535,7 +535,7 @@ func generatePlan(
 				}
 			}
 			// there should be no duplicates in items
-			if minBranch < 1 << 31 {
+			if minBranch < 1<<31 {
 				branch = minBranch
 				branches[commit.Hash] = minBranch
 			} else if !branchExists() {
@@ -544,7 +544,7 @@ func generatePlan(
 			plan = append(plan, runAction{
 				Action: runActionMerge,
 				Commit: nil,
-				Items: items,
+				Items:  items,
 			})
 		}
 		var head plumbing.Hash
@@ -615,9 +615,9 @@ func collectGarbage(plan []runAction) []runAction {
 		}
 	}
 	var garbageCollectedPlan []runAction
-	lastMentionedArr := make([][2]int, 0, len(lastMentioned) + 1)
+	lastMentionedArr := make([][2]int, 0, len(lastMentioned)+1)
 	for key, val := range lastMentioned {
-		if val != len(plan) - 1 {
+		if val != len(plan)-1 {
 			lastMentionedArr = append(lastMentionedArr, [2]int{val, key})
 		}
 	}
@@ -628,7 +628,7 @@ func collectGarbage(plan []runAction) []runAction {
 	sort.Slice(lastMentionedArr, func(i, j int) bool {
 		return lastMentionedArr[i][0] < lastMentionedArr[j][0]
 	})
-	lastMentionedArr = append(lastMentionedArr, [2]int{len(plan)-1, -1})
+	lastMentionedArr = append(lastMentionedArr, [2]int{len(plan) - 1, -1})
 	prevpi := -1
 	for _, pair := range lastMentionedArr {
 		for pi := prevpi + 1; pi <= pair[0]; pi++ {

+ 3 - 3
internal/core/forks_test.go

@@ -1,14 +1,14 @@
 package core
 
 import (
-	"testing"
-	"gopkg.in/src-d/go-git.v4"
 	"github.com/stretchr/testify/assert"
+	"gopkg.in/src-d/go-git.v4"
+	"testing"
 )
 
 type testForkPipelineItem struct {
 	NoopMerger
-	Mutable map[int]bool
+	Mutable   map[int]bool
 	Immutable string
 }
 

+ 7 - 8
internal/core/pipeline.go

@@ -623,20 +623,19 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 
 	commitIndex := 0
 	for index, step := range plan {
-		onProgress(index + 1, progressSteps)
+		onProgress(index+1, progressSteps)
 		firstItem := step.Items[0]
 		switch step.Action {
 		case runActionCommit:
 			state := map[string]interface{}{
 				DependencyCommit: step.Commit,
-				DependencyIndex: commitIndex,
-				DependencyIsMerge:
-					(index > 0 &&
+				DependencyIndex:  commitIndex,
+				DependencyIsMerge: (index > 0 &&
 					plan[index-1].Action == runActionCommit &&
 					plan[index-1].Commit.Hash == step.Commit.Hash) ||
 					(index < (len(plan)-1) &&
-					plan[index+1].Action == runActionCommit &&
-					plan[index+1].Commit.Hash == step.Commit.Hash),
+						plan[index+1].Action == runActionCommit &&
+						plan[index+1].Commit.Hash == step.Commit.Hash),
 			}
 			for _, item := range branches[firstItem] {
 				startTime := time.Now()
@@ -644,7 +643,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 				runTimePerItem[item.Name()] += time.Now().Sub(startTime).Seconds()
 				if err != nil {
 					log.Printf("%s failed on commit #%d (%d) %s\n",
-						item.Name(), commitIndex + 1, index + 1, step.Commit.Hash.String())
+						item.Name(), commitIndex+1, index+1, step.Commit.Hash.String())
 					return nil, err
 				}
 				for _, key := range item.Provides() {
@@ -680,7 +679,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 			delete(branches, firstItem)
 		}
 	}
-	onProgress(len(plan) + 1, progressSteps)
+	onProgress(len(plan)+1, progressSteps)
 	result := map[LeafPipelineItem]interface{}{}
 	for index, item := range getMasterBranch(branches) {
 		if casted, ok := item.(LeafPipelineItem); ok {

+ 6 - 6
internal/core/pipeline_test.go

@@ -255,7 +255,7 @@ func TestPipelineRunBranches(t *testing.T) {
 	pipeline.Initialize(map[string]interface{}{})
 	assert.True(t, item.Initialized)
 	commits := make([]*object.Commit, 5)
-	hashes := []string {
+	hashes := []string{
 		"6db8065cdb9bb0758f36a7e75fc72ab95f9e8145",
 		"f30daba81ff2bf0b3ba02a1e1441e74f8a4f6fee",
 		"8a03b5620b1caa72ec9cb847ea88332621e2950a",
@@ -418,7 +418,7 @@ func TestPipelineError(t *testing.T) {
 func TestCommonAnalysisResultMerge(t *testing.T) {
 	c1 := CommonAnalysisResult{
 		BeginTime: 1513620635, EndTime: 1513720635, CommitsNumber: 1, RunTime: 100,
-	    RunTimePerItem: map[string]float64{"one": 1, "two": 2}}
+		RunTimePerItem: map[string]float64{"one": 1, "two": 2}}
 	assert.Equal(t, c1.BeginTimeAsTime().Unix(), int64(1513620635))
 	assert.Equal(t, c1.EndTimeAsTime().Unix(), int64(1513720635))
 	c2 := CommonAnalysisResult{
@@ -513,7 +513,7 @@ func TestPrepareRunPlanSmall(t *testing.T) {
 		}
 	}*/
 	// fork, merge and one artificial commit per branch
-	assert.Len(t, plan, len(commits) + 1)
+	assert.Len(t, plan, len(commits)+1)
 	assert.Equal(t, runActionEmerge, plan[0].Action)
 	assert.Equal(t, "cce947b98a050c6d356bc6ba95030254914027b1", plan[0].Commit.Hash.String())
 	assert.Equal(t, rootBranchIndex, plan[0].Items[0])
@@ -593,12 +593,12 @@ func TestMergeDag(t *testing.T) {
 }
 
 func TestPrepareRunPlanBig(t *testing.T) {
-	cases := [][7]int {
+	cases := [][7]int{
 		{2017, 8, 9, 0, 0, 0, 0},
 		{2017, 8, 10, 0, 0, 0, 0},
 		{2017, 8, 24, 1, 1, 1, 1},
-		{2017, 9, 19, 1-2, 1, 1, 1},
-		{2017, 9, 23, 1-2, 1, 1, 1},
+		{2017, 9, 19, 1 - 2, 1, 1, 1},
+		{2017, 9, 23, 1 - 2, 1, 1, 1},
 		{2017, 12, 8, 1, 1, 1, 1},
 		{2017, 12, 9, 1, 1, 1, 1},
 		{2017, 12, 10, 1, 1, 1, 1},

+ 2 - 2
internal/plumbing/blob_cache.go

@@ -258,8 +258,8 @@ func (blobCache *BlobCache) Fork(n int) []core.PipelineItem {
 		}
 		caches[i] = &BlobCache{
 			FailOnMissingSubmodules: blobCache.FailOnMissingSubmodules,
-			repository: blobCache.repository,
-			cache: cache,
+			repository:              blobCache.repository,
+			cache:                   cache,
 		}
 	}
 	return caches

+ 2 - 2
internal/plumbing/diff.go

@@ -1,20 +1,20 @@
 package plumbing
 
 import (
-	"strings"
 	"github.com/sergi/go-diff/diffmatchpatch"
 	"gopkg.in/src-d/go-git.v4"
 	"gopkg.in/src-d/go-git.v4/plumbing"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/go-git.v4/utils/merkletrie"
 	"gopkg.in/src-d/hercules.v5/internal/core"
+	"strings"
 )
 
 // FileDiff calculates the difference of files which were modified.
 // It is a PipelineItem.
 type FileDiff struct {
 	core.NoopMerger
-	CleanupDisabled bool
+	CleanupDisabled  bool
 	WhitespaceIgnore bool
 }
 

+ 1 - 1
internal/plumbing/identity/identity.go

@@ -9,7 +9,7 @@ import (
 	"gopkg.in/src-d/go-git.v4"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/hercules.v5/internal/core"
-	)
+)
 
 // Detector determines the author of a commit. Same person can commit under different
 // signatures, and we apply some heuristics to merge those together.

+ 1 - 1
internal/plumbing/renames.go

@@ -263,7 +263,7 @@ func (ra *RenameAnalysis) blobsAreClose(
 		}
 	}
 	size := internal.Max(1, internal.Max(utf8.RuneCountInString(src), utf8.RuneCountInString(dst)))
-	similarity := (common*100) / size
+	similarity := (common * 100) / size
 	return similarity >= ra.SimilarityThreshold, nil
 }
 

+ 1 - 1
internal/test/repository.go

@@ -8,8 +8,8 @@ import (
 	"gopkg.in/src-d/go-git.v4/plumbing"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/go-git.v4/storage/memory"
-	"path"
 	"io/ioutil"
+	"path"
 )
 
 // Repository is a boilerplate sample repository (Hercules itself).

+ 5 - 5
leaves/burndown.go

@@ -316,7 +316,7 @@ func (analyser *BurndownAnalysis) Fork(n int) []core.PipelineItem {
 
 // Merge combines several items together. We apply the special file merging logic here.
 func (analyser *BurndownAnalysis) Merge(branches []core.PipelineItem) {
-	all := make([]*BurndownAnalysis, len(branches) + 1)
+	all := make([]*BurndownAnalysis, len(branches)+1)
 	all[0] = analyser
 	for i, branch := range branches {
 		all[i+1] = branch.(*BurndownAnalysis)
@@ -927,7 +927,7 @@ func (analyser *BurndownAnalysis) updateGlobal(currentTime, previousTime, delta
 // updateFile is bound to the specific `history` in the closure.
 func (analyser *BurndownAnalysis) updateFile(
 	history sparseHistory, currentTime, previousTime, delta int) {
-		
+
 	_, currentDay := analyser.unpackPersonWithDay(currentTime)
 	_, previousDay := analyser.unpackPersonWithDay(previousTime)
 
@@ -1237,8 +1237,8 @@ func (analyser *BurndownAnalysis) groupSparseHistory(
 	// [y][x]
 	// y - sampling
 	// x - granularity
-	samples := lastDay / analyser.Sampling + 1
-	bands := lastDay / analyser.Granularity + 1
+	samples := lastDay/analyser.Sampling + 1
+	bands := lastDay/analyser.Granularity + 1
 	result := make(DenseHistory, samples)
 	for i := 0; i < bands; i++ {
 		result[i] = make([]int64, bands)
@@ -1255,7 +1255,7 @@ func (analyser *BurndownAnalysis) groupSparseHistory(
 		}
 		sample := result[si]
 		for bday, value := range history[day] {
-			sample[bday / analyser.Granularity] += value
+			sample[bday/analyser.Granularity] += value
 		}
 	}
 	return result, lastDay

+ 2 - 2
leaves/couples.go

@@ -3,7 +3,7 @@ package leaves
 import (
 	"fmt"
 	"io"
-		"sort"
+	"sort"
 
 	"github.com/gogo/protobuf/proto"
 	"gopkg.in/src-d/go-git.v4"
@@ -53,7 +53,7 @@ type CouplesResult struct {
 
 type rename struct {
 	FromName string
-	ToName string
+	ToName   string
 }
 
 // Name of this PipelineItem. Uniquely identifies the type, used for mapping keys, etc.

+ 28 - 28
leaves/couples_test.go

@@ -9,14 +9,14 @@ import (
 
 	"github.com/gogo/protobuf/proto"
 	"github.com/stretchr/testify/assert"
-	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	gitplumbing "gopkg.in/src-d/go-git.v4/plumbing"
+	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/hercules.v5/internal/core"
 	"gopkg.in/src-d/hercules.v5/internal/pb"
 	"gopkg.in/src-d/hercules.v5/internal/plumbing"
 	"gopkg.in/src-d/hercules.v5/internal/plumbing/identity"
 	"gopkg.in/src-d/hercules.v5/internal/test"
-	)
+)
 
 func fixtureCouples() *CouplesAnalysis {
 	c := CouplesAnalysis{PeopleNumber: 3}
@@ -118,34 +118,34 @@ func TestCouplesConsumeFinalize(t *testing.T) {
 	assert.Equal(t, c.people[2]["file_test.go"], 1)
 	assert.Equal(t, len(c.files["README.md"]), 3)
 	assert.Equal(t, c.files["README.md"], map[string]int{
-		"README.md": 2,
-		"analyser.go": 2,
+		"README.md":    2,
+		"analyser.go":  2,
 		"file_test.go": 1,
 	})
 	assert.Equal(t, c.files["LICENSE2"], map[string]int{
-		"LICENSE2": 1,
-		"file2.go": 1,
+		"LICENSE2":   1,
+		"file2.go":   1,
 		"rbtree2.go": 1,
 	})
 	assert.Equal(t, c.files["file2.go"], map[string]int{
-		"LICENSE2": 1,
-		"file2.go": 1,
+		"LICENSE2":   1,
+		"file2.go":   1,
 		"rbtree2.go": 1,
 	})
 	assert.Equal(t, c.files["rbtree2.go"], map[string]int{
-		"LICENSE2": 1,
-		"file2.go": 1,
+		"LICENSE2":   1,
+		"file2.go":   1,
 		"rbtree2.go": 1,
 	})
 	assert.Equal(t, c.files["analyser.go"], map[string]int{
-		"analyser.go": 2,
-		"README.md": 2,
+		"analyser.go":  2,
+		"README.md":    2,
 		"file_test.go": 1,
 	})
 	assert.Equal(t, c.files["file_test.go"], map[string]int{
 		"file_test.go": 2,
-		"README.md": 1,
-		"analyser.go": 1,
+		"README.md":    1,
+		"analyser.go":  1,
 	})
 	assert.Equal(t, c.peopleCommits[0], 2)
 	assert.Equal(t, c.peopleCommits[1], 1)
@@ -201,17 +201,17 @@ func TestCouplesFork(t *testing.T) {
 
 func TestCouplesSerialize(t *testing.T) {
 	c := fixtureCouples()
-	result := CouplesResult {
+	result := CouplesResult{
 		PeopleMatrix: []map[int]int64{
-			{0:7, 1:3, 2:1}, {0:3, 1:3}, {0:1, 2:1}, {},
+			{0: 7, 1: 3, 2: 1}, {0: 3, 1: 3}, {0: 1, 2: 1}, {},
 		},
 		PeopleFiles: [][]int{
 			{0, 1, 2}, {1, 2}, {0}, {},
 		},
 		FilesMatrix: []map[int]int64{
-			{1:1, 2:1, 0:3}, {1:2, 2:2, 0:1}, {2:2, 0:1, 1:2},
+			{1: 1, 2: 1, 0: 3}, {1: 2, 2: 2, 0: 1}, {2: 2, 0: 1, 1: 2},
 		},
-		Files: []string{"five", "one", "three"},
+		Files:              []string{"five", "one", "three"},
 		reversedPeopleDict: []string{"p1", "p2", "p3"},
 	}
 	buffer := &bytes.Buffer{}
@@ -372,26 +372,26 @@ func TestCouplesCurrentFiles(t *testing.T) {
 func TestCouplesPropagateRenames(t *testing.T) {
 	c := fixtureCouples()
 	c.files["one"] = map[string]int{
-		"one": 1,
-		"two": 2,
+		"one":   1,
+		"two":   2,
 		"three": 3,
 	}
 	c.files["two"] = map[string]int{
-		"one": 2,
-		"two": 10,
+		"one":   2,
+		"two":   10,
 		"three": 1,
-		"four": 7,
+		"four":  7,
 	}
 	c.files["three"] = map[string]int{
-		"one": 3,
-		"two": 1,
+		"one":   3,
+		"two":   1,
 		"three": 3,
-		"four": 2,
+		"four":  2,
 	}
 	c.files["four"] = map[string]int{
-		"two": 7,
+		"two":   7,
 		"three": 3,
-		"four": 1,
+		"four":  1,
 	}
 	c.PeopleNumber = 1
 	c.people = make([]map[string]int, 1)