You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The inconsistent_or_missing_returns_checker handles two error messages inconsistent-returns and missing-return-statement as the logic to detect the two errors are similar. However, for readability and expandability concern, it could be a better design to separate this checker into two, one specifically for each error message.
For example, during the integration of z3 option into this checker, we only want missing-return-statement to be affected by z3 option. However, as the checking for two messages are tightly coupled, we have to implement a messy and suboptimal solution in our current codebase:
# At Line 85# ignore unfeasible edges for missing return if z3 option is onifself.linter.config.z3and (
notblock.is_feasibleornotany(
edge.is_feasibleforedgeinblock.successorsifedge.targetisend
)
):
We could have directly filters out blocks whose edge connecting to the end node is unfeasible, which replaces statement or not any(edge.is_feasible for edge in block.successors if edge.target is end) with the following modification:
Change
# At Line 60# get the blocks connected to the end of cfgend=node.cfg.endend_blocks= [edge.sourceforedgeinend.predecessors]
to
# At Line 60# get the blocks connected to the end of cfgend=node.cfg.endend_blocks= [edge.sourceforedgeinend.predecessorsifedge.is_feasible]
However, this change would cause errors in inconsistent-returns in our current checker.
In addition, in our current implementation, we need to maintain unit tests for z3 options for inconsistent-returns even though z3 is not used for this message. This is to ensure that modifications on missing-return-statementz3 option would also cause accidental changes to inconsistent-returns. Refactoring the checker would also us to remove the redundant test cases.
The text was updated successfully, but these errors were encountered:
Raine-Yang-UofT
changed the title
Separate inconsistent_or_missing_returns_checker into two separate checkers
Separate inconsistent_or_missing_returns_checker into two checkers
Nov 4, 2024
The
inconsistent_or_missing_returns_checker
handles two error messagesinconsistent-returns
andmissing-return-statement
as the logic to detect the two errors are similar. However, for readability and expandability concern, it could be a better design to separate this checker into two, one specifically for each error message.For example, during the integration of
z3
option into this checker, we only wantmissing-return-statement
to be affected byz3
option. However, as the checking for two messages are tightly coupled, we have to implement a messy and suboptimal solution in our current codebase:We could have directly filters out blocks whose edge connecting to the
end
node is unfeasible, which replaces statementor not any(edge.is_feasible for edge in block.successors if edge.target is end)
with the following modification:Change
to
However, this change would cause errors in
inconsistent-returns
in our current checker.In addition, in our current implementation, we need to maintain unit tests for
z3
options forinconsistent-returns
even thoughz3
is not used for this message. This is to ensure that modifications onmissing-return-statement
z3
option would also cause accidental changes toinconsistent-returns
. Refactoring the checker would also us to remove the redundant test cases.The text was updated successfully, but these errors were encountered: