com.cflint.plugins.core.CFScopes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CFLint Show documentation
Show all versions of CFLint Show documentation
A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.
package com.cflint.plugins.core;
import java.util.Arrays;
import java.util.Collection;
public class CFScopes {
public static final String LOCAL = "local";
final static Collection scopes = Arrays.asList("url", "form", "cookie", "cgi", "server", "application",
"session", "client", "request", "arguments", "variables", "this", LOCAL, "cfcatch");
protected String[] parts(final String variable) {
return variable.toLowerCase().split("\\.|\\[|\\]");
}
public boolean isCFScoped(final String variable) {
final String[] parts = parts(variable);
return scopes.contains(parts[0]);
}
public boolean isScoped(final String variable, final String scope) {
final String[] parts = parts(variable);
return parts[0].equals(scope);
}
public boolean isLocalScoped(final String variable) {
return isScoped(variable, LOCAL);
}
public boolean isFunctionScoped(final String variable) {
return isScoped(variable, LOCAL) || isScoped(variable, "variables") || isScoped(variable, "arguments");
}
}