Added static code analysis with tailor

This commit is contained in:
Pedro Piñera 2016-01-04 18:33:26 +01:00
parent 554ddad7de
commit bbe99eda14
27 changed files with 188 additions and 41 deletions

2
.tailor.yml Normal file
View File

@ -0,0 +1,2 @@
include:
- SugarRecord

View File

@ -7,6 +7,8 @@ before_install:
- curl -OlL "https://github.com/Carthage/Carthage/releases/download/0.11/Carthage.pkg"
- sudo installer -pkg "Carthage.pkg" -target /
- rm "Carthage.pkg"
- brew update
- brew install tailor
xcode_sdk: iphonesimulator
install: true
env:

View File

@ -1130,6 +1130,7 @@
2319B7F41C23FF8F0050ABE8 /* Headers */,
2319B7F51C23FF8F0050ABE8 /* Resources */,
2319B7F61C23FF8F0050ABE8 /* Bump version */,
2318A67D1C3AE449003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1149,6 +1150,7 @@
2319B8191C2400420050ABE8 /* Headers */,
2319B81A1C2400420050ABE8 /* Resources */,
2319B81B1C2400420050ABE8 /* Bump version */,
2318A67B1C3AE439003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1168,6 +1170,7 @@
2319B8501C2400D10050ABE8 /* Headers */,
2319B8511C2400D10050ABE8 /* Resources */,
2319B8521C2400D10050ABE8 /* Bump version */,
2318A6791C3AE428003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1187,6 +1190,7 @@
2319B8A81C2402490050ABE8 /* Headers */,
2319B8A91C2402490050ABE8 /* Resources */,
2319B8AA1C2402490050ABE8 /* Bump version */,
2318A6771C3AE412003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1206,6 +1210,7 @@
3DB2B82A1BDEE187005B7EF2 /* Headers */,
3DB2B82B1BDEE187005B7EF2 /* Resources */,
3D7586481C1615E500F64E22 /* Bump version */,
73E87420F3EF20AA2076D3DE /* Tailor */,
);
buildRules = (
);
@ -1225,6 +1230,7 @@
3DB2B8391BDEE1AD005B7EF2 /* Headers */,
3DB2B83A1BDEE1AD005B7EF2 /* Resources */,
3D7586491C16160A00F64E22 /* Bump version */,
2318A67C1C3AE441003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1244,6 +1250,7 @@
3DB2B8481BDEE1C7005B7EF2 /* Headers */,
3DB2B8491BDEE1C7005B7EF2 /* Resources */,
3D75864A1C16161400F64E22 /* Bump version */,
2318A67A1C3AE430003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1263,6 +1270,7 @@
3DB2B86D1BDEE67C005B7EF2 /* Headers */,
3DB2B86E1BDEE67C005B7EF2 /* Resources */,
3D75864B1C16161D00F64E22 /* Bump version */,
2318A6781C3AE420003ACD13 /* Tailor */,
);
buildRules = (
);
@ -1412,6 +1420,104 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
2318A6771C3AE412003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A6781C3AE420003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A6791C3AE428003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A67A1C3AE430003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A67B1C3AE439003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A67C1C3AE441003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2318A67D1C3AE449003ACD13 /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\ntailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\necho \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
2319B7F61C23FF8F0050ABE8 /* Bump version */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@ -1524,6 +1630,20 @@
shellPath = "/usr/bin/env ruby";
shellScript = "git = `sh /etc/profile; which git`.chomp\napp_build = `#{git} rev-list --all | wc -l`.chomp.to_i\n`/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion #{app_build}\" \"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}\"`\nputs \"Updated #{ENV['TARGET_BUILD_DIR']}/#{ENV['INFOPLIST_PATH']}\"";
};
73E87420F3EF20AA2076D3DE /* Tailor */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Tailor;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if hash tailor 2>/dev/null; then\n tailor --except=leading-whitespace,trailing-whitespace,comment-whitespace,lower-camel-case\nelse\n echo \"warning: Please install Tailor from https://tailor.sh\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -1801,6 +1921,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1828,6 +1949,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1853,6 +1975,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1879,6 +2002,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -1907,6 +2031,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_VERSION = A;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
@ -1935,6 +2060,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_VERSION = A;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
@ -1960,6 +2086,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -1985,6 +2112,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -2100,6 +2228,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -2127,6 +2256,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -2152,6 +2282,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -2178,6 +2309,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@ -2206,6 +2338,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_VERSION = A;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
@ -2234,6 +2367,7 @@
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_VERSION = A;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
@ -2259,6 +2393,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
@ -2284,6 +2419,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = SugarRecord/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

