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

ghstat.go   A

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 80.65%

Importance

Changes 0
Metric Value
cc 15
dl 0
loc 78
rs 10
c 0
b 0
f 0
ccs 25
cts 31
cp 0.8065
crap 16.6301

2 Methods

Rating   Name   Duplication   Size   Complexity  
C main.main 0 54 10
A main.uniqSlice 0 12 5
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