Bladeren bron

Run gofmt -s

Vadim Markovtsev 7 jaren geleden
bovenliggende
commit
9524bbb9ea
7 gewijzigde bestanden met toevoegingen van 37 en 36 verwijderingen
  1. 2 2
      blob_cache.go
  2. 2 2
      burndown.go
  3. 21 20
      contrib/_plugin_example/churn_analysis.go
  4. 4 4
      identity.go
  5. 1 1
      renames.go
  6. 2 2
      shotness.go
  7. 5 5
      uast.go

+ 2 - 2
blob_cache.go

@@ -30,7 +30,7 @@ const (
 	// BlobCache.Configure() to not check if the referenced submodules exist.
 	ConfigBlobCacheIgnoreMissingSubmodules = "BlobCache.IgnoreMissingSubmodules"
 	// DependencyBlobCache identifies the dependency provided by BlobCache.
-	DependencyBlobCache                    = "blob_cache"
+	DependencyBlobCache = "blob_cache"
 )
 
 func (blobCache *BlobCache) Name() string {
@@ -52,7 +52,7 @@ func (blobCache *BlobCache) ListConfigurationOptions() []ConfigurationOption {
 		Name: ConfigBlobCacheIgnoreMissingSubmodules,
 		Description: "Specifies whether to panic if some referenced submodules do not exist and thus" +
 			" the corresponding Git objects cannot be loaded. Override this if you know that the " +
-				"history is dirty and you want to get things done.",
+			"history is dirty and you want to get things done.",
 		Flag:    "ignore-missing-submodules",
 		Type:    BoolConfigurationOption,
 		Default: false}}

+ 2 - 2
burndown.go

