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

moosetechnology / MooseIDE / 21818695493

09 Feb 2026 09:02AM UTC coverage: 65.926% (+0.1%) from 65.829%
21818695493

push

github

web-flow
Merge pull request #1588 from moosetechnology/dead-code-heuristic-groups

Dead code heuristic groups

508 of 568 new or added lines in 21 files covered. (89.44%)

21882 of 33192 relevant lines covered (65.93%)

1.32 hits per line

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

8.0
/src/MooseIDE-DeadCode/MiDeadJavaInitializerRule.class.st
1
"
2
In Java, the default constructor is invoked by any other constructor, and the initialization block is invoked by all constructors.
3

4
So if any of the other constructors is not dead, then these ones are not-dead either.
5
But rules cannot model this, so we just assume they are not-dead by default
6
"
7
Class {
8
        #name : 'MiDeadJavaInitializerRule',
9
        #superclass : 'MiDeadAbstractJavaRule',
10
        #category : 'MooseIDE-DeadCode-Rules',
11
        #package : 'MooseIDE-DeadCode',
12
        #tag : 'Rules'
13
}
14

15
{ #category : 'visiting' }
NEW
16
MiDeadJavaInitializerRule >> accept: aTMethod [
×
17

×
18
        ^self notDead: aTMethod 
×
19
]
×
20

21
{ #category : 'testing' }
NEW
22
MiDeadJavaInitializerRule >> classHasNonDefaultConstructor: aClass [
×
23

×
24
        aClass methods
×
25
                detect: [ :m | m isConstructor and: [ m parameters isNotEmpty ] ]
×
26
                ifOne: [ :nonDefaultConstructor | ^true ]
×
27
                ifNone: [ ^false ]
×
28

×
29
]
×
30

31
{ #category : 'accessing' }
NEW
32
MiDeadJavaInitializerRule >> description [
×
33

×
34
        ^super description ,
×
35
        'Default constructor and initialization block are assumed not-dead'
×
36
]
×
37

38
{ #category : 'testing' }
NEW
39
MiDeadJavaInitializerRule >> isDefaultConstructorWithOtherConstructors: aTMethod [
×
40
        "the default constructor (no parameter) is always called by any other constructor
×
41
         Note: assumes but does not check that the other constructor is itself called"
×
42

×
43
        aTMethod isConstructor ifFalse: [ ^false ].
×
44
        aTMethod parameters isEmpty ifFalse: [ ^false ].
×
45
        ^self classHasNonDefaultConstructor: aTMethod parentType
×
46

×
47
]
×
48

49
{ #category : 'accessing' }
NEW
50
MiDeadJavaInitializerRule >> isForEntryPoint [
×
51

×
52
        ^true
×
53
]
×
54

55
{ #category : 'testing' }
NEW
56
MiDeadJavaInitializerRule >> isInitializerBlock: aTMethod [
×
57

×
58
        ^aTMethod name = '<Initializer>'
×
59
]
×
60

61
{ #category : 'accessing' }
62
MiDeadJavaInitializerRule >> name [
2✔
63

2✔
64
        ^super name , 'Defautl constructor/Initialization block'
2✔
65
]
2✔
66

67
{ #category : 'testing' }
NEW
68
MiDeadJavaInitializerRule >> notDead: aTMethod [
×
69

×
70
        | parentType |
×
71
        parentType := aTMethod parentType.
×
72

×
73
        ^(self isInitializerBlock: aTMethod ) or:
×
74
        [  self isDefaultConstructorWithOtherConstructors: aTMethod ]
×
75
        "[ (aTMethod name = parentType name) and:
×
76
                [ (aTMethod parameters isEmpty) and: 
×
77
                 [parentType methods count: [ :m | m name = aTMethod parentType name ]] ]]
×
78
"
×
79
]
×
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