Skip to content

Swift complexity should include "guard" #575

@AndyDentFree

Description

@AndyDentFree

Describe the bug
The common guard statement is not handled. This is equivalent to an up-front test in C++ such as if (blah == nullptr) return;

A less-important addition would be to add defer which is equivalent to using the C++ RAII idiom but is simpler, with a statement rather than needing a helper class.

To Reproduce
I reviewed languages.json and noticed guard is missing.

Expected behavior
Count guard to add to complexity. It's a very common part of control flow in many Swift functions. It is often the only branch expression in a function.

Also suggest adding defer which is less common but can't see a reason not to add it as it's a reserved word.

Desktop:

  • OS: macOS
  • Version 3.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    DONE

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions