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.

main.repositoryData   B
last analyzed

Complexity

Conditions 5

Size

Total Lines 62
Code Lines 48

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 44
CRAP Score 5.0002

Importance

Changes 0
Metric Value
cc 5
eloc 48
nop 5
dl 0
loc 62
ccs 44
cts 45
cp 0.9778
crap 5.0002
rs 8.235
c 0
b 0
f 0

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
	"sync"
10
	"time"
11
12
	"github.com/fedir/ghstat/github"
13
)
14
15
func repositoryData(rKey string, tmpFolder string, debug bool, dataChan chan Repository, wg *sync.WaitGroup) {
16
17 1
	defer wg.Done()
18
19 1
	r := new(Repository)
20
21 1
	repositoryData := github.GetRepositoryStatistics(rKey, tmpFolder, debug)
22
23 1
	r.Name = repositoryData.FullName
24 1
	r.URL = fmt.Sprintf("https://github.com/%s", r.Name)
25 1
	r.MainLanguage = repositoryData.Language
26 1
	r.AllLanguages, r.TotalCodeSize = github.GetRepositoryLanguages(rKey, tmpFolder, debug)
27 1
	r.Description = repositoryData.Description
28 1
	r.CreatedAt = repositoryData.CreatedAt
29 1
	r.Age = int(time.Since(repositoryData.CreatedAt).Seconds() / 86400)
30 1
	r.Watchers = repositoryData.Watchers
31 1
	r.Forks = repositoryData.Forks
32 1
	r.OpenIssues = repositoryData.OpenIssues
33 1
	r.License = "[Custom license]"
34 1
	if repositoryData.License.SPDXID != "" {
35 1
		r.License = repositoryData.License.SPDXID
36
	}
37 1
	r.Author = "[No GitHub account detected]"
38
39 1
	r.Author, r.LastCommitDate = github.GetRepositoryCommitsData(rKey, tmpFolder, debug)
40
41 1
	r.AuthorsFollowers = 0
42 1
	r.AuthorLocation = "[Unknown]"
43 1
	if r.Author != "" {
44 1
		r.AuthorsFollowers = github.GetUserFollowers(r.Author, tmpFolder, debug)
45 1
		authorData := github.GetUserData(r.Author, tmpFolder, debug)
46 1
		if authorData.Location != "" {
47 1
			r.AuthorLocation = authorData.Location
48
		}
49
	} else {
50
		r.Author = "[Unknown account]"
51
	}
52
53 1
	r.ClosedIssues = 0
54 1
	if repositoryData.HasIssues {
55 1
		r.ClosedIssues = github.GetRepositoryClosedIssues(rKey, tmpFolder, debug)
56
	}
57 1
	r.TotalIssues = r.OpenIssues + r.ClosedIssues
58 1
	r.Top10ContributorsFollowers,
59
		r.Contributors = github.GetRepositoryContributors(rKey, tmpFolder, debug)
60 1
	r.TotalTags = github.GetRepositoryTagsNumber(rKey, tmpFolder, debug)
61 1
	r.ActiveForkersPercentage = github.GetActiveForkersPercentage(r.Contributors, r.Forks)
62 1
	r.IssueByDay = github.GetIssueByDay(r.ClosedIssues+r.OpenIssues, r.Age)
63 1
	r.ClosedIssuesPercentage = github.GetClosedIssuesPercentage(repositoryData.OpenIssues, int(r.ClosedIssues))
64
65 1
	contributionStatistics := github.GetContributionStatistics(rKey, tmpFolder, debug)
66 1
	r.TotalCommits = contributionStatistics.TotalCommits
67 1
	r.TotalAdditions = contributionStatistics.TotalAdditions
68 1
	r.TotalDeletions = contributionStatistics.TotalDeletions
69 1
	r.TotalCodeChanges = contributionStatistics.TotalCodeChanges
70 1
	r.AverageContributionPeriod = contributionStatistics.AverageContributionPeriod
71 1
	r.ReturningContributors = contributionStatistics.ReturningContributors
72 1
	r.MediCommitSize = contributionStatistics.MediumCommitSize
73
74 1
	r.CommitsByDay = github.GetCommitsByDay(contributionStatistics.TotalCommits, r.Age)
75
76 1
	dataChan <- *r
77
}
78