• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / GitProjectHealth / 10679816778

03 Sep 2024 08:59AM UTC coverage: 18.519%. First build
10679816778

Pull #47

github

web-flow
Merge 81832ecb3 into 049515451
Pull Request #47: refactor: remove GitMetric class and subclasses

0 of 155 new or added lines in 10 files covered. (0.0%)

1590 of 8586 relevant lines covered (18.52%)

0.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/GitLabHealth-Model-Analysis/CodeChurnMetric.class.st
1
Class {
2
        #name : #CodeChurnMetric,
3
        #superclass : #UserCommitsMetric,
4
        #instVars : [
5
                'maxCommitWindow'
6
        ],
7
        #category : #'GitLabHealth-Model-Analysis'
8
}
9

10
{ #category : #calculating }
11
CodeChurnMetric >> calculate [
×
12

×
13
        | commits res groupedByDate totalContributions gitAnalyzer |
×
14
        userCommits ifNil: [ self load ].
×
NEW
15

×
16
        totalContributions := OrderedCollection new.
×
17
        groupedByDate := self setupGroupedDate.
×
18
        gitAnalyzer := GitAnalyzer new maxChildCommit: maxCommitWindow.
×
19

×
NEW
20
        commits := self
×
21
                           foundSuccessorOf: userCommits
×
22
                           andCompleteImportForMax: maxCommitWindow.
×
23

×
24
        res := commits collect: [ :commit |
×
25
                       commit -> (gitAnalyzer
×
26
                                fromCommit: commit;
×
27
                                analyseChurn) ].
×
28
        res do: [ :commits4Churns |
×
29
                | commit allChurnsInCommit sumChurnInCommit overDate contribution churnOnCommit |
×
30
                commit := commits4Churns key.
×
31
                allChurnsInCommit := commits4Churns value.
×
32
                sumChurnInCommit := (allChurnsInCommit at: #churns) sum: [ :churn |
×
33
                                            | numerator |
×
34
                                            numerator := churn value at: #churnLoC.
×
35
                                            numerator ].
×
36
                contribution := allChurnsInCommit at: #totalContribution.
×
37
                totalContributions add: contribution.
×
38
                churnOnCommit := {
×
39
                                         (#churnOnCommit -> sumChurnInCommit).
×
40
                                         (#LoCOnCommit -> contribution) } asDictionary.
×
41
                overDate := self transformDate: commit created_at to: over.
×
42
                groupedByDate
×
43
                        at: overDate printString
×
44
                        ifPresent: [ :array | array add: churnOnCommit ]
×
45
                        ifAbsentPut: [
×
46
                                OrderedCollection new
×
47
                                        add: churnOnCommit;
×
48
                                        yourself ] ].
×
49
        groupedByDate := groupedByDate collect: [ :churnsAtDate |
×
50
                                 | totalChurn totalContribution percentage |
×
51
                                 totalChurn := churnsAtDate sum: [ :churn |
×
52
                                                       churn at: #churnOnCommit ].
×
53
                                 totalContribution := churnsAtDate sum: [ :churn |
×
54
                                                              churn at: #LoCOnCommit ].
×
55
                                 totalContribution = 0
×
56
                                         ifTrue: [ percentage := 0 asFloat ]
×
57
                                         ifFalse: [
×
58
                                         percentage := (totalChurn * 100
×
59
                                                        / totalContribution) asFloat ].
×
60
                                 {
×
61
                                         (#churn -> totalChurn).
×
62
                                         (#contribution -> totalContribution).
×
63
                                         (#percentage -> percentage) } asDictionary ].
×
64

×
65
        ^ (groupedByDate collect: [ :date | date at: #percentage ]) average
×
66
]
×
67

68
{ #category : #accessing }
69
CodeChurnMetric >> description [
×
70

×
71
        ^ 'churn % (W=' , maxCommitWindow printString , ')'
×
72
]
×
73

74
{ #category : #initialization }
75
CodeChurnMetric >> initialize [ 
×
76
        maxCommitWindow := 3
×
77
]
×
78

79
{ #category : #accessing }
80
CodeChurnMetric >> name [
×
81

×
82
        ^ 'codeChurn'
×
83
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc