Skip to content

Commit

Permalink
Disable the local swiftlint, add swiftformat, avoid removing the inte…
Browse files Browse the repository at this point in the history
…rnal keyword from the Trait, format all the files in the SDK
  • Loading branch information
gazreese committed Apr 30, 2024
1 parent dbc6719 commit 2827e8d
Show file tree
Hide file tree
Showing 24 changed files with 1,184 additions and 1,088 deletions.
1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--disable redundantInternal
46 changes: 23 additions & 23 deletions FlagsmithClient/Classes/Feature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ import Foundation
A Feature represents a flag or remote configuration value on the server.
*/
public struct Feature: Codable, Sendable {
enum CodingKeys: String, CodingKey {
case name
case type
case description
}
/// The name of the feature
public let name: String
public let type: String?
public let description: String?
init(name: String, type: String?, description: String?) {
self.name = name
self.type = type
self.description = description
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.name, forKey: .name)
try container.encodeIfPresent(self.type, forKey: .type)
try container.encodeIfPresent(self.description, forKey: .description)
}
enum CodingKeys: String, CodingKey {
case name
case type
case description
}

/// The name of the feature
public let name: String
public let type: String?
public let description: String?

init(name: String, type: String?, description: String?) {
self.name = name
self.type = type
self.description = description
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(name, forKey: .name)
try container.encodeIfPresent(type, forKey: .type)
try container.encodeIfPresent(description, forKey: .description)
}
}
88 changes: 44 additions & 44 deletions FlagsmithClient/Classes/Flag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,49 @@
import Foundation

/**
A Flag represents a feature flag on the server.
*/
A Flag represents a feature flag on the server.
*/
public struct Flag: Codable, Sendable {
enum CodingKeys: String, CodingKey {
case feature
case value = "feature_state_value"
case enabled
}
public let feature: Feature
public let value: TypedValue
public let enabled: Bool
public init(featureName:String, boolValue: Bool, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.init(featureName: featureName, value: TypedValue.bool(boolValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)
}

public init(featureName:String, floatValue: Float, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.init(featureName: featureName, value: TypedValue.float(floatValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)
}

public init(featureName:String, intValue: Int, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.init(featureName: featureName, value: TypedValue.int(intValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)
}

public init(featureName:String, stringValue: String, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.init(featureName: featureName, value: TypedValue.string(stringValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)
}

public init(featureName:String, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.init(featureName: featureName, value: TypedValue.null, enabled: enabled, featureType: featureType, featureDescription: featureDescription)
}

public init(featureName:String, value: TypedValue, enabled: Bool, featureType:String? = nil, featureDescription:String? = nil) {
self.feature = Feature(name: featureName, type: featureType, description: featureDescription)
self.value = value
self.enabled = enabled
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.feature, forKey: .feature)
try container.encode(self.value, forKey: .value)
try container.encode(self.enabled, forKey: .enabled)
}
enum CodingKeys: String, CodingKey {
case feature
case value = "feature_state_value"
case enabled
}

public let feature: Feature
public let value: TypedValue
public let enabled: Bool

public init(featureName: String, boolValue: Bool, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {

Check warning on line 24 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 133 characters (line_length)
self.init(featureName: featureName, value: TypedValue.bool(boolValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)

Check warning on line 25 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 162 characters (line_length)
}

public init(featureName: String, floatValue: Float, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {

Check warning on line 28 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 135 characters (line_length)
self.init(featureName: featureName, value: TypedValue.float(floatValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)

Check warning on line 29 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 164 characters (line_length)
}

public init(featureName: String, intValue: Int, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {

Check warning on line 32 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 131 characters (line_length)
self.init(featureName: featureName, value: TypedValue.int(intValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)

Check warning on line 33 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 160 characters (line_length)
}

public init(featureName: String, stringValue: String, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {

Check warning on line 36 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 137 characters (line_length)
self.init(featureName: featureName, value: TypedValue.string(stringValue), enabled: enabled, featureType: featureType, featureDescription: featureDescription)

Check warning on line 37 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 166 characters (line_length)
}

public init(featureName: String, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {
self.init(featureName: featureName, value: TypedValue.null, enabled: enabled, featureType: featureType, featureDescription: featureDescription)

Check warning on line 41 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 151 characters (line_length)
}

public init(featureName: String, value: TypedValue, enabled: Bool, featureType: String? = nil, featureDescription: String? = nil) {

Check warning on line 44 in FlagsmithClient/Classes/Flag.swift

View workflow job for this annotation

GitHub Actions / swift-lint

Line Length Violation: Line should be 120 characters or less; currently it has 135 characters (line_length)
feature = Feature(name: featureName, type: featureType, description: featureDescription)
self.value = value
self.enabled = enabled
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(feature, forKey: .feature)
try container.encode(value, forKey: .value)
try container.encode(enabled, forKey: .enabled)
}
}
Loading

0 comments on commit 2827e8d

Please sign in to comment.