Skip to content

Commit

Permalink
Merge pull request facebookincubator#461 from facebook/nlutsenko.lint
Browse files Browse the repository at this point in the history
Lint, cleanup and fix analyzer warning.
  • Loading branch information
nlutsenko committed Aug 24, 2016
2 parents 00a8a66 + eff1db8 commit d092127
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 112 deletions.
11 changes: 5 additions & 6 deletions SocketRocket.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = "SocketRocket"
s.name = 'SocketRocket'
s.version = '0.5.1'
s.summary = 'A conforming WebSocket (RFC 6455) client library.'
s.summary = 'A conforming WebSocket (RFC 6455) client library for iOS, macOS and tvOS.'
s.homepage = 'https://github.com/facebook/SocketRocket'
s.authors = 'Square'
s.authors = { 'Nikita Lutsenko' => 'nlutsenko@me.com', 'Dan Federman' => 'federman@squareup.com', 'Mike Lewis' => 'mikelikespie@gmail.com' }
s.license = 'BSD'
s.source = { :git => 'https://github.com/facebook/SocketRocket.git', :tag => s.version.to_s }
s.requires_arc = true

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

s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8'
Expand All @@ -18,6 +18,5 @@ Pod::Spec.new do |s|
s.ios.frameworks = 'CFNetwork', 'Security'
s.osx.frameworks = 'CoreServices', 'Security'
s.tvos.frameworks = 'CFNetwork', 'Security'

s.libraries = "icucore"
s.libraries = 'icucore'
end
32 changes: 0 additions & 32 deletions SocketRocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@
2D42275D1BB4358C000C1A6C /* Sources */,
2D42275E1BB4358C000C1A6C /* Frameworks */,
2D42275F1BB4358C000C1A6C /* Headers */,
2D4227601BB4358C000C1A6C /* Resources */,
);
buildRules = (
);
Expand All @@ -869,7 +868,6 @@
3345DC831C52ACD70083CCB8 /* Sources */,
3345DC851C52ACD70083CCB8 /* Frameworks */,
3345DC891C52ACD70083CCB8 /* Headers */,
3345DC8C1C52ACD70083CCB8 /* Resources */,
);
buildRules = (
);
Expand All @@ -887,7 +885,6 @@
81D647601D2CA78800690609 /* Sources */,
81D647721D2CA78800690609 /* Frameworks */,
81D647761D2CA78800690609 /* Headers */,
81D647891D2CA78800690609 /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -925,7 +922,6 @@
F6396B85153E67EC00345B5E /* Sources */,
F668C87C153E91210044DBAC /* Frameworks */,
F668C87D153E91210044DBAC /* Headers */,
F668C87E153E91210044DBAC /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -986,27 +982,6 @@
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
2D4227601BB4358C000C1A6C /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
3345DC8C1C52ACD70083CCB8 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
81D647891D2CA78800690609 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F62417E114D52F3C003CE997 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -1017,13 +992,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F668C87E153E91210044DBAC /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F6BDA7FF145900D200FE3253 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down
2 changes: 1 addition & 1 deletion SocketRocket/Internal/Delegate/SRDelegateController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import <Foundation/Foundation.h>

#import "SRWebSocket.h"
#import <SocketRocket/SRWebSocket.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion SocketRocket/Internal/Delegate/SRDelegateController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @interface SRDelegateController ()

@property (nonatomic, strong, readonly) dispatch_queue_t accessQueue;

@property (atomic, readwrite) SRDelegateAvailableMethods availableDelegateMethods;
@property (atomic, assign, readwrite) SRDelegateAvailableMethods availableDelegateMethods;

@end

Expand Down
2 changes: 1 addition & 1 deletion SocketRocket/Internal/NSRunLoop+SRWebSocketPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
#import <SocketRocket/NSRunLoop+SRWebSocket.h>

// Empty function that force links the object file for the category.
extern void import_NSRunLoop_SRWebSocket();
extern void import_NSRunLoop_SRWebSocket(void);
2 changes: 1 addition & 1 deletion SocketRocket/Internal/NSURLRequest+SRWebSocketPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
#import <SocketRocket/NSURLRequest+SRWebSocket.h>

// Empty function that force links the object file for the category.
extern void import_NSURLRequest_SRWebSocket();
extern void import_NSURLRequest_SRWebSocket(void);
22 changes: 11 additions & 11 deletions SocketRocket/Internal/Proxy/SRProxyConnect.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
//

#import "SRProxyConnect.h"
#import "SRError.h"

#import "NSRunLoop+SRWebSocket.h"
#import "SRURLUtilities.h"
#import "SRLog.h"
#import "SRConstants.h"
#import "SRError.h"
#import "SRLog.h"
#import "SRURLUtilities.h"

