All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cflint.plugins.core.CFScopes Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.5.0
Show newest version
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");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy