Skip to content

Commit

Permalink
Merge pull request #3 from ride/null_warnings
Browse files Browse the repository at this point in the history
Fix nullability issues
  • Loading branch information
bithavoc committed Nov 16, 2015
2 parents d79fd9b + f3ff2a3 commit c6ca3d0
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 47 deletions.
3 changes: 2 additions & 1 deletion RMErrors.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/AFNetworking/AFNetworking'
s.authors = { 'Bithavoc' => 'im@bithavoc.io' }
s.source = { :git => 'https://github.com/ride/RMErrors.git', :tag=>s.version }

s.requires_arc = true

s.public_header_files = 'RMErrors/*.{h}'
s.source_files = 'RMErrors/*.{h,m}'

s.ios.deployment_target = '7.0'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
s.watchos.deployment_target = '2.0'
end
2 changes: 1 addition & 1 deletion RMErrors/RMErrorCodeBoundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

@protocol RMErrorCodeBoundary <NSObject>

Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorCodeDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorCodeBoundary.h"
#import "RMErrorDescription.h"

Expand Down
5 changes: 4 additions & 1 deletion RMErrors/RMErrorCodeDefinition.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
static NSString *const RMErrorCodeDefinitionAttributeTransientName= @"transient";

@implementation RMErrorCodeDefinition
@synthesize boundary = _boundary;
@synthesize friendlyMessage = _friendlyMessage;
@synthesize transient = _transient;

- (instancetype)init {
return [self initWithBoundary:nil friendlyMessage:nil transient:NO];
}

