@@ -10,98 +10,105 @@ This project uses [uv](https://docs.astral.sh/uv/) for dependency management.
10
10
11
11
### Prerequisites
12
12
13
- - Python 3.12 or higher
14
13
- [ uv] ( https://docs.astral.sh/uv/getting-started/installation/ ) installed
14
+ - Python 3.12 or higher. You can use ` uv ` to install Python if it's not already installed:
15
+ ``` bash
16
+ uv python install 3.12
17
+ ```
15
18
16
19
### Setup
17
20
18
21
1 . Clone the repository:
19
22
``` bash
20
- git clone < repository-url >
23
+ git clone https://github.com/codellm-devkit/codeanalyzer-python
21
24
cd codeanalyzer-python
22
25
```
23
26
24
27
2 . Install dependencies using uv:
25
28
``` bash
26
29
uv sync --all-groups
27
30
```
28
-
29
31
This will install all dependencies including development and test dependencies.
30
32
31
- 3 . Install the package in development mode:
32
- ``` bash
33
- uv pip install -e .
34
- ```
35
-
36
33
## Usage
37
34
38
35
The codeanalyzer provides a command-line interface for performing static analysis on Python projects.
39
36
40
37
### Basic Usage
41
38
42
39
``` bash
43
- codeanalyzer --input /path/to/python/project
40
+ uv run codeanalyzer --input /path/to/python/project
44
41
```
45
42
46
43
### Command Line Options
47
44
48
- - ` -i, --input PATH ` : ** Required.** Path to the project root directory to analyze.
49
- - ` -o, --output PATH ` : Output directory for analysis artifacts. If specified, results will be saved to ` analysis.json ` in this directory.
50
- - ` -a, --analysis-level INTEGER ` : Analysis depth level (default: 1)
51
- - ` 1 ` : Symbol table generation
52
- - ` 2 ` : Call graph analysis
53
- - ` --codeql/--no-codeql ` : Enable or disable CodeQL-based analysis (default: disabled)
54
- - ` --eager/--lazy ` : Analysis mode (default: lazy)
55
- - ` --eager ` : Rebuild analysis cache at every run
56
- - ` --lazy ` : Use existing cache if available
57
- - ` -c, --cache-dir PATH ` : Directory to store analysis cache. Defaults to ` .cache/codeanalyzer ` in current working directory.
58
- - ` --clear-cache/--keep-cache ` : Clear cache after analysis (default: clear)
59
- - ` -v/-q, --verbose/--quiet ` : Enable or disable verbose output (default: verbose)
45
+ To view the available options and commands, run ` uv run codeanalyzer --help ` . You should see output similar to the following:
46
+
47
+ ``` bash
48
+ ❯ uv run codeanalyzer --help
49
+
50
+ Usage: codeanalyzer [OPTIONS] COMMAND [ARGS]...
51
+
52
+ Static Analysis on Python source code using Jedi, CodeQL and Tree sitter.
53
+
54
+
55
+ ╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
56
+ │ * --input -i PATH Path to the project root directory. [default: None] [required] │
57
+ │ --output -o PATH Output directory for artifacts. [default: None] │
58
+ │ --analysis-level -a INTEGER 1: symbol table, 2: call graph. [default: 1] │
59
+ │ --codeql --no-codeql Enable CodeQL-based analysis. [default: no-codeql] │
60
+ │ --eager --lazy Enable eager or lazy analysis. Eager will rebuild the analysis cache at every run and lazy will use the cache if available. Defaults to lazy. [default: lazy] │
61
+ │ --cache-dir -c PATH Directory to store analysis cache. If not specified, the cache will be stored in the current working directory under ` .codeanalyzer` . Defaults to None. [default: None] │
62
+ │ --clear-cache --keep-cache Clear cache after analysis. [default: clear-cache] │
63
+ │ --verbose -v --quiet -q Enable verbose output. [default: v] │
64
+ │ --help Show this message and exit. │
65
+ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
66
+ ` ` `
60
67
61
68
# ## Examples
62
69
63
70
1. ** Basic analysis with symbol table:**
64
71
` ` ` bash
65
- codeanalyzer --input ./my-python-project
72
+ uv run codeanalyzer --input ./my-python-project
66
73
` ` `
67
74
68
75
This will print the symbol table to stdout in JSON format to the standard output. If you want to save the output, you can use the ` --output` option.
69
76
70
77
` ` ` bash
71
- codeanalyzer --input ./my-python-project --output /path/to/analysis-results
78
+ uv run codeanalyzer --input ./my-python-project --output /path/to/analysis-results
72
79
` ` `
73
80
74
81
Now, you can find the analysis results in ` analysis.json` in the specified directory.
75
82
76
83
2. ** Toggle analysis levels with ` --analysis-level` :**
77
84
` ` ` bash
78
- codeanalyzer --input ./my-python-project --analysis-level 1 # Symbol table only
85
+ uv run codeanalyzer --input ./my-python-project --analysis-level 1 # Symbol table only
79
86
` ` `
80
87
Call graph analysis can be enabled by setting the level to ` 2` :
81
88
` ` ` bash
82
- codeanalyzer --input ./my-python-project --analysis-level 2 # Symbol table + Call graph
89
+ uv run codeanalyzer --input ./my-python-project --analysis-level 2 # Symbol table + Call graph
83
90
` ` `
84
91
*** Note: The ` --analysis-level=2` is not yet implemented in this version.***
85
92
86
93
3. ** Analysis with CodeQL enabled:**
87
94
` ` ` bash
88
- codeanalyzer --input ./my-python-project --codeql
95
+ uv run codeanalyzer --input ./my-python-project --codeql
89
96
` ` `
90
97
This will perform CodeQL-based analysis in addition to the standard symbol table generation.
91
98
92
99
*** Note: Not yet fully implemented. Please refrain from using this option until further notice.***
93
100
94
101
4. ** Eager analysis with custom cache directory:**
95
102
` ` ` bash
96
- codeanalyzer --input ./my-python-project --eager --cache-dir /path/to/custom-cache
103
+ uv run codeanalyzer --input ./my-python-project --eager --cache-dir /path/to/custom-cache
97
104
` ` `
98
105
This will rebuild the analysis cache at every run and store it in ` /path/to/custom-cache/.codeanalyzer` . The cache will be cleared by default after analysis unless you specify ` --keep-cache` .
99
106
100
107
If you provide --cache-dir, the cache will be stored in that directory. If not specified, it defaults to ` .codeanalyzer` in the current working directory (` $PWD ` ).
101
108
102
109
5. ** Quiet mode (minimal output):**
103
110
` ` ` bash
104
- codeanalyzer --input /path/to/my-python-project --quiet
111
+ uv run codeanalyzer --input /path/to/my-python-project --quiet
105
112
` ` `
106
113
107
114
# ## Output
0 commit comments