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

moosetechnology / GitProjectHealth / 13807399403

12 Mar 2025 08:58AM UTC coverage: 66.731% (+0.2%) from 66.508%
13807399403

Pull #145

github

web-flow
Merge 41a250ee3 into 2c2d8c5e1
Pull Request #145: Code addition merge rerquest project metric

6833 of 8097 new or added lines in 90 files covered. (84.39%)

1 existing line in 1 file now uncovered.

11746 of 17602 relevant lines covered (66.73%)

0.67 hits per line

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

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

10
{ #category : #calculating }
11
CodeChurnOnCommitsProjectMetric >> calculate [
1✔
12

1✔
13
        | commits res groupedByDate totalContributions gitAnalyzer |
1✔
14
        projectCommits ifNil: [ self load ].
1✔
15

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

1✔
20
        commits := self
1✔
21
                           foundSuccessorOf: projectCommits
1✔
22
                           andCompleteImportForMax: maxCommitWindow.
1✔
23

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

1✔
66
        ^ (groupedByDate collect: [ :date | date at: #percentage ]) average
1✔
67
]
1✔
68

69
{ #category : #accessing }
NEW
70
CodeChurnOnCommitsProjectMetric >> description [
×
NEW
71

×
NEW
72
        ^ 'churn % in project (W=' , maxCommitWindow printString , ')'
×
NEW
73
]
×
74

75
{ #category : #initialization }
76
CodeChurnOnCommitsProjectMetric >> initialize [ 
1✔
77
        maxCommitWindow := 3. 
1✔
78
]
1✔
79

80
{ #category : #loading }
81
CodeChurnOnCommitsProjectMetric >> load [
1✔
82

1✔
83
        projectCommits := self
1✔
84
                                  loadCommitsSince: (period at: #since)
1✔
85
                                  until: (period at: #until)
1✔
86
]
1✔
87

88
{ #category : #accessing }
89
CodeChurnOnCommitsProjectMetric >> maxCommitWindow: anInteger [ 
1✔
90
        maxCommitWindow := anInteger
1✔
91
]
1✔
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