mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #7982 from jketema/remove-legacy-relations
This commit is contained in:
2082
cpp/downgrades/7455933b9d8832b7c385cfca8cf43bddc25b6d0f/old.dbscheme
Normal file
2082
cpp/downgrades/7455933b9d8832b7c385cfca8cf43bddc25b6d0f/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Remove unused legacy relations.
|
||||
compatibility: backwards
|
||||
4
cpp/ql/lib/change-notes/2022-02-11-external-artifact.md
Normal file
4
cpp/ql/lib/change-notes/2022-02-11-external-artifact.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: deprecated
|
||||
---
|
||||
* The `ExternalArtifact.ExternalData` class has been deprecated.
|
||||
12
cpp/ql/lib/external/ExternalArtifact.qll
vendored
12
cpp/ql/lib/external/ExternalArtifact.qll
vendored
@@ -4,12 +4,16 @@
|
||||
|
||||
import cpp
|
||||
|
||||
private newtype TExternalDataElement = MKExternalDataElement()
|
||||
|
||||
/**
|
||||
* DEPRECATED: This class is no longer used.
|
||||
*
|
||||
* An external data item.
|
||||
*/
|
||||
class ExternalData extends @externalDataElement {
|
||||
class ExternalData extends TExternalDataElement {
|
||||
/** Gets the path of the file this data was loaded from. */
|
||||
string getDataPath() { externalData(this, result, _, _) }
|
||||
string getDataPath() { none() }
|
||||
|
||||
/**
|
||||
* Gets the path of the file this data was loaded from, with its
|
||||
@@ -18,10 +22,10 @@ class ExternalData extends @externalDataElement {
|
||||
string getQueryPath() { result = this.getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
|
||||
|
||||
/** Gets the number of fields in this data item. */
|
||||
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
|
||||
int getNumFields() { none() }
|
||||
|
||||
/** Gets the value of the `i`th field of this data item. */
|
||||
string getField(int i) { externalData(this, _, i, result) }
|
||||
string getField(int i) { none() }
|
||||
|
||||
/** Gets the integer value of the `i`th field of this data item. */
|
||||
int getFieldAsInt(int i) { result = this.getField(i).toInt() }
|
||||
|
||||
@@ -122,65 +122,11 @@ compilation_finished(
|
||||
float elapsed_seconds : float ref
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* External data, loaded from CSV files during snapshot creation. See
|
||||
* [Tutorial: Incorporating external data](https://help.semmle.com/wiki/display/SD/Tutorial%3A+Incorporating+external+data)
|
||||
* for more information.
|
||||
*/
|
||||
externalData(
|
||||
int id : @externalDataElement,
|
||||
string path : string ref,
|
||||
int column: int ref,
|
||||
string value : string ref
|
||||
);
|
||||
|
||||
/**
|
||||
* The date of the snapshot.
|
||||
*/
|
||||
snapshotDate(unique date snapshotDate : date ref);
|
||||
|
||||
/**
|
||||
* The source location of the snapshot.
|
||||
*/
|
||||
sourceLocationPrefix(string prefix : string ref);
|
||||
|
||||
/**
|
||||
* Data used by the 'duplicate code' detection.
|
||||
*/
|
||||
duplicateCode(
|
||||
unique int id : @duplication,
|
||||
string relativePath : string ref,
|
||||
int equivClass : int ref
|
||||
);
|
||||
|
||||
/**
|
||||
* Data used by the 'similar code' detection.
|
||||
*/
|
||||
similarCode(
|
||||
unique int id : @similarity,
|
||||
string relativePath : string ref,
|
||||
int equivClass : int ref
|
||||
);
|
||||
|
||||
/**
|
||||
* Data used by the 'duplicate code' and 'similar code' detection.
|
||||
*/
|
||||
@duplication_or_similarity = @duplication | @similarity
|
||||
|
||||
/**
|
||||
* Data used by the 'duplicate code' and 'similar code' detection.
|
||||
*/
|
||||
#keyset[id, offset]
|
||||
tokens(
|
||||
int id : @duplication_or_similarity ref,
|
||||
int offset : int ref,
|
||||
int beginLine : int ref,
|
||||
int beginColumn : int ref,
|
||||
int endLine : int ref,
|
||||
int endColumn : int ref
|
||||
);
|
||||
|
||||
/**
|
||||
* Information about packages that provide code used during compilation.
|
||||
* The `id` is just a unique identifier.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
description: Remove unused legacy relations.
|
||||
compatibility: full
|
||||
externalData.rel: delete
|
||||
snapshotDate.rel: delete
|
||||
duplicateCode.rel: delete
|
||||
similarCode.rel: delete
|
||||
tokens.rel: delete
|
||||
4
cpp/ql/src/change-notes/2022-02-11-code-duplication.md
Normal file
4
cpp/ql/src/change-notes/2022-02-11-code-duplication.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: deprecated
|
||||
---
|
||||
* The `CodeDuplication.Copy`, `CodeDuplication.DuplicateBlock`, and `CodeDuplication.SimilarBlock` classes have been deprecated.
|
||||
65
cpp/ql/src/external/CodeDuplication.qll
vendored
65
cpp/ql/src/external/CodeDuplication.qll
vendored
@@ -2,59 +2,40 @@
|
||||
|
||||
import cpp
|
||||
|
||||
private string relativePath(File file) { result = file.getRelativePath().replaceAll("\\", "/") }
|
||||
|
||||
cached
|
||||
private predicate tokenLocation(string path, int sl, int sc, int ec, int el, Copy copy, int index) {
|
||||
path = copy.sourceFile().getAbsolutePath() and
|
||||
tokens(copy, index, sl, sc, ec, el)
|
||||
}
|
||||
|
||||
/** A token block used for detection of duplicate and similar code. */
|
||||
class Copy extends @duplication_or_similarity {
|
||||
/** Gets the index of the last token in this block. */
|
||||
private int lastToken() { result = max(int i | tokens(this, i, _, _, _, _) | i) }
|
||||
private newtype TDuplicationOrSimilarity = MKDuplicationOrSimilarity()
|
||||
|
||||
/**
|
||||
* DEPRECATED: This class is no longer used.
|
||||
*
|
||||
* A token block used for detection of duplicate and similar code.
|
||||
*/
|
||||
class Copy extends TDuplicationOrSimilarity {
|
||||
/** Gets the index of the token in this block starting at the location `loc`, if any. */
|
||||
int tokenStartingAt(Location loc) {
|
||||
exists(string filepath, int startline, int startcol |
|
||||
loc.hasLocationInfo(filepath, startline, startcol, _, _) and
|
||||
tokenLocation(filepath, startline, startcol, _, _, this, result)
|
||||
)
|
||||
}
|
||||
int tokenStartingAt(Location loc) { none() }
|
||||
|
||||
/** Gets the index of the token in this block ending at the location `loc`, if any. */
|
||||
int tokenEndingAt(Location loc) {
|
||||
exists(string filepath, int endline, int endcol |
|
||||
loc.hasLocationInfo(filepath, _, _, endline, endcol) and
|
||||
tokenLocation(filepath, _, _, endline, endcol, this, result)
|
||||
)
|
||||
}
|
||||
int tokenEndingAt(Location loc) { none() }
|
||||
|
||||
/** Gets the line on which the first token in this block starts. */
|
||||
int sourceStartLine() { tokens(this, 0, result, _, _, _) }
|
||||
int sourceStartLine() { none() }
|
||||
|
||||
/** Gets the column on which the first token in this block starts. */
|
||||
int sourceStartColumn() { tokens(this, 0, _, result, _, _) }
|
||||
int sourceStartColumn() { none() }
|
||||
|
||||
/** Gets the line on which the last token in this block ends. */
|
||||
int sourceEndLine() { tokens(this, this.lastToken(), _, _, result, _) }
|
||||
int sourceEndLine() { none() }
|
||||
|
||||
/** Gets the column on which the last token in this block ends. */
|
||||
int sourceEndColumn() { tokens(this, this.lastToken(), _, _, _, result) }
|
||||
int sourceEndColumn() { none() }
|
||||
|
||||
/** Gets the number of lines containing at least (part of) one token in this block. */
|
||||
int sourceLines() { result = this.sourceEndLine() + 1 - this.sourceStartLine() }
|
||||
|
||||
/** Gets an opaque identifier for the equivalence class of this block. */
|
||||
int getEquivalenceClass() { duplicateCode(this, _, result) or similarCode(this, _, result) }
|
||||
int getEquivalenceClass() { none() }
|
||||
|
||||
/** Gets the source file in which this block appears. */
|
||||
File sourceFile() {
|
||||
exists(string name | duplicateCode(this, name, _) or similarCode(this, name, _) |
|
||||
name.replaceAll("\\", "/") = relativePath(result)
|
||||
)
|
||||
}
|
||||
File sourceFile() { none() }
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
@@ -77,15 +58,23 @@ class Copy extends @duplication_or_similarity {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
/** A block of duplicated code. */
|
||||
class DuplicateBlock extends Copy, @duplication {
|
||||
/**
|
||||
* DEPRECATED: This class is no longer used.
|
||||
*
|
||||
* A block of duplicated code.
|
||||
*/
|
||||
class DuplicateBlock extends Copy {
|
||||
override string toString() {
|
||||
result = "Duplicate code: " + this.sourceLines() + " duplicated lines."
|
||||
}
|
||||
}
|
||||
|
||||
/** A block of similar code. */
|
||||
class SimilarBlock extends Copy, @similarity {
|
||||
/**
|
||||
* DEPRECATED: This class is no longer used.
|
||||
*
|
||||
* A block of similar code.
|
||||
*/
|
||||
class SimilarBlock extends Copy {
|
||||
override string toString() {
|
||||
result = "Similar code: " + this.sourceLines() + " almost duplicated lines."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user