Skip to content

no_magic_number - Ignore UIColor initializers #5183

@LowAmmo

Description

@LowAmmo

New Issue Checklist

New rule request

Requesting another enhancement to "no_magic_numbers", where it will ignore UIColor definitions.

Since the nature of definiting a color is going to have some "magic numbers", I think it would make sense to just ignore the values -

static let grayColor: UIColor = #colorLiteral(red: 0.7019607843, green: 0.7019607843, blue: 0.7019607843, alpha: 1)
let myColor: UIColor = UIColor(red: 0.6, green: 1.0, blue: 0.2, alpha: 0.52)
let yourColor: UIColor = UIColor(hue: 0.9, saturation: 0.6, brightness: 0.333334, alpha: 1.0)

(including all other UIColor constructors

I don't think this needs to be an "opt-in" configuration...I would think most people would want this by default...but not opposed to it being an opt-in rule.

Hopefully that makes sense!

-Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions