mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Python: Autoformat all .ql files.
This commit is contained in:
22
python/ql/src/external/DuplicateBlock.ql
vendored
22
python/ql/src/external/DuplicateBlock.ql
vendored
@@ -14,21 +14,21 @@
|
||||
* @precision medium
|
||||
* @id py/duplicate-block
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
predicate sorted_by_location(DuplicateBlock x, DuplicateBlock y) {
|
||||
if x.sourceFile() = y.sourceFile() then
|
||||
x.sourceStartLine() < y.sourceStartLine()
|
||||
else
|
||||
x.sourceFile().getAbsolutePath() < y.sourceFile().getAbsolutePath()
|
||||
if x.sourceFile() = y.sourceFile()
|
||||
then x.sourceStartLine() < y.sourceStartLine()
|
||||
else x.sourceFile().getAbsolutePath() < y.sourceFile().getAbsolutePath()
|
||||
}
|
||||
|
||||
from DuplicateBlock d, DuplicateBlock other
|
||||
where d.sourceLines() > 10 and
|
||||
other.getEquivalenceClass() = d.getEquivalenceClass() and
|
||||
sorted_by_location(other, d)
|
||||
select
|
||||
d,
|
||||
"Duplicate code: " + d.sourceLines() + " lines are duplicated at " +
|
||||
other.sourceFile().getShortName() + ":" + other.sourceStartLine().toString()
|
||||
where
|
||||
d.sourceLines() > 10 and
|
||||
other.getEquivalenceClass() = d.getEquivalenceClass() and
|
||||
sorted_by_location(other, d)
|
||||
select d,
|
||||
"Duplicate code: " + d.sourceLines() + " lines are duplicated at " +
|
||||
other.sourceFile().getShortName() + ":" + other.sourceStartLine().toString()
|
||||
|
||||
20
python/ql/src/external/DuplicateFunction.ql
vendored
20
python/ql/src/external/DuplicateFunction.ql
vendored
@@ -13,19 +13,17 @@
|
||||
* @precision high
|
||||
* @id py/duplicate-function
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
predicate relevant(Function m) {
|
||||
m.getMetrics().getNumberOfLinesOfCode() > 5
|
||||
}
|
||||
predicate relevant(Function m) { m.getMetrics().getNumberOfLinesOfCode() > 5 }
|
||||
|
||||
from Function m, Function other, string message, int percent
|
||||
where duplicateScopes(m, other, percent, message)
|
||||
and relevant(m)
|
||||
and percent > 95.0
|
||||
and not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _)
|
||||
and not duplicateScopes(m.getScope(), other.getScope(), _, _)
|
||||
select m, message,
|
||||
other,
|
||||
other.getName()
|
||||
where
|
||||
duplicateScopes(m, other, percent, message) and
|
||||
relevant(m) and
|
||||
percent > 95.0 and
|
||||
not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _) and
|
||||
not duplicateScopes(m.getScope(), other.getScope(), _, _)
|
||||
select m, message, other, other.getName()
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
* @precision high
|
||||
* @id py/mostly-duplicate-class
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
from Class c, Class other, string message
|
||||
where duplicateScopes(c, other, _, message)
|
||||
and count(c.getAStmt()) > 3
|
||||
and not duplicateScopes(c.getEnclosingModule(), _, _, _)
|
||||
where
|
||||
duplicateScopes(c, other, _, message) and
|
||||
count(c.getAStmt()) > 3 and
|
||||
not duplicateScopes(c.getEnclosingModule(), _, _, _)
|
||||
select c, message, other, other.getName()
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* @precision high
|
||||
* @id py/mostly-duplicate-file
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
|
||||
2
python/ql/src/external/MostlySimilarFile.ql
vendored
2
python/ql/src/external/MostlySimilarFile.ql
vendored
@@ -9,11 +9,11 @@
|
||||
* duplicate-code
|
||||
* statistical
|
||||
* non-attributable
|
||||
* @problem.severity recommendation
|
||||
* @sub-severity low
|
||||
* @precision high
|
||||
* @id py/mostly-similar-file
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
|
||||
15
python/ql/src/external/SimilarFunction.ql
vendored
15
python/ql/src/external/SimilarFunction.ql
vendored
@@ -13,23 +13,18 @@
|
||||
* @precision very-high
|
||||
* @id py/similar-function
|
||||
*/
|
||||
|
||||
import python
|
||||
import CodeDuplication
|
||||
|
||||
predicate relevant(Function m) {
|
||||
m.getMetrics().getNumberOfLinesOfCode() > 10
|
||||
}
|
||||
predicate relevant(Function m) { m.getMetrics().getNumberOfLinesOfCode() > 10 }
|
||||
|
||||
from Function m, Function other, string message, int percent
|
||||
where similarScopes(m, other, percent, message) and
|
||||
where
|
||||
similarScopes(m, other, percent, message) and
|
||||
relevant(m) and
|
||||
percent > 95.0 and
|
||||
not duplicateScopes(m, other, _, _) and
|
||||
not duplicateScopes(m.getEnclosingModule(), other.getEnclosingModule(), _, _) and
|
||||
not duplicateScopes(m.getScope(), other.getScope(), _, _)
|
||||
select m, message,
|
||||
other,
|
||||
other.getName()
|
||||
|
||||
|
||||
|
||||
select m, message, other, other.getName()
|
||||
|
||||
Reference in New Issue
Block a user