Merge pull request #145 from github/aibaars/fix

Fix regression in rb/unused-parameter
This commit is contained in:
Arthur Baars
2021-03-01 12:26:47 +01:00
committed by GitHub
3 changed files with 8 additions and 29 deletions

View File

@@ -175,18 +175,13 @@ private predicate inBooleanContext(AstNode n) {
or
n = any(NotExpr parent | inBooleanContext(parent)).getOperand()
or
n = any(ParenthesizedExpr parent | inBooleanContext(parent)).getLastExpr()
n = any(StmtSequence parent | inBooleanContext(parent)).getLastExpr()
or
exists(CaseExpr c, WhenExpr w |
not exists(c.getValue()) and
c.getAWhenBranch() = w and
w.getPattern(_) = n
)
or
exists(StmtSequence parent |
inBooleanContext(parent) and
n = parent.getLastExpr()
)
}
/**

View File

@@ -206,24 +206,9 @@ private predicate succImpl(AstNode pred, AstNode succ, Completion c) {
}
private predicate isHidden(ControlFlowTree t) {
not t instanceof ASTInternal::AstNode::Range
or
t.isHidden()
or
t = any(Method m).getName()
or
t = any(Class m).getName()
or
t = any(Module m).getName()
or
t = any(ScopeResolution m).getName()
or
t = any(SingletonMethod m).getName()
or
t = any(Call c).getMethod() and
not t instanceof ScopeResolution
or
t instanceof RestAssignment
or
t instanceof Superclass
}
private predicate succImplIfHidden(AstNode pred, AstNode succ) {

View File

@@ -3,7 +3,6 @@
*/
private import codeql_ruby.AST
private import AstNodes
private import Completion
private import ControlFlowGraphImpl
private import SuccessorTypes
@@ -218,19 +217,19 @@ private module ConditionalCompletionSplitting {
succ(pred, succ, c) and
last(succ, _, completion) and
(
last(succ.(LogicalNotAstNode).getOperand(), pred, c) and
last(succ.(NotExpr).getOperand(), pred, c) and
completion.(BooleanCompletion).getDual() = c
or
last(succ.(LogicalAndAstNode).getAnOperand(), pred, c) and
last(succ.(LogicalAndExpr).getAnOperand(), pred, c) and
completion = c
or
last(succ.(LogicalOrAstNode).getAnOperand(), pred, c) and
last(succ.(LogicalOrExpr).getAnOperand(), pred, c) and
completion = c
or
last(succ.(ParenthesizedStatement).getChild(), pred, c) and
last(succ.(ParenthesizedExpr).getLastExpr(), pred, c) and
completion = c
or
last(succ.(IfElsifAstNode).getBranch(_), pred, c) and
last(succ.(ConditionalExpr).getBranch(_), pred, c) and
completion = c
)
}