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

moosetechnology / MooseIDE / 19031912437

03 Nov 2025 10:47AM UTC coverage: 65.581% (+0.3%) from 65.251%
19031912437

push

github

web-flow
Merge pull request #1500 from moosetechnology/dead-code-trick

Removed DeadCode browser morphic trick

178 of 187 new or added lines in 8 files covered. (95.19%)

20961 of 31962 relevant lines covered (65.58%)

1.31 hits per line

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

91.03
/src/MooseIDE-DeadCode/MiDeadCodeBrowserModel.class.st
1
"
2
The spec model for the MiDeadCodeBrowser
3

4
Responsible for handling all interactions as well as computing the dead entities
5
"
6
Class {
7
        #name : 'MiDeadCodeBrowserModel',
8
        #superclass : 'MiAbstractModel',
9
        #instVars : [
10
                'deadEntities',
11
                'candidateEntities',
12
                'chosenHeuristics',
13
                'availableHeuristics'
14
        ],
15
        #category : 'MooseIDE-DeadCode',
16
        #package : 'MooseIDE-DeadCode'
17
}
18

19
{ #category : 'accessing' }
20
MiDeadCodeBrowserModel >> availableHeuristics [
2✔
21

2✔
22
        ^availableHeuristics ifNil: [
2✔
23
                availableHeuristics := MiDeadCodeAbstractHeuristic withAllSubclasses
2✔
24
                        select: [ :class | class isAbstract not ]
2✔
25
                        thenCollect: [ :class | class new ]
2✔
26
        ]
2✔
27
]
2✔
28

29
{ #category : 'actions' }
30
MiDeadCodeBrowserModel >> chooseHeuristics: heuristicCollection [
2✔
31
        "add all of heuristicCollection  to the internal list of chosenHeuristics"
2✔
32

2✔
33
        chosenHeuristics := (chosenHeuristics union: heuristicCollection)
2✔
34
                sort: self heuristicSortBlock.
2✔
35
        browser updateChosenHeuristics
2✔
36
]
2✔
37

38
{ #category : 'accessing' }
39
MiDeadCodeBrowserModel >> chosenHeuristics [
2✔
40

2✔
41
        ^chosenHeuristics 
2✔
42
]
2✔
43

44
{ #category : 'accessing - private tests' }
45
MiDeadCodeBrowserModel >> clearChosenHeuristics [
2✔
46

2✔
47
        chosenHeuristics removeAll
2✔
48
]
2✔
49

50
{ #category : 'settings management' }
NEW
51
MiDeadCodeBrowserModel >> currentConfiguration [
×
NEW
52
        "no settings"
×
53
]
×
54

55
{ #category : 'accessing' }
56
MiDeadCodeBrowserModel >> deadEntities [
2✔
57

2✔
58
        ^deadEntities 
2✔
59
]
2✔
60

61
{ #category : 'settings management' }
NEW
62
MiDeadCodeBrowserModel >> defaultConfiguration [
×
NEW
63
        "no settings"
×
NEW
64
]
×
65

66
{ #category : 'accessing' }
67
MiDeadCodeBrowserModel >> entities [
2✔
68

2✔
69
        ^candidateEntities
2✔
70
]
2✔
71

72
{ #category : 'actions' }
73
MiDeadCodeBrowserModel >> firstRoundComputation [
2✔
74

2✔
75
        deadEntities removeAll.
2✔
76
        self entities do: [ :entity | self firstRoundOn: entity ].
2✔
77
        browser updateToolbar.
2✔
78
        browser updateDeadEntities
2✔
79
]
2✔
80

81
{ #category : 'actions' }
82
MiDeadCodeBrowserModel >> firstRoundOn: entity [
2✔
83
        "search for a heuristic that could deal with the entity
2✔
84
         when found, go to next entity"
2✔
85

2✔
86
        chosenHeuristics do: [ :heuristic |
2✔
87
                (self heuristic: heuristic handle: entity)
2✔
88
                        ifTrue: [ ^self ]
2✔
89
                ]
2✔
90
]
2✔
91

92
{ #category : 'actions' }
93
MiDeadCodeBrowserModel >> followEntity: aCollection [
2✔
94

2✔
95
        candidateEntities := aCollection.
2✔
96
        browser candidateEntities: aCollection.
2✔
97
        browser updateChosenHeuristics
2✔
98
]
2✔
99

100
{ #category : 'actions' }
101
MiDeadCodeBrowserModel >> heuristic: heuristic handle: entity [
2✔
102
        "returns whether a decision was reached or not.
2✔
103
         A decision is reached for _refuting_ heuristics if the entity is not dead
2✔
104
           and there is nothing to do (but we do not need to check other heuristics)
2✔
105
         A decision is reached for _asserting_ heuristic, if the entity is dead
2✔
106
           and it must be added to the list of dead entities"
2✔
107

2✔
108
        heuristic refuteDead 
2✔
109
                ifTrue: [ (heuristic isDead: entity) ifFalse: [ ^true ] ]
2✔
110
                ifFalse: [
2✔
111
                        (heuristic isDead: entity)
2✔
112
                                ifTrue: [ deadEntities add: entity. ^true ]
2✔
113
                ].
2✔
114
        
2✔
115
        ^false
2✔
116
]
2✔
117

118
{ #category : 'actions' }
119
MiDeadCodeBrowserModel >> heuristicSortBlock [
2✔
120
        "sorts refuting heuristics before asserting ones.
2✔
121
         inside these two categories, sort on their names"
2✔
122

2✔
123
        ^[ :a :b |
2✔
124
                (a refuteDead = b refuteDead)
2✔
125
                        ifTrue: [ a name < b name ]
2✔
126
                        ifFalse: [ a refuteDead ]
2✔
127
                ]
2✔
128
]
2✔
129

130
{ #category : 'initialization' }
131
MiDeadCodeBrowserModel >> initialize [ 
2✔
132

2✔
133
        super initialize.
2✔
134

2✔
135
        self initializeHeuristics.
2✔
136
        deadEntities := OrderedCollection new
2✔
137
]
2✔
138

139
{ #category : 'initialization' }
140
MiDeadCodeBrowserModel >> initializeHeuristics [
2✔
141

2✔
142
        chosenHeuristics := OrderedCollection new:
2✔
143
                                    self availableHeuristics size.
2✔
144
        chosenHeuristics addAll:
2✔
145
                (self availableHeuristics select: [ :heuristic |
2✔
146
                         heuristic selectedByDefault ])
2✔
147
]
2✔
148

149
{ #category : 'actions' }
150
MiDeadCodeBrowserModel >> isNewDead: anEntity [
2✔
151

2✔
152
        (deadEntities includes: anEntity) ifTrue: [ ^ false ].
2✔
153

2✔
154
        ^(anEntity queryIncoming: FamixTInvocation) opposites
2✔
155
                allSatisfy: [ :invoker | deadEntities includes: invoker ]
2✔
156
]
2✔
157

158
{ #category : 'accessing' }
159
MiDeadCodeBrowserModel >> miSelectedItem [
2✔
160

2✔
161
        ^deadEntities 
2✔
162
]
2✔
163

164
{ #category : 'actions' }
165
MiDeadCodeBrowserModel >> oneRoundRecursion [
2✔
166

2✔
167
        | addNewDead |
2✔
168
        addNewDead := false.
2✔
169

2✔
170
        self deadEntities clone do: [ :dead |
2✔
171
                (dead queryOutgoing: FamixTInvocation) opposites do: [ :invoked |
2✔
172
                        (self isNewDead: invoked) ifTrue: [
2✔
173
                                deadEntities add: invoked.
2✔
174
                                addNewDead := true
2✔
175
                        ]
2✔
176
                ]
2✔
177
        ].
2✔
178

2✔
179
        ^ addNewDead
2✔
180
]
2✔
181

182
{ #category : 'actions' }
183
MiDeadCodeBrowserModel >> recursionComputation [
2✔
184

2✔
185
        [ self oneRoundRecursion ]
2✔
186
                whileTrue
2✔
187
]
2✔
188

189
{ #category : 'settings management' }
NEW
190
MiDeadCodeBrowserModel >> settings [
×
NEW
191
        "no settings"
×
192

×
193
]
×
194

195
{ #category : 'actions' }
196
MiDeadCodeBrowserModel >> unchooseHeuristics: heuristicCollection [
2✔
197
        "remove all of heuristicCollection from the internal list of chosenHeuristics"
2✔
198

2✔
199
        chosenHeuristics removeAll: heuristicCollection.
2✔
200
        browser updateChosenHeuristics
2✔
201
]
2✔
202

203
{ #category : 'settings management' }
NEW
204
MiDeadCodeBrowserModel >> updateFromConfiguration: aConfiguration [
×
NEW
205
        "no settings"
×
206
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc