Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint warnings #trivial #58

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/Core/ObjCADTRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ struct ObjCADTRenderer: ObjCFileRenderer {
}()
case .float: return "Float"
case .integer: return "Integer"
case .enumT(.integer(_)): return "IntegerEnum" // TODO: Allow custom names
case .enumT(.integer): return "IntegerEnum" // TODO: Allow custom names
case .boolean: return "Boolean"
case .array(itemType: _): return "Array"
case .map(valueType: _): return "Dictionary"
case .string(.some(.uri)): return "URL"
case .string(.some(.dateTime)): return "Date"
case .string(.some(_)), .string(.none): return "String"
case .enumT(.string(_)): return "StringEnum" // TODO: Allow custom names
case .string(.some), .string(.none): return "String"
case .enumT(.string): return "StringEnum" // TODO: Allow custom names
case .oneOf(types:_):
fatalError("Nested oneOf types are unsupported at this time. Please file an issue if you require this. \(aSchema)")
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/ObjCFileRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension ObjCFileRenderer {
return "double"
case .boolean:
return "BOOL"
case .enumT(_):
case .enumT:
return enumTypeName(propertyName: param, className: className)
case .object(let objSchemaRoot):
return "\(objSchemaRoot.className(with: params)) *"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/ObjectiveCBuilderExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension ObjCModelRenderer {
return ObjCIR.ifStmt("modelObject.\(self.dirtyPropertiesIVarName).\(dirtyPropertyOption(propertyName: param, className: self.className))") {
func loop(_ schema: Schema) -> [String] {
switch schema {
case .object(_):
case .object:
return [
"id value = modelObject.\(param.snakeCaseToPropertyName());",
ObjCIR.ifElseStmt("value != nil") {[
Expand Down
6 changes: 3 additions & 3 deletions Sources/Core/ObjectiveCDebugExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ extension ObjCFileRenderer {
fileprivate func renderDebugStatement(_ param: String, _ schema: Schema) -> String {
let propIVarName = "_\(param.snakeCaseToPropertyName())"
switch schema {
case .enumT(.string(_)):
case .enumT(.string):
return enumToStringMethodName(propertyName: param, className: self.className) + "(\(propIVarName))"
case .boolean, .float, .integer:
return "@(\(propIVarName))"
case .enumT(.integer(_)):
case .enumT(.integer):
return "@(\(propIVarName))"
case .string(format: _):
return propIVarName
case .array(itemType: _):
return propIVarName
case .map(valueType: _):
return propIVarName
case .object(_):
case .object:
return propIVarName
case .oneOf(types: _):
return propIVarName
Expand Down
8 changes: 4 additions & 4 deletions Sources/Core/ObjectiveCEqualityExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension ObjCFileRenderer {
func renderHash() -> ObjCIR.Method {
func schemaHashStatement(with param: Parameter, for schema: Schema) -> String {
switch schema {
case .enumT(_), .integer:
case .enumT, .integer:
// - The value equality statement is sufficient for equality testing
// - All enum types are treated as Integers so we do not need to treat String Enumerations differently
return "(NSUInteger)_\(param)"
Expand Down Expand Up @@ -55,11 +55,11 @@ extension ObjCFileRenderer {
func renderIsEqualToClass() -> ObjCIR.Method {
func schemaIsEqualStatement(with param: Parameter, for schema: Schema) -> String {
switch schema {
case .integer, .float, .enumT(_), .boolean:
case .integer, .float, .enumT, .boolean:
// - The value equality statement is sufficient for equality testing
// - All enum types are treated as Integers so we do not need to treat String Enumerations differently
return ""
case .map(_):
case .map:
return ObjCIR.msg("_\(param)", ("isEqualToDictionary", "anObject.\(param)"))
case .string(format: .some(.dateTime)):
return ObjCIR.msg("_\(param)", ("isEqualToDate", "anObject.\(param)"))
Expand All @@ -69,7 +69,7 @@ extension ObjCFileRenderer {
.string(format: .some(.ipv4)),
.string(format: .some(.ipv6)):
return ObjCIR.msg("_\(param)", ("isEqualToString", "anObject.\(param)"))
case .oneOf(types:_), .object(_), .array(_), .string(format: .some(.uri)):
case .oneOf(types:_), .object, .array, .string(format: .some(.uri)):
return ObjCIR.msg("_\(param)", ("isEqual", "anObject.\(param)"))
case .reference(with: let ref):
switch ref.force() {
Expand Down
12 changes: 6 additions & 6 deletions Sources/Core/ObjectiveCIR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extension SchemaObjectRoot {
extension Schema {
var isObjCPrimitiveType: Bool {
switch self {
case .boolean, .integer, .enumT(_), .float:
case .boolean, .integer, .enumT, .float:
return true
default:
return false
Expand All @@ -104,7 +104,7 @@ extension Schema {
switch self {
case .string(format: .none):
return .copy
case .boolean, .float, .integer, .enumT(_):
case .boolean, .float, .integer, .enumT:
return .assign
default:
return .strong
Expand Down Expand Up @@ -295,7 +295,7 @@ public struct ObjCIR {

func renderHeader() -> [String] {
switch self {
case .structDecl(_, _):
case .structDecl:
// skip structs in header
return []
case .macro(let macro):
Expand Down Expand Up @@ -348,7 +348,7 @@ public struct ObjCIR {
fields.sorted().map { $0.indent() }.joined(separator: "\n"),
"};"
]
case .macro(_):
case .macro:
// skip macro in impl
return []
case .imports(let classNames, let myName, _):
Expand All @@ -375,9 +375,9 @@ public struct ObjCIR {
].map { $0.trimmingCharacters(in: CharacterSet.whitespaces) }.filter { $0 != "" }
case .function(let method):
return method.render()
case .enumDecl(_, _):
case .enumDecl:
return []
case .optionSetEnum(_, _):
case .optionSetEnum:
return []
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/ObjectiveCInitExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extension ObjCModelRenderer {
return ObjCIR.ifStmt("[\(rawObjectName) isKindOfClass:[NSNumber class]] && (\(encodingConditions.joined(separator: " ||\n")))") {
return transformToADTInit(renderPropertyInit(propertyToAssign, rawObjectName, schema: .float, firstName: firstName, counter: counter))
}
case .integer, .enumT(.integer(_)):
case .integer, .enumT(.integer):
let encodingConditions = [
"strcmp([\(rawObjectName) objCType], @encode(int)) == 0",
"strcmp([\(rawObjectName) objCType], @encode(unsigned int)) == 0",
Expand Down Expand Up @@ -202,7 +202,7 @@ extension ObjCModelRenderer {
return ObjCIR.ifStmt("[\(rawObjectName) isKindOfClass:[NSString class]] && [[NSValueTransformer valueTransformerForName:\(dateValueTransformerKey)] transformedValue:\(rawObjectName)] != nil") {
return transformToADTInit(renderPropertyInit(propertyToAssign, rawObjectName, schema: schema, firstName: firstName, counter: counter))
}
case .string(.some(_)), .string(.none), .enumT(.string(_)):
case .string(.some), .string(.none), .enumT(.string):
return ObjCIR.ifStmt("[\(rawObjectName) isKindOfClass:[NSString class]]") {
return transformToADTInit(renderPropertyInit(propertyToAssign, rawObjectName, schema: schema, firstName: firstName, counter: counter))
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/Core/ObjectiveCNSCodingExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension ObjCFileRenderer {
return Set(["NSDate"])
case .string(format: .some(.uri)):
return Set(["NSURL"])
case .integer, .float, .boolean, .enumT(_):
case .integer, .float, .boolean, .enumT:
return Set(["NSNumber"])
case .object(let objSchemaRoot):
return Set([objSchemaRoot.className(with: self.params)])
Expand All @@ -107,15 +107,15 @@ extension ObjCFileRenderer {
fileprivate func decodeStatement(_ param: String, _ schema: Schema) -> String {
let propIVarName = "_\(param.snakeCaseToPropertyName())"
return "\(propIVarName) = " + { switch schema {
case .enumT(_):
case .enumT:
return "[aDecoder decodeIntegerForKey:\(param.objcLiteral())];"
case .boolean:
return "[aDecoder decodeBoolForKey:\(param.objcLiteral())];"
case .float:
return "[aDecoder decodeDoubleForKey:\(param.objcLiteral())];"
case .integer:
return "[aDecoder decodeIntegerForKey:\(param.objcLiteral())];"
case .string(_), .map(_), .array(_), .oneOf(_), .reference(_), .object(_):
case .string, .map, .array, .oneOf, .reference, .object:
let refObjectClasses = referencedObjectClasses(schema).map { "[\($0) class]" }
let refObjectClassesString = refObjectClasses.count == 1 ? refObjectClasses.joined(separator: ",") : "[NSSet setWithArray:\(refObjectClasses.objcLiteral())]"
if refObjectClasses.count == 0 { fatalError("Can't determine class for decode for \(schema)") }
Expand All @@ -131,15 +131,15 @@ extension ObjCFileRenderer {
func encodeStatement(_ param: String, _ schema: Schema) -> String {
let propGetter = "self.\(param.snakeCaseToPropertyName())"
switch schema {
case .enumT(_):
case .enumT:
return "[aCoder encodeInteger:\(propGetter) forKey:\(param.objcLiteral())];"
case .boolean:
return "[aCoder encodeBool:\(propGetter) forKey:\(param.objcLiteral())];"
case .float:
return "[aCoder encodeDouble:\(propGetter) forKey:\(param.objcLiteral())];"
case .integer:
return "[aCoder encodeInteger:\(propGetter) forKey:\(param.objcLiteral())];"
case .string(_), .map(_), .array(_), .oneOf(_), .reference(_), .object(_):
case .string, .map, .array, .oneOf, .reference, .object:
return "[aCoder encodeObject:\(propGetter) forKey:\(param.objcLiteral())];"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ extension Schema {
return itemType?.deps() ?? []
case .map(valueType: let valueType):
return valueType?.deps() ?? []
case .integer, .float, .boolean, .string, .enumT(_):
case .integer, .float, .boolean, .string, .enumT:
return []
case .oneOf(types: let types):
return types.map { type in type.deps() }.reduce([]) { $0.union($1) }
Expand Down