View File

@ -4,10 +4,8 @@ import CoreData
// MARK: - CoreData.ContextParent
extension CoreData {
/**
It defines a context parent
- Coordinator: persistent store coordinator
- Context: managed objcet context
*/
@ -15,5 +13,4 @@ extension CoreData {
case Coordinator(NSPersistentStoreCoordinator)
case Context(NSManagedObjectContext)
}
}

View File

@ -3,4 +3,5 @@ import Foundation
// MARK: - CoreData namespace
public struct CoreData { }
public struct CoreData {
}

View File

@ -4,10 +4,8 @@ import CoreData
// MARK: - CoreData.ObjectModel
public extension CoreData {
/**
It represents a CoreData Object Model
- Named: With the provided name. The model must be in the Main Bundle with the name NAME.xcdatamodel
- Merged: Merging all the data models in the app bundle
- URL: Referenced by the provided URL
@ -19,7 +17,6 @@ public extension CoreData {
/**
Returns the NSManagedObjectModel from the enum
- returns: managed object model
*/
func model() -> NSManagedObjectModel? {
@ -31,14 +28,15 @@ public extension CoreData {
case .URL(let url):
return NSManagedObjectModel(contentsOfURL: url)
}
}
}
}
// MARK: - ObjectModel Extension (CustomStringConvertible)
extension CoreData.ObjectModel: CustomStringConvertible {
public var description: String {
get {
switch self {
@ -48,7 +46,6 @@ extension CoreData.ObjectModel: CustomStringConvertible {
}
}
}
}
@ -58,4 +55,4 @@ extension CoreData.ObjectModel: Equatable {}
public func ==(lhs: CoreData.ObjectModel, rhs: CoreData.ObjectModel) -> Bool {
return lhs.model() == rhs.model()
}
}

View File

@ -35,5 +35,6 @@ extension CoreData {
return options
}
}
}
}
}

View File

@ -27,6 +27,7 @@ public extension CoreData {
return NSURL(fileURLWithPath: documentsDirectory()).URLByAppendingPathComponent(name)
}
}
}
}
@ -51,4 +52,3 @@ extension CoreData.Store: Equatable {}
public func ==(lhs: CoreData.Store, rhs: CoreData.Store) -> Bool {
return lhs.path() == rhs.path()
}

View File

@ -10,4 +10,4 @@ public extension CoreData {
case PersistenceStoreInitialization
}
}
}

View File

@ -29,4 +29,3 @@ extension NSManagedObject {
}
}

View File

@ -13,4 +13,4 @@ class NSManagedObjectMemoryContext: NSManagedObjectContext {
// Do nothing
}
}
}

View File

@ -1,4 +1,4 @@
import Foundation
import ReactiveCocoa
extension CoreDataDefaultStorage: ReactiveStorage {}
extension CoreDataDefaultStorage: ReactiveStorage {}

View File

