Skip to content

[Bug]: Computed Property is ignored #15

@fummicc1

Description

@fummicc1

Bug Description

Property inside struct, class or enum (computed property) is ignored by complexityCalculator.

example:

struct S {
    var v: String {
        let rand = Int.random(in: 0..<10)
        // return rand == 0 || rand > 5
        if rand == 0 {
            return true
        }
        if rand > 5 {
            return true
        } else {
            return false
        }
    }
}

Steps to Reproduce

  1. Run example code on debug site.
  2. Conform that result is empty.
Image

Expected Behavior

Computed property should be also processed. (cyclomatic: 3, cognitive: 3)

Actual Behavior

Process is skipped.

Swift Code Sample

struct S {
    var v: String {
        let rand = Int.random(in: 0..<10)
        // return rand == 0 || rand > 5
        if rand == 0 {
            return true
        }
        if rand > 5 {
            return true
        } else {
            return false
        }
    }
}

Command Used

Output/Error Messages

Platform

Linux (Ubuntu)

OS Version

jammy

Swift Version

6.1

swift-complexity Version

0.0.5

Pre-submission Checks

  • I have searched existing issues to ensure this is not a duplicate
  • I have tested with the latest version of swift-complexity
  • I have provided all the required information above

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions