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

moosetechnology / MooseIDE / 19070766961

04 Nov 2025 01:46PM UTC coverage: 65.821% (-0.07%) from 65.89%
19070766961

push

github

web-flow
Merge pull request #1507 from moosetechnology/dead-code-heuristics

Dead code heuristics

38 of 66 new or added lines in 2 files covered. (57.58%)

14 existing lines in 2 files now uncovered.

21195 of 32201 relevant lines covered (65.82%)

1.32 hits per line

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

21.43
/src/MooseIDE-DeadCode/MiDeadCodeJavaInitializerHeuristic.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 : 'MiDeadCodeJavaInitializerHeuristic',
9
        #superclass : 'MiDeadCodeAbstractJavaHeuristic',
10
        #category : 'MooseIDE-DeadCode',
11
        #package : 'MooseIDE-DeadCode'
12
}
13

14
{ #category : 'testing' }
NEW
15
MiDeadCodeJavaInitializerHeuristic >> classHasNonDefaultConstructor: aClass [
×
NEW
16

×
NEW
17
        aClass methods
×
NEW
18
                detect: [ :m | m isConstructor and: [ m parameters isNotEmpty ] ]
×
NEW
19
                ifOne: [ :nonDefaultConstructor | ^true ]
×
NEW
20
                ifNone: [ ^false ]
×
NEW
21

×
NEW
22
]
×
23

24
{ #category : 'accessing' }
25
MiDeadCodeJavaInitializerHeuristic >> description [
2✔
26

2✔
27
        ^super description ,
2✔
28
        'Default constructor and initialization block are assumed not-dead'
2✔
29
]
2✔
30

31
{ #category : 'testing' }
NEW
32
MiDeadCodeJavaInitializerHeuristic >> isDefaultConstructorWithOtherConstructors: aTMethod [
×
NEW
33
        "the default constructor (no parameter) is always called by any other constructor
×
NEW
34
         Note: assumes but does not check that the other constructor is itself called"
×
NEW
35

×
NEW
36
        aTMethod isConstructor ifFalse: [ ^false ].
×
NEW
37
        aTMethod parameters isEmpty ifFalse: [ ^false ].
×
NEW
38
        ^self classHasNonDefaultConstructor: aTMethod parentType
×
NEW
39

×
NEW
40
]
×
41

42
{ #category : 'testing' }
NEW
43
MiDeadCodeJavaInitializerHeuristic >> isInitializerBlock: aTMethod [
×
NEW
44

×
NEW
45
        ^aTMethod name = '<Initializer>'
×
UNCOV
46
]
×
47

48
{ #category : 'accessing' }
49
MiDeadCodeJavaInitializerHeuristic >> name [
2✔
50

2✔
51
        ^super name , 'Defautl constructor/Initialization block'
2✔
52
]
2✔
53

54
{ #category : 'testing' }
55
MiDeadCodeJavaInitializerHeuristic >> notDead: aTMethod [
×
56

×
NEW
57
        | parentType |
×
NEW
58
        parentType := aTMethod parentType.
×
59

×
NEW
60
        ^(self isInitializerBlock: aTMethod ) or:
×
NEW
61
        [  self isDefaultConstructorWithOtherConstructors: aTMethod ]
×
NEW
62
        "[ (aTMethod name = parentType name) and:
×
NEW
63
                [ (aTMethod parameters isEmpty) and: 
×
NEW
64
                 [parentType methods count: [ :m | m name = aTMethod parentType name ]] ]]
×
NEW
65
"
×
UNCOV
66
]
×
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