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

moosetechnology / GitProjectHealth / 11667512120

04 Nov 2024 03:36PM UTC coverage: 59.207% (+0.2%) from 59.01%
11667512120

Pull #105

github

web-flow
Merge 0462ff346 into 3c4574e31
Pull Request #105: fix/add email user to the importer + tests

71 of 82 new or added lines in 3 files covered. (86.59%)

149 existing lines in 35 files now uncovered.

9582 of 16184 relevant lines covered (59.21%)

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

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

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

×
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 }
UNCOV
69
CodeChurnMetric >> description [
×
70

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

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