Skip to content

Commit

Permalink
swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNavel committed Apr 6, 2018
1 parent 39f9937 commit a413fce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ custom_rules:
message: "Source code should not contains placeholders"
severity: warning

variable_name:
identifier_name:
min_length:
warning: 1
excluded:
- id
nesting:
type_level:
warning: 3

line_length:
- 100 # warning
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.1
// swift-tools-version:4.0

import PackageDescription

Expand Down
3 changes: 1 addition & 2 deletions Sources/SquirrelJSON/JSON+ExpressibleBy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

// MARK: String
extension JSON : ExpressibleByStringLiteral {
extension JSON: ExpressibleByStringLiteral {

/// Construct from string literal
///
Expand All @@ -30,7 +30,6 @@ extension JSON : ExpressibleByStringLiteral {
}
}


// MARK: - Dictionary
extension JSON: ExpressibleByDictionaryLiteral {

Expand Down
8 changes: 5 additions & 3 deletions Sources/SquirrelJSON/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ extension JSON {
}
}


// MARK: - Codable
public extension JSON {
/// Constructs from encodable object
Expand Down Expand Up @@ -427,7 +426,6 @@ public extension JSON {
let encoder = JSONEncoder()
return try? encoder.encode(self)
}

}

// MARK: - Additive functions
Expand Down Expand Up @@ -479,7 +477,11 @@ public extension JSON {
var serialize: Any? {
switch type {
case .array(let array):
return array.compactMap({ $0.serialize })
#if swift(>=4.1)
return array.compactMap { $0.serialize }
#else
return array.flatMap { $0.serialize }
#endif
case .bool(let bool):
return bool
case .date(let date):
Expand Down
6 changes: 6 additions & 0 deletions Sources/SquirrelJSON/JSONCoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public struct JSONCoding {
}
}

// swiftlint:disable function_body_length

/// Encode object to json representation
///
/// - Parameter object: object to encode
Expand Down Expand Up @@ -130,7 +132,11 @@ public struct JSONCoding {
case let v as Date:
return v.timeIntervalSince1970.description
case let arr as [Any]:
#if swift(>=4.1)
return arr.compactMap { encode(object: $0) }
#else
return arr.flatMap { encode(object: $0) }
#endif
case let dic as [String: Any]:
return dic.mapValues { return encode(object: $0) }
default:
Expand Down

0 comments on commit a413fce

Please sign in to comment.