Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16-Check-for-methods-in-traits-already-present-in-a-trait-they-use #61

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
]