@@ -104,13 +104,13 @@ const (
 	// ConfigBurndownGranularity is the name of the option to set BurndownAnalysis.Granularity.
 	ConfigBurndownGranularity = "Burndown.Granularity"
 	// ConfigBurndownSampling is the name of the option to set BurndownAnalysis.Sampling.
-	ConfigBurndownSampling    = "Burndown.Sampling"
+	ConfigBurndownSampling = "Burndown.Sampling"
 	// ConfigBurndownTrackFiles enables burndown collection for files.
 	ConfigBurndownTrackFiles = "Burndown.TrackFiles"
 	// ConfigBurndownTrackPeople enables burndown collection for authors.
 	ConfigBurndownTrackPeople = "Burndown.TrackPeople"
 	// ConfigBurndownDebug enables some extra debug assertions.
-	ConfigBurndownDebug        = "Burndown.Debug"
+	ConfigBurndownDebug = "Burndown.Debug"
 	// DefaultBurndownGranularity is the default number of days for BurndownAnalysis.Granularity
 	// and BurndownAnalysis.Sampling.
 	DefaultBurndownGranularity = 30

+ 21 - 20
contrib/_plugin_example/churn_analysis.go

@@ -7,14 +7,14 @@ import (
 	"strings"
 	"unicode/utf8"
 
-  "gopkg.in/src-d/go-git.v4"
+	"github.com/gogo/protobuf/proto"
+	"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/go-git.v4/plumbing"
 	"gopkg.in/src-d/hercules.v3"
 	"gopkg.in/src-d/hercules.v3/yaml"
-	"github.com/gogo/protobuf/proto"
-	"github.com/sergi/go-diff/diffmatchpatch"
 )
 
 // ChurnAnalysis contains the intermediate state which is mutated by Consume(). It should implement
@@ -30,14 +30,14 @@ type ChurnAnalysis struct {
 }
 
 type editInfo struct {
-	Day int
-	Added int
+	Day     int
+	Added   int
 	Removed int
 }
 
 // ChurnAnalysisResult is returned by Finalize() and represents the analysis result.
 type ChurnAnalysisResult struct {
-  Global Edits
+	Global Edits
 	People map[string]Edits
 }
 
@@ -80,7 +80,7 @@ func (churn *ChurnAnalysis) Requires() []string {
 // ListConfigurationOptions tells the engine which parameters can be changed through the command
 // line.
 func (churn *ChurnAnalysis) ListConfigurationOptions() []hercules.ConfigurationOption {
-	opts := [...]hercules.ConfigurationOption {{
+	opts := [...]hercules.ConfigurationOption{{
 		Name:        ConfigChurnTrackPeople,
 		Description: "Record detailed statistics per each developer.",
 		Flag:        "churn-people",
@@ -122,7 +122,8 @@ func (churn *ChurnAnalysis) Consume(deps map[string]interface{}) (map[string]int
 		if err != nil {
 			return nil, err
 		}
-		added := 0; removed := 0
+		added := 0
+		removed := 0
 		switch action {
 		case merkletrie.Insert:
 			added, err = hercules.CountLines(cache[change.To.TreeEntry.Hash])
@@ -167,16 +168,16 @@ func (churn *ChurnAnalysis) Consume(deps map[string]interface{}) (map[string]int
 }
 
 func (churn *ChurnAnalysis) Finalize() interface{} {
-  result := ChurnAnalysisResult{
-	  Global: editInfosToEdits(churn.global),
-	  People: map[string]Edits{},
-  }
+	result := ChurnAnalysisResult{
+		Global: editInfosToEdits(churn.global),
+		People: map[string]Edits{},
+	}
 	if churn.TrackPeople {
 		for key, val := range churn.people {
 			result.People[churn.reversedPeopleDict[key]] = editInfosToEdits(val)
 		}
 	}
-  return result
+	return result
 }
 
 func (churn *ChurnAnalysis) Serialize(result interface{}, binary bool, writer io.Writer) error {
@@ -189,7 +190,7 @@ func (churn *ChurnAnalysis) Serialize(result interface{}, binary bool, writer io
 }
 
 func (churn *ChurnAnalysis) serializeText(result *ChurnAnalysisResult, writer io.Writer) {
-  fmt.Fprintln(writer, "  global:")
+	fmt.Fprintln(writer, "  global:")
 	printEdits(result.Global, writer, 4)
 	for key, val := range result.People {
 		fmt.Fprintf(writer, "  %s:\n", yaml.SafeString(key))
@@ -210,7 +211,7 @@ func (churn *ChurnAnalysis) serializeBinary(result *ChurnAnalysisResult, writer
 		return err
 	}
 	writer.Write(serialized)
-  return nil
+	return nil
 }
 
 func editInfosToEdits(eis []editInfo) Edits {
@@ -245,9 +246,9 @@ func editInfosToEdits(eis []editInfo) Edits {
 func printEdits(edits Edits, writer io.Writer, indent int) {
 	strIndent := strings.Repeat(" ", indent)
 	printArray := func(arr []int, name string) {
-	  fmt.Fprintf(writer, "%s%s: [", strIndent, name)
+		fmt.Fprintf(writer, "%s%s: [", strIndent, name)
 		for i, v := range arr {
-			if i < len(arr) - 1 {
+			if i < len(arr)-1 {
 				fmt.Fprintf(writer, "%d, ", v)
 			} else {
 				fmt.Fprintf(writer, "%d]\n", v)
@@ -261,9 +262,9 @@ func printEdits(edits Edits, writer io.Writer, indent int) {
 
 func editsToEditsMessage(edits Edits) *EditsMessage {
 	message := &EditsMessage{
-		Days: make([]uint32, len(edits.Days)),
+		Days:      make([]uint32, len(edits.Days)),
 		Additions: make([]uint32, len(edits.Additions)),
-		Removals: make([]uint32, len(edits.Removals)),
+		Removals:  make([]uint32, len(edits.Removals)),
 	}
 	copyInts := func(arr []int, where []uint32) {
 		for i, v := range arr {

+ 4 - 4
identity.go

@@ -23,25 +23,25 @@ type IdentityDetector struct {
 const (
 	// AuthorMissing is the internal author index which denotes any unmatched identities
 	// (IdentityDetector.Consume()).
-	AuthorMissing   = (1 << 18) - 1
+	AuthorMissing = (1 << 18) - 1
 	// AuthorMissingName is the string name which corresponds to AuthorMissing.
 	AuthorMissingName = "<unmatched>"
 
 	// FactIdentityDetectorPeopleDict is the name of the fact which is inserted in
 	// IdentityDetector.Configure(). It corresponds to IdentityDetector.PeopleDict - the mapping
 	// from the signatures to the author indices.
-	FactIdentityDetectorPeopleDict         = "IdentityDetector.PeopleDict"
+	FactIdentityDetectorPeopleDict = "IdentityDetector.PeopleDict"
 	// FactIdentityDetectorReversedPeopleDict is the name of the fact which is inserted in
 	// IdentityDetector.Configure(). It corresponds to IdentityDetector.ReversedPeopleDict -
 	// the mapping from the author indices to the main signature.
 	FactIdentityDetectorReversedPeopleDict = "IdentityDetector.ReversedPeopleDict"
 	// ConfigIdentityDetectorPeopleDictPath is the name of the configuration option
 	// (IdentityDetector.Configure()) which allows to set the external PeopleDict mapping from a file.
-	ConfigIdentityDetectorPeopleDictPath   = "IdentityDetector.PeopleDictPath"
+	ConfigIdentityDetectorPeopleDictPath = "IdentityDetector.PeopleDictPath"
 	// FactIdentityDetectorPeopleCount is the name of the fact which is inserted in
 	// IdentityDetector.Configure(). It is equal to the overall number of unique authors
 	// (the length of ReversedPeopleDict).
-	FactIdentityDetectorPeopleCount        = "IdentityDetector.PeopleCount"
+	FactIdentityDetectorPeopleCount = "IdentityDetector.PeopleCount"
 
 	// DependencyAuthor is the name of the dependency provided by IdentityDetector.
 	DependencyAuthor = "author"

+ 1 - 1
renames.go

@@ -165,7 +165,7 @@ func (ra *RenameAnalysis) Consume(deps map[string]interface{}) (map[string]inter
 				reducedChanges = append(
 					reducedChanges,
 					&object.Change{From: deletedBlobs[d].change.From,
-						To:                addedBlobs[a].change.To})
+						To: addedBlobs[a].change.To})
 				break
 			}
 		}

+ 2 - 2
shotness.go

@@ -33,14 +33,14 @@ const (
 	// ConfigShotnessXpathName is the name of the configuration option (ShotnessAnalysis.Configure())
 	// which sets the UAST XPath to find the name of the nodes chosen by ConfigShotnessXpathStruct.
 	// These XPath-s can be different for some languages.
-	ConfigShotnessXpathName   = "Shotness.XpathName"
+	ConfigShotnessXpathName = "Shotness.XpathName"
 
 	// DefaultShotnessXpathStruct is the default UAST XPath to choose the analysed nodes.
 	// It extracts functions.
 	DefaultShotnessXpathStruct = "//*[@roleFunction and @roleDeclaration]"
 	// DefaultShotnessXpathName is the default UAST XPath to choose the names of the analysed nodes.
 	// It looks at the current tree level and at the immediate children.
-	DefaultShotnessXpathName   = "/*[@roleFunction and @roleIdentifier and @roleName] | /*/*[@roleFunction and @roleIdentifier and @roleName]"
+	DefaultShotnessXpathName = "/*[@roleFunction and @roleIdentifier and @roleName] | /*/*[@roleFunction and @roleIdentifier and @roleName]"
 )
 
 type nodeShotness struct {

+ 5 - 5
uast.go

@@ -47,23 +47,23 @@ const (
 
 	// ConfigUASTEndpoint is the name of the configuration option (UASTExtractor.Configure())
 	// which sets the Babelfish server address.
-	ConfigUASTEndpoint     = "ConfigUASTEndpoint"
+	ConfigUASTEndpoint = "ConfigUASTEndpoint"
 	// ConfigUASTTimeout is the name of the configuration option (UASTExtractor.Configure())
 	// which sets the maximum amount of time to wait for a Babelfish server response.
-	ConfigUASTTimeout      = "ConfigUASTTimeout"
+	ConfigUASTTimeout = "ConfigUASTTimeout"
 	// ConfigUASTPoolSize is the name of the configuration option (UASTExtractor.Configure())
 	// which sets the number of goroutines to run for UAST parse queries.
-	ConfigUASTPoolSize     = "ConfigUASTPoolSize"
+	ConfigUASTPoolSize = "ConfigUASTPoolSize"
 	// ConfigUASTFailOnErrors is the name of the configuration option (UASTExtractor.Configure())
 	// which enables early exit in case of any Babelfish UAST parsing errors.
 	ConfigUASTFailOnErrors = "ConfigUASTFailOnErrors"
 	// ConfigUASTLanguages is the name of the configuration option (UASTExtractor.Configure())
 	// which sets the list of languages to parse. Language names are at
 	// https://doc.bblf.sh/languages.html Names are joined with a comma ",".
-	ConfigUASTLanguages    = "ConfigUASTLanguages"
+	ConfigUASTLanguages = "ConfigUASTLanguages"
 
 	// FeatureUast is the name of the Pipeline feature which activates all the items related to UAST.
-	FeatureUast     = "uast"
+	FeatureUast = "uast"
 	// DependencyUasts is the name of the dependency provided by UASTExtractor.
 	DependencyUasts = "uasts"
 )