From edebd124058bcc1dae5d9e7694436afa25b762e9 Mon Sep 17 00:00:00 2001 From: meanmail Date: Sun, 22 Sep 2024 16:34:30 +0200 Subject: [PATCH] Refactor inspector to remove redundant try-except block. Removed unnecessary try-except block that caught exceptions during IJClient connection and code inspection. The exception handling did not add value as it only logged the exception and returned an empty list, masking potential issues. --- .../common/inspector/base_inspector.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hyperstyle/src/python/review/inspectors/common/inspector/base_inspector.py b/hyperstyle/src/python/review/inspectors/common/inspector/base_inspector.py index ae3ccbe9..8ad519cc 100644 --- a/hyperstyle/src/python/review/inspectors/common/inspector/base_inspector.py +++ b/hyperstyle/src/python/review/inspectors/common/inspector/base_inspector.py @@ -142,21 +142,15 @@ def _get_inspection_result(self, code_text: str, file_path: Path) -> list[BaseIs msg = "Connection parameters is not set up." raise Exception(msg) - try: - client = IJClient(self.host, self.port) + client = IJClient(self.host, self.port) - code = model_pb2.Code() - code.languageId = self.language_id - code.text = code_text + code = model_pb2.Code() + code.languageId = self.language_id + code.text = code_text - inspection_result = client.inspect(code) + inspection_result = client.inspect(code) - return self.convert_to_base_issues(inspection_result, file_path) - - except Exception: - # TODO: replace with error when add mock server into tests - logger.exception("Inspector failed to connect to code server.") - return [] + return self.convert_to_base_issues(inspection_result, file_path) def choose_issue_type(self, problem: model_pb2.Problem) -> IssueType: if problem.inspector in self.ij_message_to_issue_type: