class Analyzer::Elixir::Phoenix

Defined in:

analyzer/analyzers/elixir/elixir_phoenix.cr

Constant Summary

STANDARD_ROUTE_METHODS = {"get" => "GET", "post" => "POST", "patch" => "PATCH", "put" => "PUT", "delete" => "DELETE", "options" => "OPTIONS", "head" => "HEAD"}

get/post/… → its precompiled route regex. add_standard_route runs once per verb per line of every .ex file; Regex.new there recompiled the same 7 PCRE2 patterns on every call (~3.4M recompiles on a 2400-file repo, the dominant scan cost). The pattern depends only on the fixed verb set, so build it once. See add_standard_route for the shape rationale.

STANDARD_ROUTE_PATTERNS = STANDARD_ROUTE_METHODS.keys.to_h do |verb| {verb, Regex.new("(?:^|[^.\\w])#{verb}\\s*(?:\\(\\s*)?['\"]([^'\"]+)['\"]\\s*,\\s*([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*|unquote\\(\\s*\\w+\\s*\\))(?=\\s*[,)]|\\s*$)(?:\\s*,\\s*:(\\w+[!?]?))?")} end

Instance Method Summary

Instance methods inherited from class Analyzer::Elixir::ElixirEngine

analyze analyze, analyze_file(path : String) : Array(Endpoint) analyze_file

Instance methods inherited from class Analyzer

analyze analyze, base_path : String base_path, base_paths : Array(String) base_paths, callees_needed? : Bool callees_needed?, logger : NoirLogger logger, parallel_analyze(files : Array(String), &block : String -> Nil) parallel_analyze, read_file_content(path : String) : String read_file_content, result : Array(Endpoint) result, url : String url

Constructor methods inherited from class Analyzer

new(options : Hash(String, YAML::Any)) new

Macros inherited from class Analyzer

define_getter_methods(names) define_getter_methods

Instance methods inherited from module FileHelper

all_files : Array(String) all_files, get_files_by_extension(extension : String) : Array(String) get_files_by_extension, get_files_by_prefix(prefix : String) : Array(String) get_files_by_prefix, get_files_by_prefix_and_extension(prefix : String, extension : String) : Array(String) get_files_by_prefix_and_extension, get_public_dir_files(base_path : String, folder : String) : Array(String) get_public_dir_files, get_public_files(base_path : String, anchors : Array(String) = ["shard.yml", "Gemfile"]) : Array(String) get_public_files

Instance Method Detail

def analyze #

[View source]
def analyze_file(path : String) : Array(Endpoint) #

[View source]
def extract_controller_params #

[View source]
def extract_params_from_controller(content : String, controller_name : String, controller_path : String) #

[View source]
def extract_params_from_function_block(lines : Array(String), start_index : Int32, end_index : Int32, method : String) : Array(Param) #

[View source]
def find_function_end(lines : Array(String), start_index : Int32) : Int32 #

[View source]
def line_to_endpoint(line : String, file_path : String, scope_prefix : String = "", scope_module : String = "", base : String = @base_path, string_bindings : Hash(String, String) = Hash(String, String).new) : Array(Endpoint) #

[View source]
def should_extract_params_for_endpoint?(endpoint : Endpoint, controller_name : String, action_name : String) : Bool #

[View source]