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.repositoryData   B

Complexity

Conditions 4

Size

Total Lines 52
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 36
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 40
nop 4
dl 0
loc 52
rs 8.92
c 0
b 0
f 0
ccs 36
cts 36
cp 1
crap 4

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
package main
6
7
import (
8
	"fmt"
9
	"time"
10
11
	"github.com/fedir/ghstat/github"
12
)
13
14
func repositoryData(rKey string, tmpFolder string, debug bool, dataChan chan Repository) {
15
16 1
	r := new(Repository)
17
18 1
	repositoryData := github.GetRepositoryStatistics(rKey, tmpFolder, debug)
19
20 1
	r.Name = repositoryData.FullName
21 1
	r.URL = fmt.Sprintf("https://github.com/%s", r.Name)
22 1
	r.Language = repositoryData.Language
23 1
	r.CreatedAt = repositoryData.CreatedAt
24 1
	r.Age = int(time.Since(repositoryData.CreatedAt).Seconds() / 86400)
25 1
	r.Watchers = repositoryData.Watchers
26 1
	r.Forks = repositoryData.Forks
27 1
	r.OpenIssues = repositoryData.OpenIssues
28 1
	r.License = "[Unknown]"
29 1
	if repositoryData.License.SPDXID != "" {
30 1
		r.License = repositoryData.License.SPDXID
31
	}
32 1
	r.Author = "[Unknown]"
33
34 1
	r.Author,
35
		r.LastCommitDate = github.GetRepositoryCommitsData(rKey, tmpFolder, debug)
36
37 1
	r.AuthorsFollowers = 0
38 1
	if r.Author != "" {
39 1
		r.AuthorsFollowers = github.GetUserFollowers(r.Author, tmpFolder, debug)
40
	} else {
41 1
		r.Author = "[Account removed]"
42
	}
43
44 1
	r.ClosedIssues = 0
45 1
	if repositoryData.HasIssues {
46 1
		r.ClosedIssues = github.GetRepositoryClosedIssues(rKey, tmpFolder, debug)
47
	}
48 1
	r.TotalIssues = r.OpenIssues + r.ClosedIssues
49 1
	r.Top10ContributorsFollowers,
50
		r.Contributors = github.GetRepositoryContributors(rKey, tmpFolder, debug)
51 1
	r.TotalTags = github.GetRepositoryTagsNumber(rKey, tmpFolder, debug)
52 1
	r.ActiveForkersPercentage = github.GetActiveForkersPercentage(r.Contributors, r.Forks)
53 1
	r.IssueByDay = github.GetIssueByDay(r.ClosedIssues+r.OpenIssues, r.Age)
54 1
	r.ClosedIssuesPercentage = github.GetClosedIssuesPercentage(repositoryData.OpenIssues, int(r.ClosedIssues))
55
56 1
	contributionStatistics := github.GetContributionStatistics(rKey, tmpFolder, debug)
57 1
	r.TotalCommits = contributionStatistics.TotalCommits
58 1
	r.TotalAdditions = contributionStatistics.TotalAdditions
59 1
	r.TotalDeletions = contributionStatistics.TotalDeletions
60 1
	r.TotalCodeChanges = contributionStatistics.TotalCodeChanges
61 1
	r.MediCommitSize = contributionStatistics.MediumCommitSize
62
63 1
	r.CommitsByDay = github.GetCommitsByDay(contributionStatistics.TotalCommits, r.Age)
64
65 1
	dataChan <- *r
66
}
67