File tree Expand file tree Collapse file tree
analysis/python/codeanalyzer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,7 +80,10 @@ def __init__(
8080 ) -> None :
8181 if project_dir is None :
8282 raise ValueError ("project_dir is required for Python analysis." )
83- self .project_dir = Path (project_dir )
83+ # Expand ~ and resolve to absolute path for robustness
84+ self .project_dir = Path (project_dir ).expanduser ().resolve ()
85+ if not self .project_dir .is_dir ():
86+ raise ValueError (f"project_dir does not exist or is not a directory: { self .project_dir } " )
8487 self .analysis_level = analysis_level
8588 self .eager_analysis = eager_analysis
8689 self .target_files = target_files
@@ -89,8 +92,8 @@ def __init__(
8992 # codeanalyzer-python owns all caching. CLDK forwards these paths
9093 # verbatim; when cache_dir is None the backend defaults it to
9194 # <project_dir>/.codeanalyzer.
92- self .cache_dir = Path (cache_dir ) if cache_dir else None
93- self .analysis_json_path = Path (analysis_json_path ) if analysis_json_path else None
95+ self .cache_dir = Path (cache_dir ). expanduser (). resolve () if cache_dir else None
96+ self .analysis_json_path = Path (analysis_json_path ). expanduser (). resolve () if analysis_json_path else None
9497
9598 self .application : PyApplication = self ._run_analyzer ()
9699 # Class-signature → file path lookup, built once.
Original file line number Diff line number Diff line change @@ -113,6 +113,12 @@ def analysis(
113113 if project_path is not None and source_code is not None :
114114 raise CldkInitializationException ("Both project_path and source_code are provided. Please provide " "only one." )
115115
116+ # Normalize project_path: expand ~ and resolve to absolute path
117+ if project_path is not None :
118+ project_path = Path (project_path ).expanduser ().resolve ()
119+ if not project_path .is_dir ():
120+ raise CldkInitializationException (f"project_path does not exist or is not a directory: { project_path } " )
121+
116122 if self .language == "java" :
117123 return JavaAnalysis (
118124 project_dir = project_path ,
You can’t perform that action at this time.
0 commit comments