Skip to content

Commit

Permalink
chore(tooling): Add clang-format (#4229)
Browse files Browse the repository at this point in the history
Co-authored-by: Antonis Lilis <antonis.lilis@gmail.com>
  • Loading branch information
krystofwoldrich and antonis authored Nov 5, 2024
1 parent 2a32d81 commit 08365b9
Show file tree
Hide file tree
Showing 61 changed files with 1,763 additions and 1,547 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: WebKit
IndentWidth: 4
IndentPPDirectives: AfterHash
ColumnLimit: 100
AlwaysBreakAfterDefinitionReturnType: All
PointerAlignment: Right
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@
"clean": "lerna run clean",
"circularDepCheck": "lerna run circularDepCheck",
"test": "lerna run test",
"fix": "run-s fix:lerna fix:android",
"fix": "run-s fix:lerna fix:android fix:clang",
"fix:lerna": "lerna run fix",
"fix:android": "run-s 'java:format fix' java:pmd",
"lint": "run-s lint:lerna lint:android",
"fix:clang": "run-s 'clang:format fix'",
"lint": "run-s lint:lerna lint:android lint:clang",
"lint:lerna": "lerna run lint",
"lint:android": "run-s 'java:format lint' java:pmd",
"lint:clang": "run-s 'clang:format lint'",
"java:format": "./scripts/google-java-format.sh",
"java:pmd": "./scripts/pmd.sh",
"clang:format": "./scripts/clang-format.sh",
"run-ios": "cd samples/react-native && yarn react-native run-ios",
"run-android": "cd samples/react-native && yarn react-native run-android",
"set-version-samples": "lerna run set-version"
},
"devDependencies": {
"@sentry/cli": "2.38.1",
"clang-format": "^1.8.0",
"downlevel-dts": "^0.11.0",
"google-java-format": "^1.4.0",
"lerna": "^8.1.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "RNSentryReplayBreadcrumbConverter.h"
#import "RNSentryBreadcrumb.h"
#import "RNSentryReplayBreadcrumbConverter.h"
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "SentryFramesTracker.h"
#import <Foundation/Foundation.h>
#import <RNSentry/RNSentry.h>
#import "SentryFramesTracker.h"

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryDependencyContainer : NSObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNSentryDependencyContainerTests.h"
#import "RNSentryDependencyContainer.h"
#import <OCMock/OCMock.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RNSentryDependencyContainer.h"

@interface RNSentryDependencyContainerTests : XCTestCase

Expand All @@ -12,17 +12,20 @@ @implementation RNSentryDependencyContainerTests

- (void)testRNSentryDependencyContainerInitializesFrameTracker
{
XCTAssertNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
XCTAssertNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);

id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
[[RNSentryDependencyContainer sharedInstance] initializeFramesTrackerListenerWith: emitNewFrameEvent];
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {};
[[RNSentryDependencyContainer sharedInstance]
initializeFramesTrackerListenerWith:emitNewFrameEvent];
XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]);
}

@end
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "SentryFramesTracker.h"
#import <Foundation/Foundation.h>
#import <RNSentry/RNSentry.h>
#import "SentryFramesTracker.h"

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryDependencyContainer : NSObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#import "RNSentryFramesTrackerListenerTests.h"
#import "RNSentryDependencyContainer.h"
#import <OCMock/OCMock.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RNSentryDependencyContainer.h"

@interface RNSentryFramesTrackerListenerTests : XCTestCase

Expand All @@ -12,58 +12,68 @@ @implementation RNSentryFramesTrackerListenerTests

- (void)testRNSentryFramesTrackerCallsGivenEventEmitterOnNewFrame
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

XCTestExpectation *blockExpectation = [self expectationWithDescription:@"Block Expectation"];
XCTestExpectation *blockExpectation = [self expectationWithDescription:@"Block Expectation"];

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {
XCTAssertTrue([newFrameTimestampInSeconds isKindOfClass:[NSNumber class]], @"The variable should be of type NSNumber.");
[blockExpectation fulfill];
};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {
XCTAssertTrue([newFrameTimestampInSeconds isKindOfClass:[NSNumber class]],
@"The variable should be of type NSNumber.");
[blockExpectation fulfill];
};

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener framesTrackerHasNewFrame: [NSDate date]];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
[actualListener framesTrackerHasNewFrame:[NSDate date]];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}

- (void)testRNSentryFramesTrackerIsOneTimeListener
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener framesTrackerHasNewFrame: [NSDate date]];
OCMVerify([frameTrackerMock removeListener:actualListener]);
[actualListener framesTrackerHasNewFrame:[NSDate date]];
OCMVerify([frameTrackerMock removeListener:actualListener]);
}

- (void)testRNSentryFramesTrackerAddsItselfAsListener
{
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance])).andReturn(sentryDependencyContainerMock);
id sentryDependencyContainerMock = OCMClassMock([SentryDependencyContainer class]);
OCMStub(ClassMethod([sentryDependencyContainerMock sharedInstance]))
.andReturn(sentryDependencyContainerMock);

id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer*) sentryDependencyContainerMock framesTracker]).andReturn(frameTrackerMock);
id frameTrackerMock = OCMClassMock([SentryFramesTracker class]);
OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker])
.andReturn(frameTrackerMock);

RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};
RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {};

RNSentryFramesTrackerListener* actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter: mockEventEmitter];
RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc]
initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker]
andEventEmitter:mockEventEmitter];

[actualListener startListening];
OCMVerify([frameTrackerMock addListener:actualListener]);
[actualListener startListening];
OCMVerify([frameTrackerMock addListener:actualListener]);
}

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <XCTest/XCTest.h>
#import "RNSentryOnDrawReporter.h"
#import <XCTest/XCTest.h>

@interface RNSentryOnDrawReporterTests : XCTestCase

Expand All @@ -9,8 +9,8 @@ @implementation RNSentryOnDrawReporterTests

- (void)testRNSentryOnDrawReporterViewIsAvailableWhenUIKitIs
{
RNSentryOnDrawReporterView* view = [[RNSentryOnDrawReporterView alloc] init];
XCTAssertNotNil(view);
RNSentryOnDrawReporterView *view = [[RNSentryOnDrawReporterView alloc] init];
XCTAssertNotNil(view);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@interface
SentrySDK (PrivateTests)
- (nullable SentryOptions *) options;
- (nullable SentryOptions *)options;
@end

@interface SentryBinaryImageInfo : NSObject
Expand Down
Loading

0 comments on commit 08365b9

Please sign in to comment.