@ -62,17 +62,17 @@ public struct Request<T: Entity> {
// MARK: - Public Builder Methods
public func filteredWith(predicate predicate: NSPredicate) -> Request<T> {
public func filteredWith(predicate predicate: NSPredicate) -> Request<T> {
return self
.request(withPredicate: predicate)
}
public func filteredWith(key: String, equalTo value: String) -> Request<T>{
public func filteredWith(key: String, equalTo value: String) -> Request<T> {
return self
.request(withPredicate: NSPredicate(format: "\(key) == %@", value))
}
public func sortedWith(sortDescriptor sortDescriptor: NSSortDescriptor) -> Request<T> {
public func sortedWith(sortDescriptor sortDescriptor: NSSortDescriptor) -> Request<T> {
return self
.request(withSortDescriptor: sortDescriptor)
}
@ -102,4 +102,5 @@ public struct Request<T: Entity> {
func request(withSortDescriptor sortDescriptor: NSSortDescriptor) -> Request<T> {
return Request<T>(context, sortDescriptor: sortDescriptor, predicate: predicate)
}
}

View File

@ -70,4 +70,5 @@ public extension Storage {
func fetch<T: Entity>(request: Request<T>) throws -> [T] {
return try self.mainContext.fetch(request)
}
}
}

View File

@ -18,4 +18,5 @@ extension Request: NSSortDescriptorConvertible {
public init(sortDescriptor: NSSortDescriptor) {
self = Request(sortDescriptor: sortDescriptor)
}
}
}

View File

@ -3,4 +3,4 @@ import Foundation
/**
* Proxy protocol for store entities
*/
public protocol Entity {}
public protocol Entity {}

View File

@ -16,4 +16,5 @@ public protocol NSPredicateConvertible {
/// Predicate
var predicate: NSPredicate? { get }
}
}

View File

@ -16,4 +16,5 @@ public protocol NSSortDescriptorConvertible {
/// Sort descriptor
var sortDescriptor: NSSortDescriptor? { get }
}
}

View File

@ -23,15 +23,19 @@ public protocol Requestable {
}
public extension Requestable where Self: Context {
func requestContext() -> Context {
return self
}
func request<T>(model: T.Type) -> Request<T> {
return Request<T>(self)
}
}
public extension Requestable where Self:Storage {
func requestContext() -> Context {
return self.mainContext
}
@ -39,4 +43,5 @@ public extension Requestable where Self:Storage {
func request<T>(model: T.Type) -> Request<T> {
return Request<T>(self.mainContext)
}
}
}

View File

@ -8,4 +8,4 @@ import Foundation
func documentsDirectory() -> String {
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
return paths[0]
}
}

View File

@ -1,6 +1,4 @@
import Foundation
public enum ReactiveError: ErrorType {
}
public enum ReactiveError: ErrorType {}

View File

@ -274,4 +274,5 @@ public extension ReactiveStorage where Self: Storage {
return NopDisposable.instance
})
}
}
}

View File

@ -4,4 +4,4 @@ import RealmSwift
// MARK: - Object Extension (Entity)
extension Object: Entity {}
extension Object: Entity {}

View File

@ -11,4 +11,4 @@ extension Entity {
}
}
}
}

View File

@ -4,6 +4,7 @@ import RealmSwift
// MARK: - Results extension
extension Results {
func toArray() -> [T] {
var array = [T]()
for var i = 0; i < count; i++ {
@ -11,4 +12,5 @@ extension Results {
}
return array
}
}
}

View File

@ -1,3 +1,3 @@
import Foundation
extension RealmDefaultStorage: ReactiveStorage {}
extension RealmDefaultStorage: ReactiveStorage {}

View File

@ -79,15 +79,16 @@ public class RealmDefaultStorage: Storage {
- parameter operation: Operation to be executed.
*/
public func operation(operation: (context: Context, save: () -> Void) -> Void) {
let _context: Realm = self.saveContext as! Realm
_context.beginWrite()
let context: Realm = self.saveContext as Realm
context.beginWrite()
var save: Bool = false
operation(context: _context, save: { save = true })
if (save) {
_ = try? _context.commitWrite()
operation(context: context, save: { save = true })
if save {
_ = try? context.commitWrite()
}
else {
_context.cancelWrite()
context.cancelWrite()
}
}
}
}