- (instancetype)initWithBoundary:(id<RMErrorCodeBoundary>)boundary
friendlyMessage:(NSString *)friendlyMessage transient:(BOOL)transient {
if(self = [super init]) {
if((self = [super init])) {
NSParameterAssert(boundary);
_boundary = boundary;
_friendlyMessage = friendlyMessage;
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorCodeRangeBoundary.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorCodeBoundary.h"

extern NSInteger const RMErrorCodeRangeBoundaryDefaultLimit;
Expand Down
6 changes: 4 additions & 2 deletions RMErrors/RMErrorCodeRangeBoundary.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
static NSString *const RMErrorCodeRangeBoundaryPatternSeparator = @"..";

@implementation RMErrorCodeRangeBoundary
@synthesize upperLimit = _upperLimit;
@synthesize lowerLimit = _lowerLimit;

- (instancetype)init {
return [self initWithLower:RMErrorCodeRangeBoundaryDefaultLimit andUpper:RMErrorCodeRangeBoundaryDefaultLimit];
}

- (instancetype)initWithLower:(NSInteger)lower andUpper:(NSInteger)upper {
if(self = [super init]) {
if((self = [super init])) {
_lowerLimit = lower;
_upperLimit = upper;
}
return self;
}

- (BOOL)matches:(NSInteger)code {
return code >= _lowerLimit && code <= _upperLimit;
return code >= self.lowerLimit && code <= self.upperLimit;
}

+ (instancetype)boundaryWithPattern:(NSString *)pattern {
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorCodeDefinition.h"
#import "RMErrorDescription.h"

Expand Down
3 changes: 2 additions & 1 deletion RMErrors/RMErrorCodes.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ @interface RMErrorCodes()

@implementation RMErrorCodes
@dynamic definitions;
@synthesize codes;

- (instancetype)init {
return [self initWithDictionary:nil];
}

- (instancetype)initWithDictionary:(NSDictionary *)domains {
if(self = [super init]) {
if((self = [super init])) {
self.codes = [NSMutableArray array];
}
return self;
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

extern NSString *const RMErrorDescriptionContentFriendlyMessageKey;
extern NSString *const RMErrorDescriptionContentTransientKey;
Expand Down
10 changes: 5 additions & 5 deletions RMErrors/RMErrorDescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
NSString *const RMErrorDescriptionContentCodeKey = @"code";

@implementation RMErrorDescription
@synthesize transient = _transient;
@synthesize friendlyMessage = _friendlyMessage;
@synthesize code = _code;

- (instancetype)init {
if(self = [self initWithFriendlyMessage:nil transient:NO code:-1]) {

}
return self;
return [self initWithFriendlyMessage:nil transient:NO code:-1];
}

- (instancetype)initWithFriendlyMessage:(NSString *)friendlyMessage transient:(BOOL)transient code:(NSInteger)code {
if(self = [super init]) {
if((self = [super init])) {
_friendlyMessage = friendlyMessage;
_transient = transient;
_code = code;
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorDomainDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorCodes.h"
#import "RMErrorCodeDefinition.h"

Expand Down
5 changes: 4 additions & 1 deletion RMErrors/RMErrorDomainDefinition.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
static NSString *const RMErrorDomainDefinitionContentDefaultCodeKey = @"(default)";

@implementation RMErrorDomainDefinition
@synthesize name = _name;
@synthesize codes = _codes;
@synthesize defaultCode = _defaultCode;

- (instancetype)init {
return [self initWithName:nil];
}

- (instancetype)initWithName:(NSString *)name {
if(self = [super init]) {
if((self = [super init])) {
NSParameterAssert(name);
_name = name;
_codes = [[RMErrorCodes alloc] init];
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorDomains.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorDomainDefinition.h"
#import "RMErrorDescription.h"

Expand Down
3 changes: 2 additions & 1 deletion RMErrors/RMErrorDomains.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ @interface RMErrorDomains()

@implementation RMErrorDomains
@dynamic definitions;
@synthesize domains;

- (instancetype)init {
return [self initWithDictionary:nil];
}

- (instancetype)initWithDictionary:(NSDictionary *)domains {
if(self = [super init]) {
if((self = [super init])) {
self.domains = [NSMutableArray array];
}
return self;
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorTransformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;

/**
Implemented by error transformations
Expand Down
2 changes: 1 addition & 1 deletion RMErrors/RMErrorTransformations.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorTransformation.h"

/**
Expand Down
3 changes: 2 additions & 1 deletion RMErrors/RMErrorTransformations.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ @interface RMErrorTransformations()
@end

@implementation RMErrorTransformations
@synthesize list;

- (instancetype)init {
if(self = [super init]) {
if((self = [super init])) {
self.list = [NSMutableArray array];
}
return self;
Expand Down
16 changes: 8 additions & 8 deletions RMErrors/RMErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
// Copyright (c) 2015 Ride. All rights reserved.
//

#import <Foundation/Foundation.h>
@import Foundation;
#import "RMErrorDomains.h"
#import "RMErrorDescription.h"
#import "RMErrorTransformations.h"
#import "RMErrorCodes.h"

extern NSString *const RMErrorsContentDomainsKey;
extern NSString *const RMErrorsContentDefaultKey;
extern NSString *const RMErrorsDefaultFileName;
extern NSString *__nonnull const RMErrorsContentDomainsKey;
extern NSString *__nonnull const RMErrorsContentDefaultKey;
extern NSString *__nonnull const RMErrorsDefaultFileName;

@interface RMErrors : NSObject

/**
Error Domain definitions
*/
@property (nonatomic, readonly) RMErrorDomains* domains;
@property (nonatomic, nonnull, readonly) RMErrorDomains* domains;

/**
A collection of transformation to run prior describing the original error.
*/
@property (nonatomic, readonly) RMErrorTransformations *transformations;
@property (nonatomic, nonnull, readonly) RMErrorTransformations *transformations;

/**
Default error description in case is not found in domains and errors.
*/
@property (nonatomic) RMErrorDescription *defaultDescription;
@property (nonatomic, nullable) RMErrorDescription *defaultDescription;

/**
Load from parsed RMErrors.plist
Expand All @@ -53,6 +53,6 @@ extern NSString *const RMErrorsDefaultFileName;
/**
Process an error and returns a description
*/
- (RMErrorDescription *)describe:(NSError *)error;
- (nullable RMErrorDescription *)describe:(nonnull NSError *)error;

@end
7 changes: 5 additions & 2 deletions RMErrors/RMErrors.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
NSString *const RMErrorsDefaultFileName = @"RMErrors";

@implementation RMErrors
@synthesize domains = _domains;
@synthesize transformations = _transformations;
@synthesize defaultDescription = _defaultDescription;

- (instancetype)init {
if(self = [super init]) {
if((self = [super init])) {
_domains = [[RMErrorDomains alloc] init];
_transformations = [[RMErrorTransformations alloc] init];
}
Expand All @@ -30,7 +33,7 @@ - (void)load:(NSDictionary *)content {
}
}

- (RMErrorDescription *)describe:(NSError *)error {
- (nullable RMErrorDescription *)describe:(NSError *)error {
NSError *transformed = [self.transformations transform:error];
RMErrorDescription *description = [self.domains describe:transformed];
if(description) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Podfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
xcodeproj 'RMErrorsTests'
workspace '../RMErrors'
inhibit_all_warnings!
use_frameworks!

def common_pods
pod 'RMErrors', :path => '../'
end

target :ios do
platform :ios, '7.0'
platform :ios, '8.0'
link_with 'RMErrorsIOSTests'
common_pods
end
Expand Down
20 changes: 12 additions & 8 deletions Tests/RMErrorsTests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
1E9597D51BF2FAFC004C4851 /* RMErrorsTransformationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E84A7EA1BF29F2000D1532C /* RMErrorsTransformationTest.m */; };
1EFF20BB1BF63963002A65C1 /* RMErrors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1EFF20BA1BF63963002A65C1 /* RMErrors.plist */; };
1EFF20BC1BF63966002A65C1 /* RMErrors.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1EFF20BA1BF63963002A65C1 /* RMErrors.plist */; };
5525CEEDC150C468C8DF5683 /* libPods-ios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EDA1BC800683D1E509E11F3E /* libPods-ios.a */; };
BB7CD182732BEBE7C717E0B7 /* libPods-osx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D7B757FF1A5FF486760FE18 /* libPods-osx.a */; };
4C57D94F189E98E8470F6437 /* Pods_osx.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8764C77DB944C27DB9414DF2 /* Pods_osx.framework */; };
6150E705DB159ECDB2520F37 /* Pods_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BBC31B3CBFB36F4316ECC00 /* Pods_ios.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -46,11 +46,11 @@
1E9597C91BF2FAEA004C4851 /* RMErrorsOSXTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RMErrorsOSXTests.m; sourceTree = "<group>"; };
1E9597CB1BF2FAEA004C4851 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1EFF20BA1BF63963002A65C1 /* RMErrors.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = RMErrors.plist; sourceTree = "<group>"; };
2BBC31B3CBFB36F4316ECC00 /* Pods_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
35578B838AB067E90CF97C5D /* Pods-osx.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-osx.release.xcconfig"; path = "Pods/Target Support Files/Pods-osx/Pods-osx.release.xcconfig"; sourceTree = "<group>"; };
7767EB1B31CE7690808120B9 /* Pods-ios.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ios/Pods-ios.debug.xcconfig"; sourceTree = "<group>"; };
8D7B757FF1A5FF486760FE18 /* libPods-osx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-osx.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8764C77DB944C27DB9414DF2 /* Pods_osx.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_osx.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D96A260D7F7B8FD3663122A1 /* Pods-osx.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-osx.debug.xcconfig"; path = "Pods/Target Support Files/Pods-osx/Pods-osx.debug.xcconfig"; sourceTree = "<group>"; };
EDA1BC800683D1E509E11F3E /* libPods-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; };
FDC8FB2FD40BCD8294ADF04E /* Pods-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios.release.xcconfig"; path = "Pods/Target Support Files/Pods-ios/Pods-ios.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -60,15 +60,15 @@
buildActionMask = 2147483647;
files = (
1E84A7E01BF29E1300D1532C /* Foundation.framework in Frameworks */,
5525CEEDC150C468C8DF5683 /* libPods-ios.a in Frameworks */,
6150E705DB159ECDB2520F37 /* Pods_ios.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1E9597C41BF2FAEA004C4851 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BB7CD182732BEBE7C717E0B7 /* libPods-osx.a in Frameworks */,
4C57D94F189E98E8470F6437 /* Pods_osx.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -109,8 +109,8 @@
isa = PBXGroup;
children = (
1E84A7DF1BF29E1300D1532C /* Foundation.framework */,
EDA1BC800683D1E509E11F3E /* libPods-ios.a */,
8D7B757FF1A5FF486760FE18 /* libPods-osx.a */,
2BBC31B3CBFB36F4316ECC00 /* Pods_ios.framework */,
8764C77DB944C27DB9414DF2 /* Pods_osx.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -384,13 +384,17 @@
1E84A7D01BF29BE000D1532C /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
};
name = Debug;
};
1E84A7D11BF29BE000D1532C /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
};
name = Release;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests/RMErrorCodesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

#import <XCTest/XCTest.h>
#import "RMErrorCodes.h"
#import "RMErrorCodeRangeBoundary.h"
#import <RMErrors/RMErrorCodes.h>
#import <RMErrors/RMErrorCodeRangeBoundary.h>

@interface RMErrorCodesTest : XCTestCase {
NSDictionary *_content;
Expand Down
Loading

0 comments on commit c6ca3d0

Please sign in to comment.