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

moosetechnology / MooseIDE / 18938833417

30 Oct 2025 11:17AM UTC coverage: 65.531% (-1.0%) from 66.52%
18938833417

Pull #1495

github

web-flow
Merge 8589a0f73 into 4ebf8d6d3
Pull Request #1495: chore: move MiDeadCodeBrowserTest to MooseIDE-DeadCode-Tests package

20348 of 31051 relevant lines covered (65.53%)

1.31 hits per line

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

73.29
/src/MooseIDE-Dependency/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
                'allHeuristics',
13
                'selectedHeuristics'
14
        ],
15
        #category : 'MooseIDE-Dependency-DeadCode',
16
        #package : 'MooseIDE-Dependency',
17
        #tag : 'DeadCode'
18
}
19

20
{ #category : 'accessing' }
21
MiDeadCodeBrowserModel >> availableHeuristics [
×
22

×
23
        ^allHeuristics
×
24
]
×
25

26
{ #category : 'actions' }
27
MiDeadCodeBrowserModel >> clearDeads [
×
28

×
29
        deadEntities := OrderedCollection new.
×
30
        browser updateDeadEntities
×
31
]
×
32

33
{ #category : 'accessing - private tests' }
34
MiDeadCodeBrowserModel >> clearSelectedHeuristics [
×
35

×
36
        selectedHeuristics removeAll
×
37
]
×
38

39
{ #category : 'accessing' }
40
MiDeadCodeBrowserModel >> deadEntities [
2✔
41

2✔
42
        ^deadEntities 
2✔
43
]
2✔
44

45
{ #category : 'accessing' }
46
MiDeadCodeBrowserModel >> entities [
2✔
47

2✔
48
        ^candidateEntities
2✔
49
]
2✔
50

51
{ #category : 'actions' }
52
MiDeadCodeBrowserModel >> firstRoundComputation [
2✔
53

2✔
54
        deadEntities removeAll.
2✔
55
        self entities do: [ :entity | self firstRoundOn: entity ].
2✔
56
        browser updateToolbar.
2✔
57
        browser updateDeadEntities
2✔
58
]
2✔
59

60
{ #category : 'actions' }
61
MiDeadCodeBrowserModel >> firstRoundOn: entity [
2✔
62
        "search for a heuristic that could deal with the entity
2✔
63
         when found, go to next entity"
2✔
64

2✔
65
        selectedHeuristics do: [ :heuristic |
2✔
66
                (self heuristic: heuristic handle: entity)
2✔
67
                        ifTrue: [ ^self ]
2✔
68
                ]
2✔
69
]
2✔
70

71
{ #category : 'actions' }
72
MiDeadCodeBrowserModel >> followEntity: aCollection [
2✔
73

2✔
74
        candidateEntities := aCollection.
2✔
75
        browser candidateEntities: aCollection.
2✔
76
        browser updateHeuristicSelection
2✔
77
]
2✔
78

79
{ #category : 'accessing' }
80
MiDeadCodeBrowserModel >> gatherHeuristics [
2✔
81

2✔
82
        ^MiDeadCodeAbstractHeuristic withAllSubclasses
2✔
83
                select: [ :class | class isAbstract not ]
2✔
84
                thenCollect: [ :class | class new ]
2✔
85
]
2✔
86

87
{ #category : 'actions' }
88
MiDeadCodeBrowserModel >> heuristic: heuristic handle: entity [
2✔
89
        "returns whether a decision was reach or not.
2✔
90
         A decision is reached for _refuting_ heuristics if the entity is not dead
2✔
91
           and there is nothing to do (but we do not need to check other heuristics)
2✔
92
         A decision is reached for _asserting_ heuristic, if the entity is dead
2✔
93
           and it must be added to the list of dead entities"
2✔
94

2✔
95
        heuristic refuteDead 
2✔
96
                ifTrue: [ (heuristic isDead: entity) ifFalse: [ ^true ] ]
2✔
97
                ifFalse: [
2✔
98
                        (heuristic isDead: entity)
2✔
99
                                ifTrue: [ deadEntities add: entity. ^true ]
2✔
100
                ].
2✔
101
        
2✔
102
        ^false
2✔
103
]
2✔
104

105
{ #category : 'initialization' }
106
MiDeadCodeBrowserModel >> initialize [ 
2✔
107

2✔
108
        super initialize.
2✔
109

2✔
110
        self initializeHeuristics.
2✔
111
        deadEntities := OrderedCollection new
2✔
112
]
2✔
113

114
{ #category : 'initialization' }
115
MiDeadCodeBrowserModel >> initializeHeuristics [
2✔
116

2✔
117
        allHeuristics := self gatherHeuristics.
2✔
118

2✔
119
        selectedHeuristics := OrderedCollection new: allHeuristics size.
2✔
120
        allHeuristics do: [ :heuristic |
2✔
121
                heuristic selectedByDefault
2✔
122
                        ifTrue: [ selectedHeuristics add: heuristic ] ].
2✔
123

2✔
124
]
2✔
125

126
{ #category : 'actions' }
127
MiDeadCodeBrowserModel >> isNewDead: anEntity [
2✔
128

2✔
129
        (deadEntities includes: anEntity) ifTrue: [ ^ false ].
2✔
130

2✔
131
        ^ (anEntity queryIncoming: FamixTInvocation) opposites allSatisfy: [ :invoker | deadEntities includes: invoker ]
2✔
132
]
2✔
133

134
{ #category : 'accessing' }
135
MiDeadCodeBrowserModel >> miSelectedItem [
×
136

×
137
        ^deadEntities 
×
138
]
×
139

140
{ #category : 'actions' }
141
MiDeadCodeBrowserModel >> oneRoundRecursion [
2✔
142

2✔
143
        | addNewDead |
2✔
144
        addNewDead := false.
2✔
145

2✔
146
        self deadEntities clone do: [ :dead |
2✔
147
                        (dead queryOutgoing: FamixTInvocation) opposites do: [ :invoked |
2✔
148
                                        (self isNewDead: invoked) ifTrue: [
2✔
149
                                                        deadEntities add: invoked.
2✔
150
                                                        addNewDead := true ] ] ].
2✔
151

2✔
152
        ^ addNewDead
2✔
153
]
2✔
154

155
{ #category : 'actions' }
156
MiDeadCodeBrowserModel >> recursionComputation [
2✔
157

2✔
158
        [ self oneRoundRecursion ]
2✔
159
                whileTrue
2✔
160
]
2✔
161

162
{ #category : 'actions' }
163
MiDeadCodeBrowserModel >> rejectHeuristics [
×
164
        "remove all heuristics selected by the user in listHeuristicsSelected from
×
165
         the internal list of selectedHeuristics"
×
166

×
167
        | reject |
×
168
        reject := browser heuristicColumn listHeuristicsSelected selectedItems clone.
×
169

×
170
        selectedHeuristics removeAll: reject.
×
171
        browser updateHeuristicSelection
×
172
]
×
173

174
{ #category : 'actions' }
175
MiDeadCodeBrowserModel >> selectHeuristics [
×
176
        "add all heuristics selected by the user in listHeuristicsOffered to
×
177
         the internal list of selectedHeuristics"
×
178

×
179
        selectedHeuristics := (selectedHeuristics union:
×
180
                browser heuristicColumn listHeuristicsOffered selectedItems).
×
181
        self sortHeuristics.
×
182
        browser updateHeuristicSelection
×
183
]
×
184

185
{ #category : 'accessing' }
186
MiDeadCodeBrowserModel >> selectedHeuristics [
2✔
187

2✔
188
        ^selectedHeuristics 
2✔
189
]
2✔
190

191
{ #category : 'settings' }
192
MiDeadCodeBrowserModel >> settings [
×
193

×
194
]
×
195

196
{ #category : 'actions' }
197
MiDeadCodeBrowserModel >> sortHeuristics [
2✔
198
        "sorts refuting heuristics before asserting ones.
2✔
199
         if of the samecategory, sort on their names"
2✔
200

2✔
201
        selectedHeuristics sort: [ :a :b |
2✔
202
                (a refuteDead = b refuteDead)
2✔
203
                        ifTrue: [ a name < b name ]
2✔
204
                        ifFalse: [ a refuteDead ]
2✔
205
                ]
2✔
206
]
2✔
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