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

moosetechnology / MooseIDE / 21355890634

26 Jan 2026 11:22AM UTC coverage: 65.314%. First build
21355890634

push

github

web-flow
Merge pull request #1570 from moosetechnology/dead-code-browser

Dead code browser bug for Java methods

35 of 44 new or added lines in 3 files covered. (79.55%)

21805 of 33385 relevant lines covered (65.31%)

1.31 hits per line

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

0.0
/src/MooseIDE-DeadCode/MiDeadCodeBrowserModelWithCallGraph.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 : 'MiDeadCodeBrowserModelWithCallGraph',
8
        #superclass : 'MiAbstractModel',
9
        #instVars : [
10
                'deadEntities',
11
                'candidateEntities',
12
                'chosenHeuristics',
13
                'availableHeuristics',
14
                'selectedDeadEntities'
15
        ],
16
        #category : 'MooseIDE-DeadCode-Model',
17
        #package : 'MooseIDE-DeadCode',
18
        #tag : 'Model'
19
}
20

21
{ #category : 'actions' }
NEW
22
MiDeadCodeBrowserModelWithCallGraph >> applyChosenHeuristics: entity [
×
NEW
23
        "search for a heuristic that could deal with the entity
×
NEW
24
         when found, go to next entity"
×
NEW
25

×
NEW
26
        chosenHeuristics do: [ :heuristic |
×
NEW
27
                (self heuristic: heuristic handle: entity)
×
NEW
28
                        ifTrue: [ ^self ]
×
NEW
29
                ]
×
NEW
30
]
×
31

32
{ #category : 'accessing' }
33
MiDeadCodeBrowserModelWithCallGraph >> availableHeuristics [
×
34

×
35
        ^availableHeuristics ifNil: [
×
36
                availableHeuristics := MiDeadCodeAbstractHeuristic withAllSubclasses
×
37
                        select: [ :class | class isAbstract not ]
×
38
                        thenCollect: [ :class | class new ]
×
39
        ]
×
40
]
×
41

42
{ #category : 'actions' }
43
MiDeadCodeBrowserModelWithCallGraph >> chooseHeuristics: heuristicCollection [
×
44
        "add all of heuristicCollection  to the internal list of chosenHeuristics"
×
45

×
46
        chosenHeuristics := (chosenHeuristics union: heuristicCollection)
×
47
                sort: self heuristicSortBlock.
×
48
        browser updateChosenHeuristics
×
49
]
×
50

51
{ #category : 'accessing' }
52
MiDeadCodeBrowserModelWithCallGraph >> chosenHeuristics [
×
53

×
54
        ^chosenHeuristics 
×
55
]
×
56

57
{ #category : 'actions' }
58
MiDeadCodeBrowserModelWithCallGraph >> clearChosenHeuristics [
×
59

×
60
        chosenHeuristics removeAll
×
61
]
×
62

63
{ #category : 'private' }
64
MiDeadCodeBrowserModelWithCallGraph >> computeCallGraph [
×
65

×
66
        ^(FamixJavaCHABuilder
×
67
                entryPoints: (self entities select: [ :entity | self isEntryPoint: entity ]))
×
68
                build.
×
69

×
70
]
×
71

72
{ #category : 'actions' }
73
MiDeadCodeBrowserModelWithCallGraph >> computeDeadEntitiesFrom: calledEntities [
×
74

×
75
        deadEntities := (OrderedCollection withAll: self entities) \ calledEntities
×
76
]
×
77

78
{ #category : 'settings management' }
79
MiDeadCodeBrowserModelWithCallGraph >> currentConfiguration [
×
80
        "no settings"
×
81
]
×
82

83
{ #category : 'accessing' }
84
MiDeadCodeBrowserModelWithCallGraph >> deadEntities [
×
85

×
86
        ^deadEntities 
×
87
]
×
88

89
{ #category : 'settings management' }
90
MiDeadCodeBrowserModelWithCallGraph >> defaultConfiguration [
×
91
        "no settings"
×
92
]
×
93

94
{ #category : 'accessing' }
95
MiDeadCodeBrowserModelWithCallGraph >> entities [
×
96

×
97
        ^candidateEntities
×
98
]
×
99

100
{ #category : 'actions' }
101
MiDeadCodeBrowserModelWithCallGraph >> firstRoundComputation [
×
102

×
103
        | graph |
×
104
        deadEntities removeAll.
×
105

×
106
        graph := self computeCallGraph.
×
107
        self computeDeadEntitiesFrom: (graph allNodes collect: #realMethod).
×
108

×
109
        browser updateToolbar.
×
110
        browser updateDeadEntities
×
111
]
×
112

113
{ #category : 'actions' }
114
MiDeadCodeBrowserModelWithCallGraph >> followEntity: aCollection [
×
115

×
116
        candidateEntities := aCollection.
×
117
        browser candidateEntities: aCollection.
×
118
        browser updateChosenHeuristics
×
119
]
×
120

121
{ #category : 'actions' }
122
MiDeadCodeBrowserModelWithCallGraph >> graph: graph contains: mth [
×
123

×
124
        ^graph allNodes anySatisfy: [ :node | node realMethod = mth]
×
125
]
×
126

127
{ #category : 'actions' }
128
MiDeadCodeBrowserModelWithCallGraph >> heuristic: heuristic handle: entity [
×
129
        "returns whether a decision was reached or not.
×
130
         A decision is reached for _refuting_ heuristics if the entity is not dead
×
131
           and there is nothing to do (but we do not need to check other heuristics)
×
132
         A decision is reached for _asserting_ heuristic, if the entity is dead
×
133
           and it must be added to the list of dead entities"
×
134

×
135
        heuristic refuteDead 
×
136
                ifTrue: [ (heuristic isDead: entity) ifFalse: [ ^true ] ]
×
137
                ifFalse: [
×
138
                        (heuristic isDead: entity)
×
139
                                ifTrue: [ deadEntities add: entity. ^true ]
×
140
                ].
×
141
        
×
142
        ^false
×
143
]
×
144

145
{ #category : 'actions' }
146
MiDeadCodeBrowserModelWithCallGraph >> heuristicSortBlock [
×
147
        "sorts refuting heuristics before asserting ones.
×
148
         inside these two categories, sort on their names"
×
149

×
150
        ^[ :a :b |
×
151
                (a refuteDead = b refuteDead)
×
152
                        ifTrue: [ a name < b name ]
×
153
                        ifFalse: [ a refuteDead ]
×
154
                ]
×
155
]
×
156

157
{ #category : 'initialization' }
158
MiDeadCodeBrowserModelWithCallGraph >> initialize [ 
×
159

×
160
        super initialize.
×
161

×
162
        self initializeHeuristics.
×
163
        deadEntities := OrderedCollection new.
×
164
        selectedDeadEntities := #()
×
165
]
×
166

167
{ #category : 'initialization' }
168
MiDeadCodeBrowserModelWithCallGraph >> initializeHeuristics [
×
169

×
170
        chosenHeuristics := OrderedCollection new:
×
171
                                    self availableHeuristics size.
×
172
        chosenHeuristics addAll:
×
173
                (self availableHeuristics select: [ :heuristic |
×
174
                         heuristic selectedByDefault ])
×
175
]
×
176

177
{ #category : 'actions' }
178
MiDeadCodeBrowserModelWithCallGraph >> isEntryPoint: entity [
×
179

×
180
        chosenHeuristics do: [ :heuristic |
×
181
                (self heuristic: heuristic handle: entity)
×
182
                        ifTrue: [ heuristic isForEntryPoint 
×
183
                                ifTrue: [ (heuristic accept: entity) ifTrue: [ ^true ] ]
×
184
                        ]
×
185
                ].
×
186
        ^false
×
187
]
×
188

189
{ #category : 'accessing' }
190
MiDeadCodeBrowserModelWithCallGraph >> miSelectedItem [
×
191

×
192
        ^selectedDeadEntities ifEmpty: [ deadEntities ] 
×
193
]
×
194

195
{ #category : 'accessing' }
196
MiDeadCodeBrowserModelWithCallGraph >> miSelectedItems: aCollection [
×
197

×
198
        selectedDeadEntities := aCollection 
×
199
]
×
200

201
{ #category : 'actions' }
202
MiDeadCodeBrowserModelWithCallGraph >> recursionComputation [
×
203

×
204
        UIManager default inform: 'No recursion done'
×
205
]
×
206

207
{ #category : 'settings management' }
208
MiDeadCodeBrowserModelWithCallGraph >> settings [
×
209
        "no settings"
×
210

×
211
]
×
212

213
{ #category : 'actions' }
214
MiDeadCodeBrowserModelWithCallGraph >> unchooseHeuristics: heuristicCollection [
×
215
        "remove all of heuristicCollection from the internal list of chosenHeuristics"
×
216

×
217
        chosenHeuristics removeAll: heuristicCollection.
×
218
        browser updateChosenHeuristics
×
219
]
×
220

221
{ #category : 'settings management' }
222
MiDeadCodeBrowserModelWithCallGraph >> updateFromConfiguration: aConfiguration [
×
223
        "no settings"
×
224
]
×
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