@interface SRProxyConnect() <NSStreamDelegate>

Expand Down Expand Up @@ -165,14 +166,14 @@ - (void)_configureProxy
if ([proxyType isEqualToString:(NSString *)kCFProxyTypeAutoConfigurationURL]) {
NSURL *pacURL = settings[(NSString *)kCFProxyAutoConfigurationURLKey];
if (pacURL) {
[self _fetchPAC:pacURL];
[self _fetchPAC:pacURL withProxySettings:proxySettings];
return;
}
}
if ([proxyType isEqualToString:(__bridge NSString *)kCFProxyTypeAutoConfigurationJavaScript]) {
NSString *script = settings[(__bridge NSString *)kCFProxyAutoConfigurationJavaScriptKey];
if (script) {
[self _runPACScript:script];
[self _runPACScript:script withProxySettings:proxySettings];
return;
}
}
Expand Down Expand Up @@ -208,7 +209,7 @@ - (void)_readProxySettingWithType:(NSString *)proxyType settings:(NSDictionary *
}
}

- (void)_fetchPAC:(NSURL *)PACurl
- (void)_fetchPAC:(NSURL *)PACurl withProxySettings:(NSDictionary *)proxySettings
{
SRDebugLog(@"SRWebSocket fetchPAC:%@", PACurl);

Expand All @@ -221,7 +222,7 @@ - (void)_fetchPAC:(NSURL *)PACurl
if (error) {
[self _openConnection];
} else {
[self _runPACScript:script];
[self _runPACScript:script withProxySettings:proxySettings];
}
return;
}
Expand All @@ -240,14 +241,14 @@ - (void)_fetchPAC:(NSURL *)PACurl
__strong typeof(wself) sself = wself;
if (!error) {
NSString *script = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[sself _runPACScript:script];
[sself _runPACScript:script withProxySettings:proxySettings];
} else {
[sself _openConnection];
}
}] resume];
}

