Skip to content

Code cleanup #2297

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

Merged
merged 1 commit into from
Jan 21, 2019
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
4 changes: 4 additions & 0 deletions GoogleDataLogger/GoogleDataLogger/Classes/GDLLogWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

@protocol GDLLogTransformer;

NS_ASSUME_NONNULL_BEGIN

/** Manages the writing and log-time transforming of logs. */
@interface GDLLogWriter : NSObject

Expand All @@ -38,3 +40,5 @@
afterApplyingTransformers:(nullable NSArray<id<GDLLogTransformer>> *)logTransformers;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@class GDLUploadCoordinator;

NS_ASSUME_NONNULL_BEGIN

@interface GDLLogStorage ()

/** The queue on which all storage work will occur. */
Expand All @@ -34,3 +36,5 @@
@property(nonatomic) GDLUploadCoordinator *uploader;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@class GDLLogStorage;

NS_ASSUME_NONNULL_BEGIN

@interface GDLLogWriter ()

/** The queue on which all work will occur. */
Expand All @@ -27,3 +29,5 @@
@property(nonatomic) GDLLogStorage *storageInstance;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@class GDLLogWriter;

NS_ASSUME_NONNULL_BEGIN

@interface GDLLogger ()

/** The log mapping identifier that a GDLLogBackend will use to map the extension to proto. */
Expand All @@ -33,3 +35,5 @@
@property(nonatomic) GDLLogWriter *logWriterInstance;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@interface GDLRegistrar ()

NS_ASSUME_NONNULL_BEGIN

/** The concurrent queue on which all registration occurs. */
@property(nonatomic, readonly) dispatch_queue_t registrarQueue;

Expand All @@ -30,3 +32,5 @@
NSMutableDictionary<NSNumber *, id<GDLLogPrioritizer>> *logTargetToPrioritizer;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@class GDLLogEvent;

NS_ASSUME_NONNULL_BEGIN

/** This protocol defines the common interface of a log prioritization. Log prioritizers are
* stateful objects that prioritize logs upon insertion into storage and remain prepared to return a
* set of log filenames to the storage system.
Expand Down Expand Up @@ -45,3 +47,5 @@
- (NSSet<NSNumber *> *)logsForNextUpload;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/** This protocol defines the common interface that log protos should implement regardless of the
* underlying transport technology (protobuf, nanopb, etc).
*/
Expand All @@ -28,3 +30,5 @@
- (NSData *)protoBytes;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

@class GDLLogEvent;

NS_ASSUME_NONNULL_BEGIN

/** Defines the API that log transformers must adopt. */
@protocol GDLLogTransformer <NSObject>

Expand All @@ -32,3 +34,5 @@
- (GDLLogEvent *)transform:(GDLLogEvent *)logEvent;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ typedef NS_ENUM(NSInteger, GDLMessageCode) {
};

/** */
FOUNDATION_EXTERN NSString *GDLMessageCodeEnumToString(GDLMessageCode code);
FOUNDATION_EXTERN NSString *_Nonnull GDLMessageCodeEnumToString(GDLMessageCode code);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we're not using NS_ASSUME_NONNULL_BEGIN/END here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just general carefulness around whether we're accidentally injecting NS_ASSUMEs into code with the preprocessor.


/** Logs the warningMessage string to the console at the warning level.
*
* @param warningMessageFormat The format string to log to the console.
*/
FOUNDATION_EXTERN void GDLLogWarning(GDLMessageCode messageCode,
NSString *warningMessageFormat,
NSString *_Nonnull warningMessageFormat,
...) NS_FORMAT_FUNCTION(2, 3);

// A define to wrap GULLogWarning with slightly more convenient usage.
Expand Down
2 changes: 2 additions & 0 deletions GoogleDataLogger/Tests/Unit/GDLClockTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (void)testSupportsSecureEncoding {
XCTAssertTrue([GDLClock supportsSecureCoding]);
}

/** Tests encoding and decoding a clock using a keyed archiver. */
- (void)testEncoding {
GDLClock *clock = [GDLClock snapshot];
NSData *clockData = [NSKeyedArchiver archivedDataWithRootObject:clock];
Expand All @@ -56,6 +57,7 @@ - (void)testEncoding {
XCTAssertEqualObjects(clock, unarchivedClock);
}

/** Tests creating a clock that represents a future time. */
- (void)testClockSnapshotInTheFuture {
GDLClock *clock1 = [GDLClock snapshot];
GDLClock *clock2 = [GDLClock clockSnapshotInTheFuture:1];
Expand Down
6 changes: 0 additions & 6 deletions GoogleDataLogger/Tests/Unit/GDLLogWriterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,4 @@ - (void)testWriteLogWithBadTransformer {
[self waitForExpectations:@[ errorExpectation ] timeout:5.0];
}

/** Tests that writing a nil log throws. */
- (void)testWritingANilLogThrows {
GDLLogWriter *writer = [GDLLogWriter sharedInstance];
XCTAssertThrows([writer writeLog:nil afterApplyingTransformers:nil]);
}

@end
1 change: 1 addition & 0 deletions GoogleDataLogger/Tests/Unit/GDLRegistrarTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ @interface GDLRegistrarTest : GDLTestCase
@implementation GDLRegistrarTest

- (void)setUp {
[super setUp];
_logTarget = 23;
}

Expand Down
6 changes: 1 addition & 5 deletions GoogleDataLogger/generate_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@
# From https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

# Remove the old generated project
echo "Removing $DIR/gen"
rm -rf "$DIR/gen/"

pod gen "$DIR/../GoogleDataLogger.podspec" --auto-open --gen-directory="$DIR/gen"
pod gen "$DIR/../GoogleDataLogger.podspec" --auto-open --gen-directory="$DIR/gen" --clean