Browse Source

Run gofmt

The check was broken in CI; fixed now.

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

+ 2 - 2
internal/burndown/file.go

@@ -257,11 +257,11 @@ func (file *File) Update(time int, pos int, insLength int, delLength int) {
 	if delta != 0 {
 		for iter = iter.Next(); !iter.Limit(); iter = iter.Next() {
 			// we do not need to re-balance the tree
-			iter.Item().Key = uint32(int(iter.Item().Key)+delta)
+			iter.Item().Key = uint32(int(iter.Item().Key) + delta)
 		}
 		// have to adjust origin in case insLength == 0
 		if origin.Key > uint32(pos) {
-			origin.Key = uint32(int(origin.Key)+delta)
+			origin.Key = uint32(int(origin.Key) + delta)
 		}
 	}
 

+ 6 - 6
internal/burndown/file_test.go

@@ -56,7 +56,7 @@ func TestBullshitFile(t *testing.T) {
 	file.Update(1, 10, 0, 0)
 	assert.Equal(t, int64(100), status[0])
 	assert.Equal(t, int64(0), status[1])
-	assert.Equal(t, alloc.Size(), 3)  // 1 + 2 nodes
+	assert.Equal(t, alloc.Size(), 3) // 1 + 2 nodes
 }
 
 func TestCloneFileShallow(t *testing.T) {
@@ -212,8 +212,8 @@ func TestFusedFile(t *testing.T) {
 	dump = file.Dump()
 	assert.Equal(t, "0 0\n93 -1\n", dump)
 	assert.Equal(t, alloc.Size(), 5)
-	file.Update(3, 10, 6, 0) // +2 nodes
-	assert.Equal(t, alloc.Size(), 5)  // using gaps
+	file.Update(3, 10, 6, 0)         // +2 nodes
+	assert.Equal(t, alloc.Size(), 5) // using gaps
 	file.Update(4, 10, 6, 0)
 	assert.Equal(t, alloc.Size(), 6)
 }
@@ -502,7 +502,7 @@ func TestBug4File(t *testing.T) {
 	// 0 125 | 2 215 | 27 214 | 28 300 | 29 214 | 30 215 | 37 214 | 40 215 | 44 125 | 46 215 | 48 125 | 49 215 | 69 125 | 73 215 | 79 125 | 80 0 | 81 -1
 	dump = file.Dump()
 	assert.Equal(t, "0 125\n2 215\n27 214\n28 300\n29 214\n30 215\n37 214\n40 215\n44 125\n46 215\n48 125\n49 215\n69 125\n73 215\n79 125\n80 0\n81 -1\n", dump)
-	assert.Equal(t, 1 + file.tree.Len(), alloc.Used())
+	assert.Equal(t, 1+file.tree.Len(), alloc.Used())
 	assert.Equal(t, file.Nodes(), file.tree.Len())
 }
 
@@ -539,10 +539,10 @@ func TestUpdatePanic(t *testing.T) {
 	file := NewFileFromTree(keys[:], vals[:], rbtree.NewAllocator())
 	file.tree.DeleteWithKey(0)
 	file.tree.Insert(rbtree.Item{Key: 1, Value: math.MaxUint32})
-	assert.PanicsWithValue(t, "invalid tree state", func(){file.Update(1, 0, 1, 0)})
+	assert.PanicsWithValue(t, "invalid tree state", func() { file.Update(1, 0, 1, 0) })
 	file.tree.Insert(rbtree.Item{Key: 0, Value: math.MaxUint32})
 	assert.PanicsWithValue(
-		t, "time may not be >= MaxUint32", func(){file.Update(math.MaxUint32, 0, 1, 0)})
+		t, "time may not be >= MaxUint32", func() { file.Update(math.MaxUint32, 0, 1, 0) })
 }
 
 func TestFileValidate(t *testing.T) {

+ 1 - 1
internal/core/forks.go

@@ -84,7 +84,7 @@ const (
 )
 
 // planPrintFunc is used to print the execution plan in prepareRunPlan().
-var planPrintFunc = func(args... interface{}) {
+var planPrintFunc = func(args ...interface{}) {
 	fmt.Fprintln(os.Stderr, args...)
 }
 

+ 1 - 1
internal/core/pipeline_test.go

@@ -502,7 +502,7 @@ func TestPipelineDumpPlanConfigure(t *testing.T) {
 	pipeline.Initialize(map[string]interface{}{ConfigPipelineDumpPlan: true})
 	assert.True(t, pipeline.DumpPlan)
 	stream := &bytes.Buffer{}
-	planPrintFunc = func(args... interface{}) {
+	planPrintFunc = func(args ...interface{}) {
 		fmt.Fprintln(stream, args...)
 	}
 	commits := make([]*object.Commit, 1)

+ 3 - 3
internal/plumbing/renames.go

@@ -295,7 +295,7 @@ func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]inter
 						matchesB,
 						&object.Change{
 							From: deletedBlobsB[d].change.From,
-							To: addedBlobsB[a].change.To})
+							To:   addedBlobsB[a].change.To})
 					break
 				}
 			}
