2
2
3
3
import cpp
4
4
5
- private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity ( )
5
+ deprecated private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity ( )
6
6
7
7
/**
8
8
* DEPRECATED: This class is no longer used.
9
9
*
10
10
* A token block used for detection of duplicate and similar code.
11
11
*/
12
- class Copy extends TDuplicationOrSimilarity {
12
+ deprecated class Copy extends TDuplicationOrSimilarity {
13
13
/** Gets the index of the token in this block starting at the location `loc`, if any. */
14
14
int tokenStartingAt ( Location loc ) { none ( ) }
15
15
@@ -63,7 +63,7 @@ class Copy extends TDuplicationOrSimilarity {
63
63
*
64
64
* A block of duplicated code.
65
65
*/
66
- class DuplicateBlock extends Copy {
66
+ deprecated class DuplicateBlock extends Copy {
67
67
override string toString ( ) {
68
68
result = "Duplicate code: " + this .sourceLines ( ) + " duplicated lines."
69
69
}
@@ -74,29 +74,37 @@ class DuplicateBlock extends Copy {
74
74
*
75
75
* A block of similar code.
76
76
*/
77
- class SimilarBlock extends Copy {
77
+ deprecated class SimilarBlock extends Copy {
78
78
override string toString ( ) {
79
79
result = "Similar code: " + this .sourceLines ( ) + " almost duplicated lines."
80
80
}
81
81
}
82
82
83
- /** Gets a function with a body and a location. */
84
- FunctionDeclarationEntry sourceMethod ( ) {
83
+ /**
84
+ * DEPRECATED: The `CodeDuplication` library will be removed in a future release.
85
+ *
86
+ * Gets a function with a body and a location.
87
+ */
88
+ deprecated FunctionDeclarationEntry sourceMethod ( ) {
85
89
result .isDefinition ( ) and
86
90
exists ( result .getLocation ( ) ) and
87
91
numlines ( unresolveElement ( result .getFunction ( ) ) , _, _, _)
88
92
}
89
93
90
- /** Gets the number of member functions in `c` with a body and a location. */
91
- int numberOfSourceMethods ( Class c ) {
94
+ /**
95
+ * DEPRECATED: The `CodeDuplication` library will be removed in a future release.
96
+ *
97
+ * Gets the number of member functions in `c` with a body and a location.
98
+ */
99
+ deprecated int numberOfSourceMethods ( Class c ) {
92
100
result =
93
101
count ( FunctionDeclarationEntry m |
94
102
m = sourceMethod ( ) and
95
103
m .getFunction ( ) .getDeclaringType ( ) = c
96
104
)
97
105
}
98
106
99
- private predicate blockCoversStatement ( int equivClass , int first , int last , Stmt stmt ) {
107
+ deprecated private predicate blockCoversStatement ( int equivClass , int first , int last , Stmt stmt ) {
100
108
exists ( DuplicateBlock b , Location loc |
101
109
stmt .getLocation ( ) = loc and
102
110
first = b .tokenStartingAt ( loc ) and
@@ -105,13 +113,13 @@ private predicate blockCoversStatement(int equivClass, int first, int last, Stmt
105
113
)
106
114
}
107
115
108
- private Stmt statementInMethod ( FunctionDeclarationEntry m ) {
116
+ deprecated private Stmt statementInMethod ( FunctionDeclarationEntry m ) {
109
117
result .getParent + ( ) = m .getBlock ( ) and
110
118
not result .getLocation ( ) instanceof UnknownStmtLocation and
111
119
not result instanceof BlockStmt
112
120
}
113
121
114
- private predicate duplicateStatement (
122
+ deprecated private predicate duplicateStatement (
115
123
FunctionDeclarationEntry m1 , FunctionDeclarationEntry m2 , Stmt s1 , Stmt s2
116
124
) {
117
125
exists ( int equivClass , int first , int last |
@@ -125,31 +133,39 @@ private predicate duplicateStatement(
125
133
}
126
134
127
135
/**
136
+ * DEPRECATED: Information on duplicated statements is no longer available.
137
+ *
128
138
* Holds if `m1` is a function with `total` lines, and `m2` is a function
129
139
* that has `duplicate` lines in common with `m1`.
130
140
*/
131
- predicate duplicateStatements (
141
+ deprecated predicate duplicateStatements (
132
142
FunctionDeclarationEntry m1 , FunctionDeclarationEntry m2 , int duplicate , int total
133
143
) {
134
144
duplicate = strictcount ( Stmt s | duplicateStatement ( m1 , m2 , s , _) ) and
135
145
total = strictcount ( statementInMethod ( m1 ) )
136
146
}
137
147
138
- /** Holds if `m` and other are identical functions. */
139
- predicate duplicateMethod ( FunctionDeclarationEntry m , FunctionDeclarationEntry other ) {
148
+ /**
149
+ * DEPRECATED: Information on duplicated methods is no longer available.
150
+ *
151
+ * Holds if `m` and other are identical functions.
152
+ */
153
+ deprecated predicate duplicateMethod ( FunctionDeclarationEntry m , FunctionDeclarationEntry other ) {
140
154
exists ( int total | duplicateStatements ( m , other , total , total ) )
141
155
}
142
156
143
157
/**
158
+ * DEPRECATED: Information on similar lines is no longer available.
159
+ *
144
160
* INTERNAL: do not use.
145
161
*
146
162
* Holds if `line` in `f` is similar to a line somewhere else.
147
163
*/
148
- predicate similarLines ( File f , int line ) {
164
+ deprecated predicate similarLines ( File f , int line ) {
149
165
exists ( SimilarBlock b | b .sourceFile ( ) = f and line in [ b .sourceStartLine ( ) .. b .sourceEndLine ( ) ] )
150
166
}
151
167
152
- private predicate similarLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
168
+ deprecated private predicate similarLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
153
169
lines =
154
170
strictsum ( SimilarBlock b , int toSum |
155
171
( b .sourceFile ( ) = f and b .getEquivalenceClass ( ) = equivClass ) and
@@ -159,7 +175,7 @@ private predicate similarLinesPerEquivalenceClass(int equivClass, int lines, Fil
159
175
)
160
176
}
161
177
162
- private predicate similarLinesCoveredFiles ( File f , File otherFile ) {
178
+ deprecated private predicate similarLinesCoveredFiles ( File f , File otherFile ) {
163
179
exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
164
180
exists ( int coveredApprox |
165
181
coveredApprox =
@@ -175,8 +191,12 @@ private predicate similarLinesCoveredFiles(File f, File otherFile) {
175
191
)
176
192
}
177
193
178
- /** Holds if `coveredLines` lines of `f` are similar to lines in `otherFile`. */
179
- predicate similarLinesCovered ( File f , int coveredLines , File otherFile ) {
194
+ /**
195
+ * DEPRECATED: Information on similar lines is no longer available.
196
+ *
197
+ * Holds if `coveredLines` lines of `f` are similar to lines in `otherFile`.
198
+ */
199
+ deprecated predicate similarLinesCovered ( File f , int coveredLines , File otherFile ) {
180
200
exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
181
201
similarLinesCoveredFiles ( f , otherFile ) and
182
202
exists ( int notCovered |
@@ -191,17 +211,19 @@ predicate similarLinesCovered(File f, int coveredLines, File otherFile) {
191
211
}
192
212
193
213
/**
214
+ * DEPRECATED: Information on duplicate lines is no longer available.
215
+ *
194
216
* INTERNAL: do not use.
195
217
*
196
218
* Holds if `line` in `f` is duplicated by a line somewhere else.
197
219
*/
198
- predicate duplicateLines ( File f , int line ) {
220
+ deprecated predicate duplicateLines ( File f , int line ) {
199
221
exists ( DuplicateBlock b |
200
222
b .sourceFile ( ) = f and line in [ b .sourceStartLine ( ) .. b .sourceEndLine ( ) ]
201
223
)
202
224
}
203
225
204
- private predicate duplicateLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
226
+ deprecated private predicate duplicateLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
205
227
lines =
206
228
strictsum ( DuplicateBlock b , int toSum |
207
229
( b .sourceFile ( ) = f and b .getEquivalenceClass ( ) = equivClass ) and
@@ -211,8 +233,12 @@ private predicate duplicateLinesPerEquivalenceClass(int equivClass, int lines, F
211
233
)
212
234
}
213
235
214
- /** Holds if `coveredLines` lines of `f` are duplicates of lines in `otherFile`. */
215
- predicate duplicateLinesCovered ( File f , int coveredLines , File otherFile ) {
236
+ /**
237
+ * DEPRECATED: Information on duplicate lines is no longer available.
238
+ *
239
+ * Holds if `coveredLines` lines of `f` are duplicates of lines in `otherFile`.
240
+ */
241
+ deprecated predicate duplicateLinesCovered ( File f , int coveredLines , File otherFile ) {
216
242
exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
217
243
exists ( int coveredApprox |
218
244
coveredApprox =
@@ -236,8 +262,12 @@ predicate duplicateLinesCovered(File f, int coveredLines, File otherFile) {
236
262
)
237
263
}
238
264
239
- /** Holds if most of `f` (`percent`%) is similar to `other`. */
240
- predicate similarFiles ( File f , File other , int percent ) {
265
+ /**
266
+ * DEPRECATED: Information on similar files is no longer available.
267
+ *
268
+ * Holds if most of `f` (`percent`%) is similar to `other`.
269
+ */
270
+ deprecated predicate similarFiles ( File f , File other , int percent ) {
241
271
exists ( int covered , int total |
242
272
similarLinesCovered ( f , covered , other ) and
243
273
total = f .getMetrics ( ) .getNumberOfLines ( ) and
@@ -247,8 +277,12 @@ predicate similarFiles(File f, File other, int percent) {
247
277
not duplicateFiles ( f , other , _)
248
278
}
249
279
250
- /** Holds if most of `f` (`percent`%) is duplicated by `other`. */
251
- predicate duplicateFiles ( File f , File other , int percent ) {
280
+ /**
281
+ * DEPRECATED: Information on duplicate files is no longer available.
282
+ *
283
+ * Holds if most of `f` (`percent`%) is duplicated by `other`.
284
+ */
285
+ deprecated predicate duplicateFiles ( File f , File other , int percent ) {
252
286
exists ( int covered , int total |
253
287
duplicateLinesCovered ( f , covered , other ) and
254
288
total = f .getMetrics ( ) .getNumberOfLines ( ) and
@@ -258,10 +292,12 @@ predicate duplicateFiles(File f, File other, int percent) {
258
292
}
259
293
260
294
/**
295
+ * DEPRECATED: Information on duplciate classes is no longer available.
296
+ *
261
297
* Holds if most member functions of `c` (`numDup` out of `total`) are
262
298
* duplicates of member functions in `other`.
263
299
*/
264
- predicate mostlyDuplicateClassBase ( Class c , Class other , int numDup , int total ) {
300
+ deprecated predicate mostlyDuplicateClassBase ( Class c , Class other , int numDup , int total ) {
265
301
numDup =
266
302
strictcount ( FunctionDeclarationEntry m1 |
267
303
exists ( FunctionDeclarationEntry m2 |
@@ -277,11 +313,13 @@ predicate mostlyDuplicateClassBase(Class c, Class other, int numDup, int total)
277
313
}
278
314
279
315
/**
316
+ * DEPRECATED: Information on duplciate classes is no longer available.
317
+ *
280
318
* Holds if most member functions of `c` are duplicates of member functions in
281
319
* `other`. Provides the human-readable `message` to describe the amount of
282
320
* duplication.
283
321
*/
284
- predicate mostlyDuplicateClass ( Class c , Class other , string message ) {
322
+ deprecated predicate mostlyDuplicateClass ( Class c , Class other , string message ) {
285
323
exists ( int numDup , int total |
286
324
mostlyDuplicateClassBase ( c , other , numDup , total ) and
287
325
(
@@ -305,21 +343,31 @@ predicate mostlyDuplicateClass(Class c, Class other, string message) {
305
343
)
306
344
}
307
345
308
- /** Holds if `f` and `other` are similar or duplicates. */
309
- predicate fileLevelDuplication ( File f , File other ) {
346
+ /**
347
+ * DEPRECATED: Information on file duplication is no longer available.
348
+ *
349
+ * Holds if `f` and `other` are similar or duplicates.
350
+ */
351
+ deprecated predicate fileLevelDuplication ( File f , File other ) {
310
352
similarFiles ( f , other , _) or duplicateFiles ( f , other , _)
311
353
}
312
354
313
355
/**
356
+ * DEPRECATED: Information on class duplication is no longer available.
357
+ *
314
358
* Holds if most member functions of `c` are duplicates of member functions in
315
359
* `other`.
316
360
*/
317
- predicate classLevelDuplication ( Class c , Class other ) { mostlyDuplicateClass ( c , other , _) }
361
+ deprecated predicate classLevelDuplication ( Class c , Class other ) {
362
+ mostlyDuplicateClass ( c , other , _)
363
+ }
318
364
319
365
/**
366
+ * DEPRECATED: The CodeDuplication library will be removed in a future release.
367
+ *
320
368
* Holds if `line` in `f` should be allowed to be duplicated. This is the case
321
369
* for `#include` directives.
322
370
*/
323
- predicate whitelistedLineForDuplication ( File f , int line ) {
371
+ deprecated predicate whitelistedLineForDuplication ( File f , int line ) {
324
372
exists ( Include i | i .getFile ( ) = f and i .getLocation ( ) .getStartLine ( ) = line )
325
373
}
0 commit comments