Skip to content

Commit 58e11f1

Browse files
committed
Add input path validation
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 0196794 commit 58e11f1

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.1] - 2025-07-10
9+
10+
### Added
11+
- Input path validation in CLI main function to check if the provided input path exists
12+
- Logger import for better error handling and logging capabilities
13+
14+
### Changed
15+
- Improved CLI error handling with proper logging when input path does not exist
16+
- Test configuration updates:
17+
- Removed unused app import from conftest.py
18+
- Updated test_cli_call_symbol_table to use verbose flag (-v) instead of --quiet flag
19+
20+
### Fixed
21+
- CLI now properly exits with error code 1 when input path doesn't exist instead of proceeding with invalid path
22+
23+
## [0.1.0] - Initial Release
24+
25+
### Added
26+
- Initial release of codeanalyzer
27+
- Static analysis capabilities for Python source code using Jedi, CodeQL, and Tree-sitter
28+
- Command-line interface with typer
29+
- Support for symbol table analysis and call graph generation
30+
- Configurable analysis levels (1: symbol table, 2: call graph)
31+
- CodeQL integration with optional enable/disable
32+
- Caching system with configurable cache directory
33+
- Output artifacts in JSON format
34+
- Verbosity controls for logging
35+
- Eager/lazy analysis modes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "codeanalyzer"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Static Analysis on Python source code using Jedi, CodeQL and Treesitter."
55
readme = "README.md"
66
authors = [

src/codeanalyzer/__main__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional, Annotated
55
from pathlib import Path
66
from codeanalyzer.utils import _set_log_level
7-
7+
from codeanalyzer.utils import logger
88
from codeanalyzer.core import AnalyzerCore
99

1010

@@ -49,6 +49,10 @@ def main(
4949
"""Static Analysis on Python source code using Jedi, Astroid, and Treesitter."""
5050
_set_log_level(verbosity)
5151

52+
if not input.exists():
53+
logger.error(f"Input path '{input}' does not exist.")
54+
raise typer.Exit(code=1)
55+
5256
with AnalyzerCore(
5357
input, analysis_level, using_codeql, rebuild_analysis, cache_dir, clear_cache
5458
) as analyzer:

src/test/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import pytest
44
from typer.testing import CliRunner
55

6-
# Import your Typer app
7-
from codeanalyzer.__main__ import app # adjust if main is elsewhere
8-
96

107
@pytest.fixture
118
def cli_runner() -> CliRunner:

src/test/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def test_cli_call_symbol_table(cli_runner, project_root):
2525
"--analysis-level",
2626
"1",
2727
"--no-codeql",
28-
"--quiet",
2928
"--cache-dir",
3029
str(project_root / "src" / "test" / ".cache"),
3130
"--keep-cache",
31+
"-v",
3232
],
3333
)
3434
logger.debug(f"CLI result: {result.output}")

0 commit comments

Comments
 (0)