- (void)_runPACScript:(NSString *)script
- (void)_runPACScript:(NSString *)script withProxySettings:(NSDictionary *)proxySettings
{
if (!script) {
[self _openConnection];
Expand All @@ -258,8 +259,7 @@ - (void)_runPACScript:(NSString *)script
// Work around <rdar://problem/5530166>. This dummy call to
// CFNetworkCopyProxiesForURL initialise some state within CFNetwork
// that is required by CFNetworkCopyProxiesForAutoConfigurationScript.
NSDictionary *empty = nil;
CFBridgingRelease(CFNetworkCopyProxiesForURL((__bridge CFURLRef)_url, (__bridge CFDictionaryRef)empty));
CFBridgingRelease(CFNetworkCopyProxiesForURL((__bridge CFURLRef)_url, (__bridge CFDictionaryRef)proxySettings));

// Obtain the list of proxies by running the autoconfiguration script
CFErrorRef err = NULL;
Expand Down
14 changes: 4 additions & 10 deletions SocketRocket/Internal/RunLoop/SRRunLoopThread.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@
#import "SRRunLoopThread.h"

@interface SRRunLoopThread ()
{
dispatch_group_t _waitGroup;
}

@property (nonatomic, strong, readwrite) NSRunLoop *runLoop;

@end

@implementation SRRunLoopThread {
dispatch_group_t _waitGroup;
}

- (void)dealloc
{
#if !OS_OBJECT_USE_OBJC_RETAIN_RELEASE
dispatch_release(_waitGroup);
#endif
}
@implementation SRRunLoopThread

+ (instancetype)sharedThread
{
Expand Down
1 change: 0 additions & 1 deletion SocketRocket/Internal/SRConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ typedef NS_ENUM(NSInteger, SROpCode)
Default buffer size that is used for reading/writing to streams.
*/
extern size_t SRDefaultBufferSize(void);

3 changes: 2 additions & 1 deletion SocketRocket/Internal/Security/SRPinningSecurityPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
//

#import <Foundation/Foundation.h>
#import "SRSecurityPolicy.h"

#import <SocketRocket/SRSecurityPolicy.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
1 change: 1 addition & 0 deletions SocketRocket/Internal/Utilities/SRError.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//

#import "SRError.h"

#import "SRWebSocket.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
4 changes: 2 additions & 2 deletions SocketRocket/Internal/Utilities/SRSIMDHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

typedef uint8_t uint8x32_t __attribute__((vector_size(32)));

void SRMaskBytesManual(uint8_t *bytes, size_t length, uint8_t *maskKey) {
static void SRMaskBytesManual(uint8_t *bytes, size_t length, uint8_t *maskKey) {
for (size_t i = 0; i < length; i++) {
bytes[i] = bytes[i] ^ maskKey[i % sizeof(uint32_t)];
}
Expand All @@ -25,7 +25,7 @@ void SRMaskBytesManual(uint8_t *bytes, size_t length, uint8_t *maskKey) {
@return A shifted vector.
*/
uint8x32_t SRShiftVector(uint8x32_t vector, size_t by) {
static uint8x32_t SRShiftVector(uint8x32_t vector, size_t by) {
uint8x32_t vectorCopy = vector;
by = by % _Alignof(uint8x32_t);

Expand Down
20 changes: 0 additions & 20 deletions SocketRocket/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion SocketRocket/NSRunLoop+SRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "SRRunLoopThread.h"

// Required for object file to always be linked.
extern void import_NSRunLoop_SRWebSocket() { }
void import_NSRunLoop_SRWebSocket() { }

@implementation NSRunLoop (SRWebSocket)

Expand Down
4 changes: 2 additions & 2 deletions SocketRocket/NSURLRequest+SRWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
An array of pinned `SecCertificateRef` SSL certificates that `SRWebSocket` will use for validation.
*/
@property (nullable, nonatomic, strong, readonly) NSArray *SR_SSLPinnedCertificates;
@property (nullable, nonatomic, copy, readonly) NSArray *SR_SSLPinnedCertificates;

@end

Expand All @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
An array of pinned `SecCertificateRef` SSL certificates that `SRWebSocket` will use for validation.
*/
@property (nullable, nonatomic, strong) NSArray *SR_SSLPinnedCertificates;
@property (nullable, nonatomic, copy) NSArray *SR_SSLPinnedCertificates;

@end

Expand Down
10 changes: 6 additions & 4 deletions SocketRocket/NSURLRequest+SRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
#import "NSURLRequest+SRWebSocketPrivate.h"

// Required for object file to always be linked.
extern void import_NSURLRequest_SRWebSocket() { }
void import_NSURLRequest_SRWebSocket() { }

NS_ASSUME_NONNULL_BEGIN

static NSString *const SRSSLPinnnedCertificatesKey = @"SocketRocket_SSLPinnedCertificates";

@implementation NSURLRequest (SRWebSocket)

- (nullable NSArray *)SR_SSLPinnedCertificates
{
return [NSURLProtocol propertyForKey:@"SR_SSLPinnedCertificates" inRequest:self];
return [NSURLProtocol propertyForKey:SRSSLPinnnedCertificatesKey inRequest:self];
}

@end
Expand All @@ -30,12 +32,12 @@ @implementation NSMutableURLRequest (SRWebSocket)

- (nullable NSArray *)SR_SSLPinnedCertificates
{
return [NSURLProtocol propertyForKey:@"SR_SSLPinnedCertificates" inRequest:self];
return [NSURLProtocol propertyForKey:SRSSLPinnnedCertificatesKey inRequest:self];
}

- (void)setSR_SSLPinnedCertificates:(nullable NSArray *)SR_SSLPinnedCertificates
{
[NSURLProtocol setProperty:SR_SSLPinnedCertificates forKey:@"SR_SSLPinnedCertificates" inRequest:self];
[NSURLProtocol setProperty:[SR_SSLPinnedCertificates copy] forKey:SRSSLPinnnedCertificatesKey inRequest:self];
}

@end
Expand Down
10 changes: 5 additions & 5 deletions SocketRocket/SRWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, SRReadyState) {
};

typedef NS_ENUM(NSInteger, SRStatusCode) {
// 0999: Reserved and not used.
// 0-999: Reserved and not used.
SRStatusCodeNormal = 1000,
SRStatusCodeGoingAway = 1001,
SRStatusCodeProtocolError = 1002,
Expand All @@ -38,10 +38,10 @@ typedef NS_ENUM(NSInteger, SRStatusCode) {
SRStatusCodeTryAgainLater = 1013,
// 1014: Reserved for future use by the WebSocket standard.
SRStatusCodeTLSHandshake = 1015,
// 10161999: Reserved for future use by the WebSocket standard.
// 20002999: Reserved for use by WebSocket extensions.
// 30003999: Available for use by libraries and frameworks. May not be used by applications. Available for registration at the IANA via first-come, first-serve.
// 40004999: Available for use by applications.
// 1016-1999: Reserved for future use by the WebSocket standard.
// 2000-2999: Reserved for use by WebSocket extensions.
// 3000-3999: Available for use by libraries and frameworks. May not be used by applications. Available for registration at the IANA via first-come, first-serve.
// 4000-4999: Available for use by applications.
};

@class SRWebSocket;
Expand Down
Loading

0 comments on commit d092127

Please sign in to comment.