Skip to content

Rule Request: Prefer static over final class #5471

@SimplyDanny

Description

@SimplyDanny

The modifiers final and class on a method/property have the same meaning as static. The rule should flag appearances of final class on the same declaration and replace them by static.

I don't think there is any need for configuration. The rule could be enabled by default, but this can be decided in review when browsing through the reported OSS findings.

Triggering:

class C {
    final class func f() {}
}

final class C {
    class func f() {}
}

Non-triggering:

class C {
    static func f() {}
}

class C {
    class func f() {}
}

final class C {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssue to be taken up by new contributors yet unfamiliar with the project.rule-requestRequests for a new rules.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions