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

moosetechnology / GitProjectHealth / 11163879852

03 Oct 2024 02:24PM UTC coverage: 58.906% (+25.2%) from 33.667%
11163879852

push

github

web-flow
Merge pull request #75 from moosetechnology/develop

V1.0.0

6210 of 8212 new or added lines in 80 files covered. (75.62%)

130 existing lines in 6 files now uncovered.

8903 of 15114 relevant lines covered (58.91%)

0.59 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 }
NEW
11
CodeChurnMetric >> calculate [
×
NEW
12

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

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

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

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

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

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

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

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