GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2e7cbb...9fc785 )
by Fedir
02:21
created

main.fillRepositoryStatistics   B

Complexity

Conditions 7

Size

Total Lines 59
Code Lines 53

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 7

Importance

Changes 0
Metric Value
cc 7
eloc 53
nop 4
dl 0
loc 59
rs 7.1381
c 0
b 0
f 0
ccs 24
cts 24
cp 1
crap 7

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
// Copyright 2018 Fedir RYKHTIK. All rights reserved.
2
// Use of this source code is governed by the GNU GPL 3.0
3
// license that can be found in the LICENSE file.
4
5
// ghstat - statistical multi-criteria decision-making comparator for Github's projects.
6
package main
7
8
import (
9
	"flag"
10
	"os"
11
	"strings"
12
13
	"github.com/fedir/ghstat/github"
14
)
15
16
func main() {
17 1
	var (
18
		clearHTTPCache         = flag.Bool("cc", false, "Clear HTTP cache")
19
		clearHTTPCacheDryRun   = flag.Bool("ccdr", false, "Clear HTTP cache (dry run)")
20
		debug                  = flag.Bool("d", false, "Debug mode")
21
		resultFileSavePath     = flag.String("f", "", "File path where result CSV file will be saved")
22
		rateLimitCheck         = flag.Bool("l", false, "Rate limit check")
23
		repositoriesKeysManual = flag.String("r", "", "Repositories keys")
24
		tmpFolder              = flag.String("t", "test_data", "Clear HTTP cache (dry run)")
25
		repositoriesKeys       = []string{}
26
	)
27 1
	flag.Parse()
28 1
	if *clearHTTPCache || *clearHTTPCacheDryRun {
29
		clearHTTPCacheFolder(*tmpFolder, *clearHTTPCacheDryRun)
30
		os.Exit(0)
31
	}
32 1
	if *rateLimitCheck {
33
		github.CheckAndPrintRateLimit()
34
		os.Exit(0)
35
	}
36 1
	if *repositoriesKeysManual != "" {
37
		repositoriesKeys = uniqSlice(strings.Split(*repositoriesKeysManual, ","))
38
	} else {
39 1
		repositoriesKeys = uniqSlice([]string{
40
			"astaxie/beego",
41
			"gohugoio/hugo",
42
			"gin-gonic/gin",
43
			"labstack/echo",
44
			"revel/revel",
45
			"gobuffalo/buffalo",
46
			"go-chi/chi",
47
			"kataras/iris",
48
			"zenazn/goji",
49
			"go-macaron/macaron",
50
		})
51
	}
52
53 1
	csvFilePath := ""
54 1
	if *resultFileSavePath != "" {
55
		csvFilePath = *resultFileSavePath
56
	} else {
57 1
		csvFilePath = "result.csv"
58
	}
59 1
	var ghData = []Repository{}
60
61 1
	dataChan := make(chan Repository, len(repositoriesKeys))
62 1
	for _, rKey := range repositoriesKeys {
63 1
		go repositoryData(rKey, *tmpFolder, *debug, dataChan)
64
	}
65 1
	for range repositoriesKeys {
66 1
		ghData = append(ghData, <-dataChan)
67
	}
68 1
	rateAndPrintGreetings(ghData)
69 1
	writeCSVStatistics(ghData, csvFilePath)
70
}
71
72
func uniqSlice(s []string) []string {
73 1
	unique := make(map[string]bool, len(s))
74 1
	us := make([]string, len(unique))
75 1
	for _, elem := range s {
76 1
		if len(elem) != 0 {
77 1
			if !unique[elem] {
78 1
				us = append(us, elem)
79 1
				unique[elem] = true
80
			}
81
		}
82
	}
83 1
	return us
84
}
85