22
33import cpp
44
5- private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity ( )
5+ deprecated private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity ( )
66
77/**
88 * DEPRECATED: This class is no longer used.
99 *
1010 * A token block used for detection of duplicate and similar code.
1111 */
12- class Copy extends TDuplicationOrSimilarity {
12+ deprecated class Copy extends TDuplicationOrSimilarity {
1313 /** Gets the index of the token in this block starting at the location `loc`, if any. */
1414 int tokenStartingAt ( Location loc ) { none ( ) }
1515
@@ -63,7 +63,7 @@ class Copy extends TDuplicationOrSimilarity {
6363 *
6464 * A block of duplicated code.
6565 */
66- class DuplicateBlock extends Copy {
66+ deprecated class DuplicateBlock extends Copy {
6767 override string toString ( ) {
6868 result = "Duplicate code: " + this .sourceLines ( ) + " duplicated lines."
6969 }
@@ -74,29 +74,37 @@ class DuplicateBlock extends Copy {
7474 *
7575 * A block of similar code.
7676 */
77- class SimilarBlock extends Copy {
77+ deprecated class SimilarBlock extends Copy {
7878 override string toString ( ) {
7979 result = "Similar code: " + this .sourceLines ( ) + " almost duplicated lines."
8080 }
8181}
8282
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 ( ) {
8589 result .isDefinition ( ) and
8690 exists ( result .getLocation ( ) ) and
8791 numlines ( unresolveElement ( result .getFunction ( ) ) , _, _, _)
8892}
8993
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 ) {
92100 result =
93101 count ( FunctionDeclarationEntry m |
94102 m = sourceMethod ( ) and
95103 m .getFunction ( ) .getDeclaringType ( ) = c
96104 )
97105}
98106
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 ) {
100108 exists ( DuplicateBlock b , Location loc |
101109 stmt .getLocation ( ) = loc and
102110 first = b .tokenStartingAt ( loc ) and
@@ -105,13 +113,13 @@ private predicate blockCoversStatement(int equivClass, int first, int last, Stmt
105113 )
106114}
107115
108- private Stmt statementInMethod ( FunctionDeclarationEntry m ) {
116+ deprecated private Stmt statementInMethod ( FunctionDeclarationEntry m ) {
109117 result .getParent + ( ) = m .getBlock ( ) and
110118 not result .getLocation ( ) instanceof UnknownStmtLocation and
111119 not result instanceof BlockStmt
112120}
113121
114- private predicate duplicateStatement (
122+ deprecated private predicate duplicateStatement (
115123 FunctionDeclarationEntry m1 , FunctionDeclarationEntry m2 , Stmt s1 , Stmt s2
116124) {
117125 exists ( int equivClass , int first , int last |
@@ -125,31 +133,39 @@ private predicate duplicateStatement(
125133}
126134
127135/**
136+ * DEPRECATED: Information on duplicated statements is no longer available.
137+ *
128138 * Holds if `m1` is a function with `total` lines, and `m2` is a function
129139 * that has `duplicate` lines in common with `m1`.
130140 */
131- predicate duplicateStatements (
141+ deprecated predicate duplicateStatements (
132142 FunctionDeclarationEntry m1 , FunctionDeclarationEntry m2 , int duplicate , int total
133143) {
134144 duplicate = strictcount ( Stmt s | duplicateStatement ( m1 , m2 , s , _) ) and
135145 total = strictcount ( statementInMethod ( m1 ) )
136146}
137147
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 ) {
140154 exists ( int total | duplicateStatements ( m , other , total , total ) )
141155}
142156
143157/**
158+ * DEPRECATED: Information on similar lines is no longer available.
159+ *
144160 * INTERNAL: do not use.
145161 *
146162 * Holds if `line` in `f` is similar to a line somewhere else.
147163 */
148- predicate similarLines ( File f , int line ) {
164+ deprecated predicate similarLines ( File f , int line ) {
149165 exists ( SimilarBlock b | b .sourceFile ( ) = f and line in [ b .sourceStartLine ( ) .. b .sourceEndLine ( ) ] )
150166}
151167
152- private predicate similarLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
168+ deprecated private predicate similarLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
153169 lines =
154170 strictsum ( SimilarBlock b , int toSum |
155171 ( b .sourceFile ( ) = f and b .getEquivalenceClass ( ) = equivClass ) and
@@ -159,7 +175,7 @@ private predicate similarLinesPerEquivalenceClass(int equivClass, int lines, Fil
159175 )
160176}
161177
162- private predicate similarLinesCoveredFiles ( File f , File otherFile ) {
178+ deprecated private predicate similarLinesCoveredFiles ( File f , File otherFile ) {
163179 exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
164180 exists ( int coveredApprox |
165181 coveredApprox =
@@ -175,8 +191,12 @@ private predicate similarLinesCoveredFiles(File f, File otherFile) {
175191 )
176192}
177193
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 ) {
180200 exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
181201 similarLinesCoveredFiles ( f , otherFile ) and
182202 exists ( int notCovered |
@@ -191,17 +211,19 @@ predicate similarLinesCovered(File f, int coveredLines, File otherFile) {
191211}
192212
193213/**
214+ * DEPRECATED: Information on duplicate lines is no longer available.
215+ *
194216 * INTERNAL: do not use.
195217 *
196218 * Holds if `line` in `f` is duplicated by a line somewhere else.
197219 */
198- predicate duplicateLines ( File f , int line ) {
220+ deprecated predicate duplicateLines ( File f , int line ) {
199221 exists ( DuplicateBlock b |
200222 b .sourceFile ( ) = f and line in [ b .sourceStartLine ( ) .. b .sourceEndLine ( ) ]
201223 )
202224}
203225
204- private predicate duplicateLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
226+ deprecated private predicate duplicateLinesPerEquivalenceClass ( int equivClass , int lines , File f ) {
205227 lines =
206228 strictsum ( DuplicateBlock b , int toSum |
207229 ( b .sourceFile ( ) = f and b .getEquivalenceClass ( ) = equivClass ) and
@@ -211,8 +233,12 @@ private predicate duplicateLinesPerEquivalenceClass(int equivClass, int lines, F
211233 )
212234}
213235
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 ) {
216242 exists ( int numLines | numLines = f .getMetrics ( ) .getNumberOfLines ( ) |
217243 exists ( int coveredApprox |
218244 coveredApprox =
@@ -236,8 +262,12 @@ predicate duplicateLinesCovered(File f, int coveredLines, File otherFile) {
236262 )
237263}
238264
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 ) {
241271 exists ( int covered , int total |
242272 similarLinesCovered ( f , covered , other ) and
243273 total = f .getMetrics ( ) .getNumberOfLines ( ) and
@@ -247,8 +277,12 @@ predicate similarFiles(File f, File other, int percent) {
247277 not duplicateFiles ( f , other , _)
248278}
249279
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 ) {
252286 exists ( int covered , int total |
253287 duplicateLinesCovered ( f , covered , other ) and
254288 total = f .getMetrics ( ) .getNumberOfLines ( ) and
@@ -258,10 +292,12 @@ predicate duplicateFiles(File f, File other, int percent) {
258292}
259293
260294/**
295+ * DEPRECATED: Information on duplciate classes is no longer available.
296+ *
261297 * Holds if most member functions of `c` (`numDup` out of `total`) are
262298 * duplicates of member functions in `other`.
263299 */
264- predicate mostlyDuplicateClassBase ( Class c , Class other , int numDup , int total ) {
300+ deprecated predicate mostlyDuplicateClassBase ( Class c , Class other , int numDup , int total ) {
265301 numDup =
266302 strictcount ( FunctionDeclarationEntry m1 |
267303 exists ( FunctionDeclarationEntry m2 |
@@ -277,11 +313,13 @@ predicate mostlyDuplicateClassBase(Class c, Class other, int numDup, int total)
277313}
278314
279315/**
316+ * DEPRECATED: Information on duplciate classes is no longer available.
317+ *
280318 * Holds if most member functions of `c` are duplicates of member functions in
281319 * `other`. Provides the human-readable `message` to describe the amount of
282320 * duplication.
283321 */
284- predicate mostlyDuplicateClass ( Class c , Class other , string message ) {
322+ deprecated predicate mostlyDuplicateClass ( Class c , Class other , string message ) {
285323 exists ( int numDup , int total |
286324 mostlyDuplicateClassBase ( c , other , numDup , total ) and
287325 (
@@ -305,21 +343,31 @@ predicate mostlyDuplicateClass(Class c, Class other, string message) {
305343 )
306344}
307345
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 ) {
310352 similarFiles ( f , other , _) or duplicateFiles ( f , other , _)
311353}
312354
313355/**
356+ * DEPRECATED: Information on class duplication is no longer available.
357+ *
314358 * Holds if most member functions of `c` are duplicates of member functions in
315359 * `other`.
316360 */
317- predicate classLevelDuplication ( Class c , Class other ) { mostlyDuplicateClass ( c , other , _) }
361+ deprecated predicate classLevelDuplication ( Class c , Class other ) {
362+ mostlyDuplicateClass ( c , other , _)
363+ }
318364
319365/**
366+ * DEPRECATED: The CodeDuplication library will be removed in a future release.
367+ *
320368 * Holds if `line` in `f` should be allowed to be duplicated. This is the case
321369 * for `#include` directives.
322370 */
323- predicate whitelistedLineForDuplication ( File f , int line ) {
371+ deprecated predicate whitelistedLineForDuplication ( File f , int line ) {
324372 exists ( Include i | i .getFile ( ) = f and i .getLocation ( ) .getStartLine ( ) = line )
325373}
0 commit comments