mirror of
https://github.com/github/codeql.git
synced 2026-05-03 20:58:03 +02:00
Migrate Java code to separate QL repo.
This commit is contained in:
30
java/ql/src/external/MostlyDuplicateMethod.ql
vendored
Normal file
30
java/ql/src/external/MostlyDuplicateMethod.ql
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @name Mostly duplicate method
|
||||
* @description Methods in which most of the lines are duplicated in another method make code more
|
||||
* difficult to understand and introduce a risk of changes being made to only one copy.
|
||||
* @kind problem
|
||||
* @problem.severity recommendation
|
||||
* @precision high
|
||||
* @id java/similar-method
|
||||
* @tags testability
|
||||
* maintainability
|
||||
* useless-code
|
||||
* duplicate-code
|
||||
* statistical
|
||||
* non-attributable
|
||||
*/
|
||||
import java
|
||||
import CodeDuplication
|
||||
|
||||
from Method m, int covered, int total, Method other, int percent
|
||||
where
|
||||
duplicateStatements(m, other, covered, total) and
|
||||
covered != total and
|
||||
m.getMetrics().getNumberOfLinesOfCode() > 5 and
|
||||
covered * 100 / total = percent and
|
||||
percent > 80 and
|
||||
not duplicateMethod(m, other) and
|
||||
not classLevelDuplication(m.getDeclaringType(), other.getDeclaringType()) and
|
||||
not fileLevelDuplication(m.getCompilationUnit(), other.getCompilationUnit())
|
||||
select m, percent + "% of the statements in " + m.getName() + " are duplicated in $@.",
|
||||
other, other.getDeclaringType().getName() + "." + other.getStringSignature()
|
||||
Reference in New Issue
Block a user