Skip to content

Commit

Permalink
simplify checks
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Jun 15, 2024
1 parent 0e9e49f commit df30535
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ private void AnalyzeOperation(OperationAnalysisContext context)

private bool SwitchIsIncomplete(
TSwitchOperation operation,
out bool missingCases, out bool missingDefaultCase)
out bool missingCases,
out bool missingDefaultCase)
{
missingCases = false;
missingDefaultCase = false;

if (HasExhaustiveNullAndTypeCheckCases(operation))
return false;

if (!IsBooleanSwitch(operation, out missingCases, out missingDefaultCase))
{
var missingEnumMembers = GetMissingEnumMembers(operation);
Expand All @@ -86,13 +93,7 @@ private bool SwitchIsIncomplete(
missingDefaultCase = !HasDefaultCase(operation);
}

if (missingCases)
return true;

if (HasExhaustiveNullAndTypeCheckCases(operation))
return false;

return missingDefaultCase;
return missingCases || missingDefaultCase;
}

private bool IsBooleanSwitch(TSwitchOperation operation, out bool missingCases, out bool missingDefaultCase)
Expand Down

0 comments on commit df30535

Please sign in to comment.