@@ -355,7 +355,7 @@ func (ra *RenameAnalysis) Fork(n int) []core.PipelineItem {
 
 func (ra *RenameAnalysis) sizesAreClose(size1 int64, size2 int64) bool {
 	size := internal.Max64(1, internal.Max64(size1, size2))
-	return (internal.Abs64(size1-size2)*10000)/size <= int64(100-ra.SimilarityThreshold) * 100
+	return (internal.Abs64(size1-size2)*10000)/size <= int64(100-ra.SimilarityThreshold)*100
 }
 
 func (ra *RenameAnalysis) blobsAreClose(
@@ -487,7 +487,7 @@ func sortRenameCandidates(candidates []int, origin string, nameGetter func(int)
 		return distances[i].Distance < distances[j].Distance
 	})
 	for i, cd := range distances {
-		candidates[i]  = cd.Candidate
+		candidates[i] = cd.Candidate
 	}
 }
 

+ 1 - 1
internal/plumbing/renames_test.go

@@ -185,4 +185,4 @@ func TestRenameAnalysisSortRenameCandidates(t *testing.T) {
 	})
 	assert.Equal(t, candidates[0], 3)
 	assert.Equal(t, candidates[1], 1)
-}
+}

+ 2 - 2
internal/rbtree/lz4.go

@@ -14,7 +14,7 @@ func CompressUInt32Slice(data []uint32) []byte {
 	dstSize = C.LZ4_compress_HC(
 		unsafe.Pointer(&data[0]),
 		unsafe.Pointer(&dst[0]),
-		C.int(len(data) * 4),
+		C.int(len(data)*4),
 		dstSize,
 		12)
 	finalDst := make([]byte, dstSize)
@@ -28,5 +28,5 @@ func DecompressUInt32Slice(data []byte, result []uint32) {
 	C.LZ4_decompress_fast(
 		unsafe.Pointer(&data[0]),
 		unsafe.Pointer(&result[0]),
-		C.int(len(result) * 4))
+		C.int(len(result)*4))
 }

+ 11 - 11
internal/rbtree/rbtree.go

@@ -19,17 +19,17 @@ type Item struct {
 type Allocator struct {
 	HibernationThreshold int
 
-	storage []node
-	gaps map[uint32]bool
+	storage           []node
+	gaps              map[uint32]bool
 	hibernatedStorage [6][]byte
-	hibernatedLen int
+	hibernatedLen     int
 }
 
 // NewAllocator creates a new allocator for RBTree's nodes.
 func NewAllocator() *Allocator {
-	return &Allocator{ 
+	return &Allocator{
 		storage: []node{},
-		gaps: map[uint32]bool{},
+		gaps:    map[uint32]bool{},
 	}
 }
 
@@ -47,7 +47,7 @@ func (allocator Allocator) Used() int {
 func (allocator *Allocator) Clone() *Allocator {
 	newAllocator := &Allocator{
 		storage: make([]node, len(allocator.storage), cap(allocator.storage)),
-		gaps: map[uint32]bool{},
+		gaps:    map[uint32]bool{},
 	}
 	copy(newAllocator.storage, allocator.storage)
 	for key, val := range allocator.gaps {
@@ -108,7 +108,7 @@ func (allocator *Allocator) Boot() {
 		}(i)
 	}
 	wg.Wait()
-	allocator.storage = make([]node, allocator.hibernatedLen, (allocator.hibernatedLen * 3) / 2)
+	allocator.storage = make([]node, allocator.hibernatedLen, (allocator.hibernatedLen*3)/2)
 	for i := range allocator.storage {
 		n := &allocator.storage[i]
 		n.item.Key = buffers[0][i]
@@ -136,7 +136,7 @@ func (allocator *Allocator) malloc() uint32 {
 		allocator.storage = append(allocator.storage, node{})
 		n = 1
 	}
-	if n == negativeLimitNode - 1 {
+	if n == negativeLimitNode-1 {
 		// math.MaxUint32 is reserved
 		panic("the size of my RBTree allocator has reached the maximum value for uint32, sorry")
 	}
@@ -203,7 +203,7 @@ func (tree RBTree) CloneShallow(allocator *Allocator) *RBTree {
 // CloneDeep performs a deep copy of the tree - the nodes are created from scratch.
 func (tree RBTree) CloneDeep(allocator *Allocator) *RBTree {
 	clone := &RBTree{
-		count: tree.count,
+		count:     tree.count,
 		allocator: allocator,
 	}
 	nodeMap := map[uint32]uint32{0: 0}
@@ -472,8 +472,8 @@ func doAssert(b bool) {
 }
 
 const (
-	red = false
-	black = true
+	red               = false
+	black             = true
 	negativeLimitNode = math.MaxUint32
 )
 

+ 7 - 4
internal/rbtree/rbtree_test.go

@@ -9,7 +9,6 @@ import (
 	"github.com/stretchr/testify/assert"
 )
 
-
 // Create a tree storing a set of integers
 func testNewIntSet() *RBTree {
 	return NewRBTree(NewAllocator())
@@ -80,7 +79,9 @@ func TestDelete(t *testing.T) {
 func iterToString(i Iterator) string {
 	s := ""
 	for ; !i.Limit(); i = i.Next() {
-		if s != "" { s = s + ","}
+		if s != "" {
+			s = s + ","
+		}
 		s = s + fmt.Sprintf("%d", i.Item().Key)
 	}
 	return s
@@ -89,7 +90,9 @@ func iterToString(i Iterator) string {
 func reverseIterToString(i Iterator) string {
 	s := ""
 	for ; !i.NegativeLimit(); i = i.Prev() {
-		if s != "" { s = s + ","}
+		if s != "" {
+			s = s + ","
+		}
 		s = s + fmt.Sprintf("%d", i.Item().Key)
 	}
 	return s
@@ -214,7 +217,7 @@ func (oiter oracleIterator) NegativeLimit() bool {
 }
 
 func (oiter oracleIterator) Max() bool {
-	return oiter.index == len(oiter.o.data) - 1
+	return oiter.index == len(oiter.o.data)-1
 }
 
 func (oiter oracleIterator) Item() int {

+ 4 - 4
leaves/burndown_test.go

@@ -1173,8 +1173,8 @@ func TestBurndownDeserialize(t *testing.T) {
 
 func TestBurndownEmptyFileHistory(t *testing.T) {
 	burndown := &BurndownAnalysis{
-		Sampling: 30,
-		Granularity: 30,
+		Sampling:      30,
+		Granularity:   30,
 		globalHistory: sparseHistory{0: map[int]int64{0: 10}},
 		fileHistories: map[string]sparseHistory{"test.go": {}},
 	}
@@ -1188,8 +1188,8 @@ func TestBurndownEmptyFileHistory(t *testing.T) {
 
 func TestBurndownNegativePeople(t *testing.T) {
 	burndown := &BurndownAnalysis{
-		Sampling:    30,
-		Granularity: 30,
+		Sampling:     30,
+		Granularity:  30,
 		PeopleNumber: -1,
 	}
 	err := burndown.Initialize(test.Repository)

+ 5 - 5
leaves/devs.go

@@ -49,7 +49,7 @@ type DevDay struct {
 	// Commits is the number of commits made by a particular developer in a particular day.
 	Commits int
 	// Added is the number of added lines by a particular developer in a particular day.
-	Added   int
+	Added int
 	// Removed is the number of removed lines by a particular developer in a particular day.
 	Removed int
 	// Changed is the number of changed lines by a particular developer in a particular day.
@@ -208,7 +208,7 @@ func (devs *DevsAnalysis) Consume(deps map[string]interface{}) (map[string]inter
 // Finalize returns the result of the analysis. Further Consume() calls are not expected.
 func (devs *DevsAnalysis) Finalize() interface{} {
 	return DevsResult{
-		Days: devs.days,
+		Days:               devs.days,
 		reversedPeopleDict: devs.reversedPeopleDict,
 	}
 }
@@ -253,7 +253,7 @@ func (devs *DevsAnalysis) Deserialize(pbmessage []byte) (interface{}, error) {
 		}
 	}
 	result := DevsResult{
-		Days: days,
+		Days:               days,
 		reversedPeopleDict: message.DevIndex,
 	}
 	return result, nil
@@ -270,10 +270,10 @@ func (devs *DevsAnalysis) MergeResults(r1, r2 interface{}, c1, c2 *core.CommonAn
 	}
 	devIndex := map[string]devIndexPair{}
 	for dev, devName := range cr1.reversedPeopleDict {
-		devIndex[devName] = devIndexPair{Index1: dev+1, Index2: devIndex[devName].Index2}
+		devIndex[devName] = devIndexPair{Index1: dev + 1, Index2: devIndex[devName].Index2}
 	}
 	for dev, devName := range cr2.reversedPeopleDict {
-		devIndex[devName] = devIndexPair{Index1: devIndex[devName].Index1, Index2: dev+1}
+		devIndex[devName] = devIndexPair{Index1: devIndex[devName].Index1, Index2: dev + 1}
 	}
 	jointDevSeq := make([]string, len(devIndex))
 	{

+ 7 - 7
leaves/devs_test.go

@@ -284,7 +284,7 @@ func TestDevsMergeResults(t *testing.T) {
 	people1 := [...]string{"1@srcd", "2@srcd"}
 	people2 := [...]string{"3@srcd", "1@srcd"}
 	r1 := DevsResult{
-		Days: map[int]map[int]*DevDay{},
+		Days:               map[int]map[int]*DevDay{},
 		reversedPeopleDict: people1[:],
 	}
 	r1.Days[1] = map[int]*DevDay{}
@@ -296,7 +296,7 @@ func TestDevsMergeResults(t *testing.T) {
 	r1.Days[11] = map[int]*DevDay{}
 	r1.Days[11][1] = &DevDay{10, 20, 30, 40}
 	r2 := DevsResult{
-		Days: map[int]map[int]*DevDay{},
+		Days:               map[int]map[int]*DevDay{},
 		reversedPeopleDict: people2[:],
 	}
 	r2.Days[1] = map[int]*DevDay{}
@@ -317,7 +317,7 @@ func TestDevsMergeResults(t *testing.T) {
 	assert.Equal(t, rm.Days[11], map[int]*DevDay{1: {10, 20, 30, 40}})
 	assert.Equal(t, rm.Days[2], map[int]*DevDay{
 		identity.AuthorMissing: {100, 200, 300, 400},
-		2: {11, 21, 31, 41},
+		2:                      {11, 21, 31, 41},
 	})
 	assert.Equal(t, rm.Days[1], map[int]*DevDay{
 		0: {11, 22, 33, 44},
@@ -325,8 +325,8 @@ func TestDevsMergeResults(t *testing.T) {
 		2: {10, 20, 30, 40},
 	})
 	assert.Equal(t, rm.Days[10], map[int]*DevDay{
-		0: {11, 21, 31, 41},
-		2: {11, 21, 31, 41},
-		identity.AuthorMissing: {100*2, 200*2, 300*2, 400*2},
+		0:                      {11, 21, 31, 41},
+		2:                      {11, 21, 31, 41},
+		identity.AuthorMissing: {100 * 2, 200 * 2, 300 * 2, 400 * 2},
 	})
-}
+}