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.

competition.go   A
last analyzed

Size/Duplication

Total Lines 126
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 35
eloc 75
dl 0
loc 126
rs 9.6
c 0
b 0
f 0
ccs 69
cts 69
cp 1
crap 35

2 Methods

Rating   Name   Duplication   Size   Complexity  
A main.rateAndPrintGreetings 0 3 1
F main.rateGhData 0 114 34
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
	"sort"
10
)
11
12
func rateAndPrintGreetings(ghData []Repository) {
13 1
	greetings := rateGhData(ghData)
14 1
	fmt.Println(greetings)
15
}
16
17
func rateGhData(ghData []Repository) string {
18
19 1
	greetings := ""
20
21
	// Add points by repository total popularity (more popular is better)
22 1
	sort.Slice(ghData[:], func(i, j int) bool {
23 1
		return ghData[i].Watchers > ghData[j].Watchers
24
	})
25 1
	greetings += fmt.Sprintf("* The most popular project is `%s`\n", ghData[0].Name)
26 1
	for i := range ghData {
27 1
		ghData[i].PlacementPopularity = i + 1
28 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
29
	}
30
31
	// Add points by age (newest is better)
32 1
	sort.Slice(ghData[:], func(i, j int) bool {
33 1
		return ghData[i].Age < ghData[j].Age
34
	})
35 1
	greetings += fmt.Sprintf("* The newest project is `%s`\n", ghData[0].Name)
36 1
	for i := range ghData {
37 1
		ghData[i].PlacementAge = i + 1
38 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
39
	}
40
41
	// Add points by number of commits (more commits is better)
42 1
	sort.Slice(ghData[:], func(i, j int) bool {
43 1
		return ghData[i].TotalCommits > ghData[j].TotalCommits
44
	})
45 1
	greetings += fmt.Sprintf("* The project with more commits is `%s`\n", ghData[0].Name)
46 1
	for i := range ghData {
47 1
		ghData[i].PlacementTotalCommits = i + 1
48 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
49
	}
50
51
	// Add points by average contribution in days (longer is better)
52 1
	sort.Slice(ghData[:], func(i, j int) bool {
53 1
		return ghData[i].AverageContributionPeriod > ghData[j].AverageContributionPeriod
54
	})
55 1
	greetings += fmt.Sprintf("* The project with biggest average contribution period is `%s`\n", ghData[0].Name)
56 1
	for i := range ghData {
57 1
		ghData[i].PlacementTotalCommits = i + 1
58 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
59
	}
60
61
	// Add points by number of tags (more tags is better)
62 1
	sort.Slice(ghData[:], func(i, j int) bool {
63 1
		return ghData[i].TotalTags > ghData[j].TotalTags
64
	})
65 1
	greetings += fmt.Sprintf("* The project with more tags is `%s`\n", ghData[0].Name)
66 1
	for i := range ghData {
67 1
		ghData[i].PlacementTotalTags = i + 1
68 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
69
	}
70
71
	// Add points by Top10 contributors followers
72 1
	sort.Slice(ghData[:], func(i, j int) bool {
73 1
		return ghData[i].Top10ContributorsFollowers > ghData[j].Top10ContributorsFollowers
74
	})
75 1
	greetings += fmt.Sprintf("* The project made by most notable top contributors is `%s`\n", ghData[0].Name)
76 1
	for i := range ghData {
77 1
		ghData[i].PlacementTop10ContributorsFollowers = i + 1
78 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
79
	}
80
81
	// Add points by Top10 contributors followers
82 1
	sort.Slice(ghData[:], func(i, j int) bool {
83 1
		return ghData[i].ClosedIssuesPercentage > ghData[j].ClosedIssuesPercentage
84
	})
85 1
	greetings += fmt.Sprintf("* The project with best errors resolving rate is `%s`\n", ghData[0].Name)
86 1
	for i := range ghData {
87 1
		ghData[i].PlacementClosedIssuesPercentage = i + 1
88 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
89
	}
90
91
	// Add points by commits by day (more commits shows good healthy community)
92 1
	sort.Slice(ghData[:], func(i, j int) bool {
93 1
		return ghData[i].CommitsByDay > ghData[j].CommitsByDay
94
	})
95 1
	greetings += fmt.Sprintf("* The project with more commits by day is `%s`\n", ghData[0].Name)
96 1
	for i := range ghData {
97 1
		ghData[i].PlacementCommitsByDay = i + 1
98 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
99
	}
100
101
	// Add points by active forkers (more active forkers shows good open source spirit of the community)
102 1
	sort.Slice(ghData[:], func(i, j int) bool {
103 1
		return ghData[i].ActiveForkersPercentage > ghData[j].ActiveForkersPercentage
104
	})
105 1
	greetings += fmt.Sprintf("* The project with the most active number of forkers is `%s`\n", ghData[0].Name)
106 1
	for i := range ghData {
107 1
		ghData[i].PlacementActiveForkersColumn = i + 1
108 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
109
	}
110
111
	// Add points by returning contributors (more returning contributors shows good open source spirit of the community)
112 1
	sort.Slice(ghData[:], func(i, j int) bool {
113 1
		return ghData[i].ReturningContributors > ghData[j].ReturningContributors
114
	})
115 1
	greetings += fmt.Sprintf("* The project with biggest number of returning contributors is `%s`\n", ghData[0].Name)
116 1
	for i := range ghData {
117 1
		ghData[i].PlacementActiveForkersColumn = i + 1
118 1
		ghData[i].PlacementOverall = ghData[i].PlacementOverall + i
119
	}
120
121
	// Assign places to projects by all metrics
122 1
	sort.Slice(ghData[:], func(i, j int) bool {
123 1
		return ghData[i].PlacementOverall < ghData[j].PlacementOverall
124
	})
125 1
	greetings += fmt.Sprintf("* The best project (taking in account placements in all competitions) is `%s`\n", ghData[0].Name)
126 1
	for i := range ghData {
127 1
		ghData[i].PlacementOverall = i + 1
128
	}
129
130 1
	return greetings
131
}
132