mirror of
https://github.com/github/codeql.git
synced 2026-01-04 02:00:18 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
33 lines
711 B
Plaintext
33 lines
711 B
Plaintext
/**
|
|
* @name Unnecessary pass
|
|
* @description Unnecessary 'pass' statement
|
|
* @kind problem
|
|
* @tags maintainability
|
|
* useless-code
|
|
* @problem.severity warning
|
|
* @sub-severity low
|
|
* @precision very-high
|
|
* @id py/unnecessary-pass
|
|
*/
|
|
|
|
import python
|
|
|
|
predicate is_doc_string(ExprStmt s) {
|
|
s.getValue() instanceof Unicode or s.getValue() instanceof Bytes
|
|
}
|
|
|
|
predicate has_doc_string(StmtList stmts) {
|
|
stmts.getParent() instanceof Scope and
|
|
is_doc_string(stmts.getItem(0))
|
|
}
|
|
|
|
from Pass p, StmtList list
|
|
where
|
|
list.getAnItem() = p and
|
|
(
|
|
strictcount(list.getAnItem()) = 2 and not has_doc_string(list)
|
|
or
|
|
strictcount(list.getAnItem()) > 2
|
|
)
|
|
select p, "Unnecessary 'pass' statement."
|