Skip to content

Commit

Permalink
Merge pull request #61 from jecisc/16-Check-for-methods-in-traits-alr…
Browse files Browse the repository at this point in the history
…eady-present-in-a-trait-they-use

16-Check-for-methods-in-traits-already-present-in-a-trait-they-use
  • Loading branch information
jecisc authored May 1, 2020
2 parents a4443f2 + db07c6a commit c34fc39
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions resources/doc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ This might remove methods that were intentionally created with the flaw for test

### Remove duplicated methods from traits

If methods present on traits are duplicated in a classe using the trait, Chanel removes the duplicated version.
If methods present on traits are duplicated in a classe or a trait using the trait, Chanel removes the duplicated version.

*Conditions for the cleanings to by applied:*
- The class of the method needs to use at least on trait
- The class or trait of the method needs to use at least on trait
- The method should have another method in the trait composition with the same name and the same AST.

*Warnings:*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,27 @@ ChanelDuplicatedMethodFromTraitCleanerTest >> testRemoveDuplicatedMethodFromTrai
self assert: (trait class localSelectors includes: #one).
self deny: (class class localSelectors includes: #one)
]

{ #category : #tests }
ChanelDuplicatedMethodFromTraitCleanerTest >> testRemoveDuplicatedMethodFromTraitUsingTrait [
| trait2 |
trait2 := self createTraitNamed: 'SecondTrait'.
trait setTraitComposition: trait2.
class setTraitComposition: trait.

trait2
compile:
'one
^ #one'.

trait
compile:
'one
^ #one'.

self runCleaner.

self assert: (trait2 localSelectors includes: #one).
self deny: (trait localSelectors includes: #one).
self deny: (class localSelectors includes: #one)
]
1 change: 0 additions & 1 deletion src/Chanel/ChanelDuplicatedMethodFromTraitCleaner.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ChanelDuplicatedMethodFromTraitCleaner class >> priority [
{ #category : #cleaning }
ChanelDuplicatedMethodFromTraitCleaner >> clean [
self configuration definedClasses iterator
| #isTrait rejectIt
| #hasTraitComposition selectIt
> #removeDuplicatedMethodsFromTrait doIt
]

0 comments on commit c34fc39

Please sign in to comment.