Skip to content

Commit 40faa63

Browse files
committed
Add a cleaner for FamixPythonModel and FamixReplication
Fixes moosetechnology/MooseIDE#1467
1 parent 52429ae commit 40faa63

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/Famix-Python-Entities/FamixPythonModel.class.st

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,13 @@ FamixPythonModel class >> importingContextClass [
3333
<generated>
3434
^ FamixPythonImportingContext
3535
]
36+
37+
{ #category : 'replication' }
38+
FamixPythonModel >> defaultDetectionConfiguration [
39+
40+
^ FamixRepConfiguration
41+
sourcesCleaner: FamixRepPythonCleaner new
42+
minimumNumberOfReplicas: 2
43+
ofLines: 10
44+
ofCharacters: 80
45+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"
2+
I am a cleaner used by FamixReplication to detect duplicated code in Python code
3+
"
4+
Class {
5+
#name : 'FamixRepPythonCleaner',
6+
#superclass : 'FamixRepPairedCommentsCleaner',
7+
#category : 'Famix-Python-Entities-Replication',
8+
#package : 'Famix-Python-Entities',
9+
#tag : 'Replication'
10+
}
11+
12+
{ #category : 'accessing' }
13+
FamixRepPythonCleaner class >> description [
14+
15+
^ 'Clearner for Python language'
16+
]
17+
18+
{ #category : 'displaying' }
19+
FamixRepPythonCleaner class >> displayStringOn: aStream [
20+
21+
aStream << 'Python comments'
22+
]
23+
24+
{ #category : 'private' }
25+
FamixRepPythonCleaner >> cleanLine: aText [
26+
"a++ //asd -> a++"
27+
28+
^ (super cleanLine: aText) copyUpToSubString: '//'
29+
]
30+
31+
{ #category : 'private' }
32+
FamixRepPythonCleaner >> isComment: aLine [
33+
"we could have defined this method
34+
but just returning false because a comment line will be empty because cleaner removes everything within double qoutes and hence not considered by the detector"
35+
36+
^ false
37+
]
38+
39+
{ #category : 'actions' }
40+
FamixRepPythonCleaner >> multilineCommentCloser [
41+
42+
^ '"""'
43+
]
44+
45+
{ #category : 'actions' }
46+
FamixRepPythonCleaner >> multilineCommentOpener [
47+
48+
^ '"""'
49+
]

0 commit comments

Comments
 (0)