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

moosetechnology / MooseIDE / 19293949353

12 Nov 2025 10:15AM UTC coverage: 65.543% (-0.3%) from 65.828%
19293949353

push

github

web-flow
Merge pull request #1516 from moosetechnology/dead-code-java-rules

Dead code java rules

142 of 325 new or added lines in 10 files covered. (43.69%)

21293 of 32487 relevant lines covered (65.54%)

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 : 'accessing' }
NEW
22
MiDeadCodeBrowserModelWithCallGraph >> availableHeuristics [
×
NEW
23

×
NEW
24
        ^availableHeuristics ifNil: [
×
NEW
25
                availableHeuristics := MiDeadCodeAbstractHeuristic withAllSubclasses
×
NEW
26
                        select: [ :class | class isAbstract not ]
×
NEW
27
                        thenCollect: [ :class | class new ]
×
NEW
28
        ]
×
NEW
29
]
×
30

31
{ #category : 'actions' }
NEW
32
MiDeadCodeBrowserModelWithCallGraph >> chooseHeuristics: heuristicCollection [
×
NEW
33
        "add all of heuristicCollection  to the internal list of chosenHeuristics"
×
NEW
34

×
NEW
35
        chosenHeuristics := (chosenHeuristics union: heuristicCollection)
×
NEW
36
                sort: self heuristicSortBlock.
×
NEW
37
        browser updateChosenHeuristics
×
NEW
38
]
×
39

40
{ #category : 'accessing' }
NEW
41
MiDeadCodeBrowserModelWithCallGraph >> chosenHeuristics [
×
NEW
42

×
NEW
43
        ^chosenHeuristics 
×
NEW
44
]
×
45

46
{ #category : 'actions' }
NEW
47
MiDeadCodeBrowserModelWithCallGraph >> clearChosenHeuristics [
×
NEW
48

×
NEW
49
        chosenHeuristics removeAll
×
NEW
50
]
×
51

52
{ #category : 'private' }
NEW
53
MiDeadCodeBrowserModelWithCallGraph >> computeCallGraph [
×
NEW
54

×
NEW
55
        ^(FamixJavaCHABuilder
×
NEW
56
                entryPoints: (self entities select: [ :entity | self isEntryPoint: entity ]))
×
NEW
57
                build.
×
NEW
58

×
NEW
59
]
×
60

61
{ #category : 'actions' }
NEW
62
MiDeadCodeBrowserModelWithCallGraph >> computeDeadEntitiesFrom: calledEntities [
×
NEW
63

×
NEW
64
        deadEntities := (OrderedCollection withAll: self entities) \ calledEntities
×
NEW
65
]
×
66

67
{ #category : 'settings management' }
NEW
68
MiDeadCodeBrowserModelWithCallGraph >> currentConfiguration [
×
NEW
69
        "no settings"
×
NEW
70
]
×
71

72
{ #category : 'accessing' }
NEW
73
MiDeadCodeBrowserModelWithCallGraph >> deadEntities [
×
NEW
74

×
NEW
75
        ^deadEntities 
×
NEW
76
]
×
77

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

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

×
NEW
86
        ^candidateEntities
×
NEW
87
]
×
88

89
{ #category : 'actions' }
NEW
90
MiDeadCodeBrowserModelWithCallGraph >> firstRoundComputation [
×
NEW
91

×
NEW
92
        | graph |
×
NEW
93
        deadEntities removeAll.
×
NEW
94

×
NEW
95
        graph := self computeCallGraph.
×
NEW
96
        self computeDeadEntitiesFrom: (graph allNodes collect: #realMethod).
×
NEW
97

×
NEW
98
        browser updateToolbar.
×
NEW
99
        browser updateDeadEntities
×
NEW
100
]
×
101

102
{ #category : 'actions' }
NEW
103
MiDeadCodeBrowserModelWithCallGraph >> firstRoundOn: entity [
×
NEW
104
        "search for a heuristic that could deal with the entity
×
NEW
105
         when found, go to next entity"
×
NEW
106

×
NEW
107
        chosenHeuristics do: [ :heuristic |
×
NEW
108
                (self heuristic: heuristic handle: entity)
×
NEW
109
                        ifTrue: [ ^self ]
×
NEW
110
                ]
×
NEW
111
]
×
112

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

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

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

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

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

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

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

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

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

×
NEW
160
        super initialize.
×
NEW
161

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

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

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

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

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

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

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

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

×
NEW
198
        selectedDeadEntities := aCollection 
×
NEW
199
]
×
200

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

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

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

×
NEW
211
]
×
212

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

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

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