Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Dec 21, 2016
1 parent 560210f commit c2ee435
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/java/com/cflint/plugins/core/UnusedArgumentChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,24 @@ protected void setArgumentLineNo(final String argument, final Integer lineNo) {
}
}

protected void useIdentifier(final CFIdentifier identifier) {
String name = identifier.getName().toLowerCase();
if (name.equals("arguments")) {
name = identifier.Decompile(0).toLowerCase().replace("arguments.", ""); // TODO
// better
// way
// of
// doing
// this?
protected void useIdentifier(final CFFullVarExpression fullVarExpression) {
if(fullVarExpression.getExpressions().size()>0){
final CFExpression identifier1 = fullVarExpression.getExpressions().get(0);
if (identifier1 instanceof CFIdentifier){
if("arguments".equalsIgnoreCase(((CFIdentifier) identifier1).getName()) && fullVarExpression.getExpressions().size()>1) {
final CFExpression identifier2 = fullVarExpression.getExpressions().get(1);
if(identifier2 instanceof CFIdentifier){
useIdentifier((CFIdentifier)identifier2);
}
}else{
useIdentifier((CFIdentifier)identifier1);
}
}
}
}

protected void useIdentifier(final CFIdentifier identifier) {
final String name = identifier.getName().toLowerCase();
if (methodArguments.get(name) != null) {
methodArguments.put(name, true);
}
Expand All @@ -74,10 +82,7 @@ protected void useIdentifier(final CFIdentifier identifier) {
@Override
public void expression(final CFExpression expression, final Context context, final BugList bugs) {
if (expression instanceof CFFullVarExpression) {
final CFExpression variable = ((CFFullVarExpression) expression).getExpressions().get(0);
if (variable instanceof CFIdentifier) {
useIdentifier((CFIdentifier) expression);
}
useIdentifier((CFFullVarExpression) expression);
} else if (expression instanceof CFIdentifier) {
useIdentifier((CFIdentifier) expression);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
component{

function x(arg1,arg2){
var foo = arguments.arg1.xyzzy;
foo = arguments.arg2.test;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ ]

0 comments on commit c2ee435

Please sign in to comment.