Skip to content

Commit

Permalink
Refactor inspector to remove redundant try-except block.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
meanmail committed Sep 22, 2024
1 parent 0d742a8 commit edebd12
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit edebd12

Please sign in to comment.