codeanalyzer-python 0.1.11__tar.gz → 0.1.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/PKG-INFO +1 -1
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/__main__.py +38 -24
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/core.py +13 -27
- codeanalyzer_python-0.1.13/codeanalyzer/options/__init__.py +3 -0
- codeanalyzer_python-0.1.13/codeanalyzer/options/options.py +25 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/pyproject.toml +1 -1
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/.gitignore +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/LICENSE +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/NOTICE +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/README.md +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/config/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/config/config.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/jedi/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/jedi/jedi.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/py.typed +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/schema/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/schema/py_schema.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/codeql/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/codeql/codeql_analysis.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/codeql/codeql_exceptions.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/codeql/codeql_loader.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/codeql/codeql_query_runner.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/wala/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/syntactic_analysis/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/syntactic_analysis/exceptions.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/syntactic_analysis/symbol_table_builder.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/utils/__init__.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/utils/logging.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/utils/progress_bar.py +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/LICENSE +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/README.md +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/properties/README.md +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/xarray/datatree_/LICENSE +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/xarray/datatree_/README.md +0 -0
- {codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/test/fixtures/whole_applications/xarray/xarray/datatree_/docs/README.md +0 -0
|
@@ -7,6 +7,8 @@ from codeanalyzer.core import Codeanalyzer
|
|
|
7
7
|
from codeanalyzer.utils import _set_log_level, logger
|
|
8
8
|
from codeanalyzer.config import OutputFormat
|
|
9
9
|
from codeanalyzer.schema import model_dump_json
|
|
10
|
+
from codeanalyzer.options import AnalysisOptions
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
def main(
|
|
12
14
|
input: Annotated[
|
|
@@ -34,9 +36,7 @@ def main(
|
|
|
34
36
|
] = False,
|
|
35
37
|
using_ray: Annotated[
|
|
36
38
|
bool,
|
|
37
|
-
typer.Option(
|
|
38
|
-
"--ray/--no-ray", help="Enable Ray for distributed analysis."
|
|
39
|
-
),
|
|
39
|
+
typer.Option("--ray/--no-ray", help="Enable Ray for distributed analysis."),
|
|
40
40
|
] = False,
|
|
41
41
|
rebuild_analysis: Annotated[
|
|
42
42
|
bool,
|
|
@@ -69,45 +69,59 @@ def main(
|
|
|
69
69
|
] = None,
|
|
70
70
|
clear_cache: Annotated[
|
|
71
71
|
bool,
|
|
72
|
-
typer.Option(
|
|
72
|
+
typer.Option(
|
|
73
|
+
"--clear-cache/--keep-cache",
|
|
74
|
+
help="Clear cache after analysis. By default, cache is retained.",
|
|
75
|
+
),
|
|
73
76
|
] = False,
|
|
74
77
|
verbosity: Annotated[
|
|
75
78
|
int, typer.Option("-v", count=True, help="Increase verbosity: -v, -vv, -vvv")
|
|
76
79
|
] = 0,
|
|
77
80
|
):
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
options = AnalysisOptions(
|
|
82
|
+
input=input,
|
|
83
|
+
output=output,
|
|
84
|
+
format=format,
|
|
85
|
+
analysis_level=analysis_level,
|
|
86
|
+
using_codeql=using_codeql,
|
|
87
|
+
using_ray=using_ray,
|
|
88
|
+
rebuild_analysis=rebuild_analysis,
|
|
89
|
+
skip_tests=skip_tests,
|
|
90
|
+
file_name=file_name,
|
|
91
|
+
cache_dir=cache_dir,
|
|
92
|
+
clear_cache=clear_cache,
|
|
93
|
+
verbosity=verbosity,
|
|
94
|
+
)
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
_set_log_level(options.verbosity)
|
|
97
|
+
if not options.input.exists():
|
|
98
|
+
logger.error(f"Input path '{options.input}' does not exist.")
|
|
83
99
|
raise typer.Exit(code=1)
|
|
84
100
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
full_file_path = input / file_name
|
|
101
|
+
if options.file_name is not None:
|
|
102
|
+
full_file_path = options.input / options.file_name
|
|
88
103
|
if not full_file_path.exists():
|
|
89
|
-
logger.error(
|
|
104
|
+
logger.error(
|
|
105
|
+
f"Specified file '{options.file_name}' does not exist in '{options.input}'."
|
|
106
|
+
)
|
|
90
107
|
raise typer.Exit(code=1)
|
|
91
108
|
if not full_file_path.is_file():
|
|
92
|
-
logger.error(f"Specified path '{file_name}' is not a file.")
|
|
109
|
+
logger.error(f"Specified path '{options.file_name}' is not a file.")
|
|
93
110
|
raise typer.Exit(code=1)
|
|
94
|
-
if not str(file_name).endswith(
|
|
95
|
-
logger.error(
|
|
111
|
+
if not str(options.file_name).endswith(".py"):
|
|
112
|
+
logger.error(
|
|
113
|
+
f"Specified file '{options.file_name}' is not a Python file (.py)."
|
|
114
|
+
)
|
|
96
115
|
raise typer.Exit(code=1)
|
|
97
116
|
|
|
98
|
-
with Codeanalyzer(
|
|
99
|
-
input, analysis_level, skip_tests, using_codeql, rebuild_analysis, cache_dir, clear_cache, using_ray, file_name
|
|
100
|
-
) as analyzer:
|
|
117
|
+
with Codeanalyzer(options) as analyzer:
|
|
101
118
|
artifacts = analyzer.analyze()
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
if output is None:
|
|
105
|
-
# Output to stdout (only for JSON)
|
|
120
|
+
if options.output is None:
|
|
106
121
|
print(model_dump_json(artifacts, separators=(",", ":")))
|
|
107
122
|
else:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_write_output(artifacts, output, format)
|
|
123
|
+
options.output.mkdir(parents=True, exist_ok=True)
|
|
124
|
+
_write_output(artifacts, options.output, options.format)
|
|
111
125
|
|
|
112
126
|
|
|
113
127
|
def _write_output(artifacts, output_dir: Path, format: OutputFormat):
|
|
@@ -14,6 +14,7 @@ from codeanalyzer.semantic_analysis.codeql.codeql_exceptions import CodeQLExcept
|
|
|
14
14
|
from codeanalyzer.syntactic_analysis.exceptions import SymbolTableBuilderRayError
|
|
15
15
|
from codeanalyzer.syntactic_analysis.symbol_table_builder import SymbolTableBuilder
|
|
16
16
|
from codeanalyzer.utils import ProgressBar
|
|
17
|
+
from codeanalyzer.options import AnalysisOptions
|
|
17
18
|
|
|
18
19
|
@ray.remote
|
|
19
20
|
def _process_file_with_ray(py_file: Union[Path, str], project_dir: Union[Path, str], virtualenv: Union[Path, str, None]) -> Dict[str, PyModule]:
|
|
@@ -43,40 +44,25 @@ class Codeanalyzer:
|
|
|
43
44
|
"""Core functionality for CodeQL analysis.
|
|
44
45
|
|
|
45
46
|
Args:
|
|
46
|
-
|
|
47
|
-
virtualenv (Optional[Path]): Path to the virtual environment directory.
|
|
48
|
-
using_codeql (bool): Whether to use CodeQL for analysis.
|
|
49
|
-
rebuild_analysis (bool): Whether to force rebuild the database.
|
|
50
|
-
clear_cache (bool): Whether to delete the cached directory after analysis.
|
|
51
|
-
analysis_depth (int): Depth of analysis (reserved for future use).
|
|
47
|
+
options (AnalysisOptions): Analysis configuration options containing all necessary parameters.
|
|
52
48
|
"""
|
|
53
49
|
|
|
54
|
-
def __init__(
|
|
55
|
-
self
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
skip_tests
|
|
59
|
-
using_codeql
|
|
60
|
-
rebuild_analysis
|
|
61
|
-
cache_dir: Optional[Path],
|
|
62
|
-
clear_cache: bool,
|
|
63
|
-
using_ray: bool,
|
|
64
|
-
file_name: Optional[Path] = None,
|
|
65
|
-
) -> None:
|
|
66
|
-
self.analysis_depth = analysis_depth
|
|
67
|
-
self.project_dir = Path(project_dir).resolve()
|
|
68
|
-
self.skip_tests = skip_tests
|
|
69
|
-
self.using_codeql = using_codeql
|
|
70
|
-
self.rebuild_analysis = rebuild_analysis
|
|
50
|
+
def __init__(self, options: AnalysisOptions) -> None:
|
|
51
|
+
self.options = options
|
|
52
|
+
self.analysis_depth = options.analysis_level
|
|
53
|
+
self.project_dir = Path(options.input).resolve()
|
|
54
|
+
self.skip_tests = options.skip_tests
|
|
55
|
+
self.using_codeql = options.using_codeql
|
|
56
|
+
self.rebuild_analysis = options.rebuild_analysis
|
|
71
57
|
self.cache_dir = (
|
|
72
|
-
cache_dir.resolve() if cache_dir is not None else self.project_dir
|
|
58
|
+
options.cache_dir.resolve() if options.cache_dir is not None else self.project_dir
|
|
73
59
|
) / ".codeanalyzer"
|
|
74
|
-
self.clear_cache = clear_cache
|
|
60
|
+
self.clear_cache = options.clear_cache
|
|
75
61
|
self.db_path: Optional[Path] = None
|
|
76
62
|
self.codeql_bin: Optional[Path] = None
|
|
77
63
|
self.virtualenv: Optional[Path] = None
|
|
78
|
-
self.using_ray: bool = using_ray
|
|
79
|
-
self.file_name: Optional[Path] = file_name
|
|
64
|
+
self.using_ray: bool = options.using_ray
|
|
65
|
+
self.file_name: Optional[Path] = options.file_name
|
|
80
66
|
|
|
81
67
|
@staticmethod
|
|
82
68
|
def _cmd_exec_helper(
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Optional
|
|
4
|
+
from enum import Enum
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class OutputFormat(str, Enum):
|
|
8
|
+
JSON = "json"
|
|
9
|
+
MSGPACK = "msgpack"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class AnalysisOptions:
|
|
14
|
+
input: Path
|
|
15
|
+
output: Optional[Path] = None
|
|
16
|
+
format: OutputFormat = OutputFormat.JSON
|
|
17
|
+
analysis_level: int = 1
|
|
18
|
+
using_codeql: bool = False
|
|
19
|
+
using_ray: bool = False
|
|
20
|
+
rebuild_analysis: bool = False
|
|
21
|
+
skip_tests: bool = True
|
|
22
|
+
file_name: Optional[Path] = None
|
|
23
|
+
cache_dir: Optional[Path] = None
|
|
24
|
+
clear_cache: bool = False
|
|
25
|
+
verbosity: int = 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/semantic_analysis/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codeanalyzer_python-0.1.11 → codeanalyzer_python-0.1.13}/codeanalyzer/utils/progress_bar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|