class AnalyzerPython

Direct Known Subclasses

Defined in:

analyzer/analyzers/analyzer_python.cr

Constant Summary

HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options", "trace"]

HTTP method names commonly used in REST APIs

INDENTATION_SIZE = 4

Indentation size in spaces; different sizes can cause analysis issues

PYTHON_VAR_NAME_REGEX = /[a-zA-Z_][a-zA-Z0-9_]*/

Regex for valid Python variable names

Instance Method Summary

Instance methods inherited from class Analyzer

analyze analyze, base_path : String base_path, logger : NoirLogger logger, result : Array(Endpoint) result, url : String url

Constructor methods inherited from class Analyzer

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

Macros inherited from class Analyzer

define_getter_methods(names) define_getter_methods

Instance Method Detail

def find_imported_modules(app_base_path : String, file_path : String, content : String | Nil = nil) : Hash(String, Tuple(String, Int32)) #

Finds all the modules imported in a given Python file


[View source]
def find_imported_package(package_path : String, dotted_as_names : String) : Array(Tuple(String, String, Int32)) #

Finds the package path for imported modules


[View source]
def find_json_params(codeblock_lines : Array(String), json_var_names : Array(String)) : Array(Param) #

Finds all parameters in JSON objects within a given code block


[View source]
def parse_code_block(data : String | Array(String), after : Regex | Nil = nil) : String | Nil #

Parses a function or class definition from a string or an array of strings


[View source]
def parse_function_def(source_lines : Array(String), start_index : Int32) : FunctionDefinition | Nil #

Parses the definition of a function from the source lines starting at a given index


[View source]
def return_literal_value(data : String) : String #

Returns the literal value from a string if it represents a number or a quoted string


[View source]