• 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

93.65
/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 [
1✔
12

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

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

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

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

74
{ #category : #initialization }
75
CodeChurnMetric >> initialize [ 
1✔
76
        maxCommitWindow := 3
1✔
77
]
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