Skip to content

Commit aa9f429

Browse files
committed
Add file path filed to callables.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 00c7693 commit aa9f429

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

src/codeanalyzer/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def main(
5959
typer.Option(
6060
"-c",
6161
"--cache-dir",
62-
help="Directory to store analysis cache. If not specified, the cache will be stored in the current working directory under .cache/codeanalyzer. Defaults to None.",
62+
help="Directory to store analysis cache. If not specified, the cache will be stored in the current working directory under `.codeanalyzer`. Defaults to None.",
6363
),
6464
] = None,
6565
clear_cache: Annotated[

src/codeanalyzer/core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def __enter__(self) -> "AnalyzerCore":
128128
"pip",
129129
"install",
130130
"--upgrade",
131+
"--editable",
131132
"pip",
132133
"build",
133134
"setuptools",

src/codeanalyzer/schema/py_schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class PyCallable(BaseModel):
254254
"""
255255

256256
name: str
257+
path: str
257258
signature: str # e.g., module.<class_name>.function_name
258259
comments: List[PyComment] = []
259260
decorators: List[str] = []

src/codeanalyzer/syntactic_analysis/symbol_table_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ def visit(n: AST, class_prefix: str = ""):
258258
callables[method_name] = (
259259
PyCallable.builder()
260260
.with_name(method_name)
261+
.with_path(script.path.__str__())
261262
.with_signature(signature)
262263
.with_decorators(decorators)
263264
.with_code(code)
@@ -799,9 +800,10 @@ def _cyclomatic_complexity(self, fn_node: ast.FunctionDef) -> int:
799800
complexity += 1
800801

801802
elif isinstance(node, ast.ExceptHandler):
803+
# Try and catch statement
802804
complexity += 1
803805

804-
# I am also counting 'assert' or 'return' or 'yield' as complexity bumps
806+
# TODO: I am also counting 'assert' or 'return' or 'yield' as complexity bumps
805807
elif isinstance(node, (ast.Assert, ast.Return, ast.Yield, ast.YieldFrom)):
806808
complexity += 1
807809

0 commit comments

Comments
 (0)