Skip to content

checking the compatibility of analysis.json with the passed analysis … #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cldk/analysis/java/codeanalyzer/codeanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ def _init_japplication(data: str) -> JApplication:

# set_trace()
return JApplication(**json.loads(data))

@staticmethod
def check_exisiting_analysis_file_level(analysis_json_path_file: Path, analysis_level: int) -> bool:
analysis_file_compatible = True
if not analysis_json_path_file.exists():
analysis_file_compatible = False
else:
with open(analysis_json_path_file) as f:
data = json.load(f)
if analysis_level == 2 and "call_graph" not in data:
analysis_file_compatible = False
elif analysis_level == 1 and "symbol_table" not in data:
analysis_file_compatible = False
return analysis_file_compatible



def _init_codeanalyzer(self, analysis_level=1) -> JApplication:
"""Should initialize the Codeanalyzer.
Expand Down Expand Up @@ -170,7 +186,7 @@ def _init_codeanalyzer(self, analysis_level=1) -> JApplication:
)
is_run_code_analyzer = True
else:
if not analysis_json_path_file.exists() or self.eager_analysis:
if not self.check_exisiting_analysis_file_level(analysis_json_path_file, analysis_level) or self.eager_analysis:
# If the analysis file does not exist, we'll run the analysis. Alternately, if the eager_analysis
# flag is set, we'll run the analysis every time the object is created. This will happen regradless
# of the existence of the analysis file.
Expand Down