diff --git a/.github/workflows/buildandtest.yml b/.github/workflows/buildandtest.yml index d436861b81..81065f9623 100644 --- a/.github/workflows/buildandtest.yml +++ b/.github/workflows/buildandtest.yml @@ -51,6 +51,22 @@ jobs: cache-dependency-path: yarn.lock - name: Install Dependencies run: yarn install + + # Default of ubuntu and apt packages are too old compared to macos packages. + # This is required for using a newer version of clang-format. + - name: Setup clang-format V20 + run: | + sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" 20 + sudo apt-get install -y clang-20 clang-format-20 lld-20 lldb-20 + + - name: Set clang-format V20 as default + run: | + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200 + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 200 + clang --version + clang-format --version + - name: Lint run: yarn lint diff --git a/package.json b/package.json index e08b41c76b..2526b2f46e 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@expo/swiftlint": "^0.57.1", "@naturalcycles/ktlint": "^1.13.0", "@sentry/cli": "2.53.0", - "clang-format": "^1.8.0", "downlevel-dts": "^0.11.0", "google-java-format": "^1.4.0", "lerna": "^8.1.8", diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h index 51f257cb76..db28ce81f1 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h @@ -1,7 +1,6 @@ #import -@interface -RNSentry (RNSentryInternal) +@interface RNSentry (RNSentryInternal) + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys otherUserKeys:(NSDictionary *)userDataKeys; diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m index ab81eb658b..1cef19682c 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.m @@ -22,7 +22,7 @@ - (void)testRNSentryDependencyContainerInitializesFrameTracker OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker]) .andReturn(frameTrackerMock); - RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) {}; + RNSentryEmitNewFrameEvent emitNewFrameEvent = ^(NSNumber *newFrameTimestampInSeconds) { }; [[RNSentryDependencyContainer sharedInstance] initializeFramesTrackerListenerWith:emitNewFrameEvent]; XCTAssertNotNil([[RNSentryDependencyContainer sharedInstance] framesTrackerListener]); diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m index ee33d109e4..7a877795d6 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.m @@ -46,7 +46,7 @@ - (void)testRNSentryFramesTrackerIsOneTimeListener OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker]) .andReturn(frameTrackerMock); - RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {}; + RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { }; RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker] @@ -66,7 +66,7 @@ - (void)testRNSentryFramesTrackerAddsItselfAsListener OCMStub([(SentryDependencyContainer *)sentryDependencyContainerMock framesTracker]) .andReturn(frameTrackerMock); - RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) {}; + RNSentryEmitNewFrameEvent mockEventEmitter = ^(NSNumber *newFrameTimestampInSeconds) { }; RNSentryFramesTrackerListener *actualListener = [[RNSentryFramesTrackerListener alloc] initWithSentryFramesTracker:[[SentryDependencyContainer sharedInstance] framesTracker] diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h index 2ef701d215..8a9df3a94e 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.h @@ -1,8 +1,7 @@ #import "RNSentryOnDrawReporter.h" #import -@interface -RNSentryOnDrawReporterView (Testing) +@interface RNSentryOnDrawReporterView (Testing) + (instancetype)createWithMockedListener; - (RNSentryEmitNewFrameEvent)createEmitNewFrameEvent; diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.mm b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.mm index 3aca532855..da85363b16 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.mm +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryOnDrawReporter+Test.mm @@ -28,8 +28,7 @@ - (void)framesTrackerHasNewFrame:(nonnull NSDate *)newFrameDate @end -@implementation -RNSentryOnDrawReporterView (Testing) +@implementation RNSentryOnDrawReporterView (Testing) + (instancetype)createWithMockedListener { diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.h b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.h index 54e8504da0..43a25477fc 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.h +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.h @@ -3,8 +3,7 @@ @class SentryOptions; -@interface -SentrySDKInternal (PrivateTests) +@interface SentrySDKInternal (PrivateTests) + (nullable SentryOptions *)options; @end diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index 72515ff235..ffb404fa22 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -16,8 +16,7 @@ // This method was moved to a new category so we can use `@import Sentry` to use Sentry's Swift // classes -@implementation -RNSentry (fetchNativeStack) +@implementation RNSentry (fetchNativeStack) - (NSDictionary *)fetchNativeStackFramesBy:(NSArray *)instructionsAddr symbolicate:(SymbolicateCallbackType)symbolicate diff --git a/packages/core/ios/RNSentry.h b/packages/core/ios/RNSentry.h index 074c8f270e..78f48f5f4b 100644 --- a/packages/core/ios/RNSentry.h +++ b/packages/core/ios/RNSentry.h @@ -28,8 +28,7 @@ typedef int (*SymbolicateCallbackType)(const void *, Dl_info *); @end -@interface -RNSentry (fetchNativeStack) +@interface RNSentry (fetchNativeStack) - (NSDictionary *_Nonnull)fetchNativeStackFramesBy:(NSArray *)instructionsAddr symbolicate:(SymbolicateCallbackType)symbolicate; diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index ea024ec8a1..2f0f3cb529 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -87,10 +87,8 @@ - (instancetype)init } RCT_EXPORT_MODULE() -RCT_EXPORT_METHOD(initNativeSdk - : (NSDictionary *_Nonnull)options resolve - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(initNativeSdk : (NSDictionary *_Nonnull)options resolve : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSError *error = nil; SentryOptions *sentryOptions = [self createOptionsWithDictionary:options error:&error]; @@ -200,8 +198,7 @@ - (BOOL)shouldIgnoreError:(NSString *)message - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)options error:(NSError *_Nonnull *_Nonnull)errorPointer { - SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event) - { + SentryBeforeSendEventCallback beforeSend = ^SentryEvent *(SentryEvent *event) { // We don't want to send an event after startup that came from a Unhandled JS Exception of // React Native because we sent it already before the app crashed. if (nil != event.exceptions.firstObject.type && @@ -292,7 +289,7 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) id enableLogsValue = [mutableOptions valueForKey:@"enableLogs"]; if ([enableLogsValue isKindOfClass:[NSNumber class]]) { [RNSentryExperimentalOptions setEnableLogs:[enableLogsValue boolValue] - sentryOptions:sentryOptions]; + sentryOptions:sentryOptions]; } } [self trySetIgnoreErrors:mutableOptions]; @@ -362,9 +359,8 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event event.tags = newTags; } -RCT_EXPORT_METHOD(initNativeReactNavigationNewFrameTracking - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(initNativeReactNavigationNewFrameTracking : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if SENTRY_HAS_UIKIT if ([[NSThread currentThread] isMainThread]) { @@ -406,9 +402,8 @@ - (void)stopObserving return @[ RNSentryNewFrameEvent ]; } -RCT_EXPORT_METHOD(fetchNativeSdkInfo - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchNativeSdkInfo : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { resolve(@ { @"name" : PrivateSentrySDKOnly.getSdkName, @@ -416,9 +411,8 @@ - (void)stopObserving }); } -RCT_EXPORT_METHOD(fetchModules - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchModules : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSString *filePath = [[NSBundle mainBundle] pathForResource:@"modules" ofType:@"json"]; NSString *modulesString = [NSString stringWithContentsOfFile:filePath @@ -433,15 +427,14 @@ - (void)stopObserving return packageName; } -RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, fetchNativeStackFramesBy - : (NSArray *)instructionsAddr) +RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD( + NSDictionary *, fetchNativeStackFramesBy : (NSArray *)instructionsAddr) { return [self fetchNativeStackFramesBy:instructionsAddr symbolicate:dladdr]; } -RCT_EXPORT_METHOD(fetchNativeLogAttributes - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(fetchNativeLogAttributes : (RCTPromiseResolveBlock)resolve rejecter : ( + RCTPromiseRejectBlock)reject) { __block NSMutableDictionary *result = [NSMutableDictionary new]; @@ -491,9 +484,8 @@ - (void)stopObserving resolve(result); } -RCT_EXPORT_METHOD(fetchNativeDeviceContexts - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(fetchNativeDeviceContexts : (RCTPromiseResolveBlock)resolve rejecter : ( + RCTPromiseRejectBlock)reject) { if (PrivateSentrySDKOnly.options.debug) { NSLog(@"Bridge call to: deviceContexts"); @@ -553,9 +545,8 @@ - (void)stopObserving resolve(serializedScope); } -RCT_EXPORT_METHOD(fetchNativeAppStart - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchNativeAppStart : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if SENTRY_HAS_UIKIT NSDictionary *measurements = @@ -580,9 +571,8 @@ - (void)stopObserving #endif } -RCT_EXPORT_METHOD(fetchNativeFrames - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchNativeFrames : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST @@ -611,9 +601,8 @@ - (void)stopObserving #endif } -RCT_EXPORT_METHOD(fetchNativeRelease - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchNativeRelease : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; resolve(@ { @@ -623,11 +612,8 @@ - (void)stopObserving }); } -RCT_EXPORT_METHOD(captureEnvelope - : (NSString *_Nonnull)rawBytes options - : (NSDictionary *_Nonnull)options resolve - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(captureEnvelope : (NSString *_Nonnull)rawBytes options : (NSDictionary *_Nonnull) + options resolve : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSData *data = [[NSData alloc] initWithBase64EncodedString:rawBytes options:0]; @@ -650,9 +636,8 @@ - (void)stopObserving resolve(@YES); } -RCT_EXPORT_METHOD(captureScreenshot - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + captureScreenshot : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST NSArray *rawScreenshots = [PrivateSentrySDKOnly captureScreenshots]; @@ -684,9 +669,8 @@ - (void)stopObserving #endif } -RCT_EXPORT_METHOD(fetchViewHierarchy - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + fetchViewHierarchy : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST NSData *rawViewHierarchy = [PrivateSentrySDKOnly captureViewHierarchy]; @@ -800,9 +784,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys RCT_EXPORT_METHOD(crash) { [SentrySDKWrapper crash]; } -RCT_EXPORT_METHOD(closeNativeSdk - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + closeNativeSdk : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { [SentrySDKWrapper close]; resolve(@YES); @@ -821,10 +804,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys // the 'tracesSampleRate' or 'tracesSampler' option. } -RCT_EXPORT_METHOD(captureReplay - : (BOOL)isHardCrash resolver - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(captureReplay : (BOOL)isHardCrash resolver : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if SENTRY_TARGET_REPLAY_SUPPORTED [PrivateSentrySDKOnly captureReplay]; @@ -834,10 +815,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys #endif } -RCT_EXPORT_METHOD(getDataFromUri - : (NSString *_Nonnull)uri resolve - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(getDataFromUri : (NSString *_Nonnull)uri resolve : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST NSURL *fileURL = [NSURL URLWithString:uri]; @@ -1020,9 +999,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys #endif } -RCT_EXPORT_METHOD(crashedLastRun - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + crashedLastRun : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { resolve(@([SentrySDKWrapper crashedLastRun])); } @@ -1036,17 +1014,14 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys } #endif -RCT_EXPORT_METHOD(getNewScreenTimeToDisplay - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(getNewScreenTimeToDisplay : (RCTPromiseResolveBlock)resolve rejecter : ( + RCTPromiseRejectBlock)reject) { [_timeToDisplay getTimeToDisplay:resolve]; } -RCT_EXPORT_METHOD(popTimeToDisplayFor - : (NSString *)key resolver - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(popTimeToDisplayFor : (NSString *)key resolver : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { resolve([RNSentryTimeToDisplay popTimeToDisplayFor:key]); } @@ -1057,10 +1032,8 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys return @YES; // The return ensures that the method is synchronous } -RCT_EXPORT_METHOD(encodeToBase64 - : (NSArray *)array resolver - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD(encodeToBase64 : (NSArray *)array resolver : ( + RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSUInteger count = array.count; uint8_t *bytes = (uint8_t *)malloc(count); diff --git a/packages/core/ios/RNSentryExperimentalOptions.h b/packages/core/ios/RNSentryExperimentalOptions.h index c193bc1599..05fab2ddef 100644 --- a/packages/core/ios/RNSentryExperimentalOptions.h +++ b/packages/core/ios/RNSentryExperimentalOptions.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN * @param sentryOptions The SentryOptions instance to configure * @param enabled Whether logs from sentry Cocoa should be enabled */ -+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions; ++ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions; @end diff --git a/packages/core/ios/RNSentryExperimentalOptions.m b/packages/core/ios/RNSentryExperimentalOptions.m index 8348b6f6d4..2e7db99a71 100644 --- a/packages/core/ios/RNSentryExperimentalOptions.m +++ b/packages/core/ios/RNSentryExperimentalOptions.m @@ -19,7 +19,7 @@ + (BOOL)getEnableUnhandledCPPExceptionsV2:(SentryOptions *)sentryOptions return sentryOptions.experimental.enableUnhandledCPPExceptionsV2; } -+ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions ++ (void)setEnableLogs:(BOOL)enabled sentryOptions:(SentryOptions *)sentryOptions { if (sentryOptions == nil) { return; diff --git a/packages/core/ios/Replay/RNSentryReplayMask.mm b/packages/core/ios/Replay/RNSentryReplayMask.mm index bc39f229e2..14453e26af 100644 --- a/packages/core/ios/Replay/RNSentryReplayMask.mm +++ b/packages/core/ios/Replay/RNSentryReplayMask.mm @@ -23,8 +23,7 @@ - (UIView *)view @end # ifdef RCT_NEW_ARCH_ENABLED -@interface -RNSentryReplayMask () +@interface RNSentryReplayMask () @end # endif diff --git a/packages/core/ios/Replay/RNSentryReplayUnmask.mm b/packages/core/ios/Replay/RNSentryReplayUnmask.mm index 8dd0f06611..f0ec5139d6 100644 --- a/packages/core/ios/Replay/RNSentryReplayUnmask.mm +++ b/packages/core/ios/Replay/RNSentryReplayUnmask.mm @@ -23,8 +23,7 @@ - (UIView *)view @end # ifdef RCT_NEW_ARCH_ENABLED -@interface -RNSentryReplayUnmask () +@interface RNSentryReplayUnmask () @end # endif diff --git a/packages/core/test/wrapper.test.ts b/packages/core/test/wrapper.test.ts index 2f18952056..8fc14c89ea 100644 --- a/packages/core/test/wrapper.test.ts +++ b/packages/core/test/wrapper.test.ts @@ -335,8 +335,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":87}\n' + - '{"event_id":"event0","message":"test","sdk":{"name":"test-sdk-name","version":"2.1.3"}}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":87}\n' + + '{"event_id":"event0","message":"test","sdk":{"name":"test-sdk-name","version":"2.1.3"}}\n', ), ), { hardCrashed: false }, @@ -367,8 +367,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":93}\n' + - '{"event_id":"event0","sdk":{"name":"test-sdk-name","version":"2.1.3"},"instance":{"value":0}}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":93}\n' + + '{"event_id":"event0","sdk":{"name":"test-sdk-name","version":"2.1.3"},"instance":{"value":0}}\n', ), ), { hardCrashed: false }, @@ -410,8 +410,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":50}\n' + - '{"event_id":"event0","message":{"message":"test"}}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":50}\n' + + '{"event_id":"event0","message":{"message":"test"}}\n', ), ), { hardCrashed: false }, @@ -449,8 +449,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":124}\n' + - '{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":true,"type":""}}]},"breadcrumbs":[{"message":"crumb!"}]}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":124}\n' + + '{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":true,"type":""}}]},"breadcrumbs":[{"message":"crumb!"}]}\n', ), ), { hardCrashed: false }, @@ -478,8 +478,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":58}\n' + - '{"event_id":"event0","breadcrumbs":[{"message":"crumb!"}]}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":58}\n' + + '{"event_id":"event0","breadcrumbs":[{"message":"crumb!"}]}\n', ), ), { hardCrashed: false }, @@ -517,8 +517,8 @@ describe('Tests Native Wrapper', () => { base64StringFromByteArray( utf8ToBytes( '{"event_id":"event0","sent_at":"123"}\n' + - '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":132}\n' + - '{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":false,"type":"onerror"}}]},"breadcrumbs":[{"message":"crumb!"}]}\n', + '{"type":"event","content_type":"application/vnd.sentry.items.log+json","length":132}\n' + + '{"event_id":"event0","exception":{"values":[{"mechanism":{"handled":false,"type":"onerror"}}]},"breadcrumbs":[{"message":"crumb!"}]}\n', ), ), { hardCrashed: true }, diff --git a/performance-tests/TestAppPlain/ios/TestAppPlain/AppDelegate.mm b/performance-tests/TestAppPlain/ios/TestAppPlain/AppDelegate.mm index 426fb5164f..08bbcca328 100644 --- a/performance-tests/TestAppPlain/ios/TestAppPlain/AppDelegate.mm +++ b/performance-tests/TestAppPlain/ios/TestAppPlain/AppDelegate.mm @@ -18,8 +18,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; -@interface -AppDelegate () { +@interface AppDelegate () { RCTTurboModuleManager *_turboModuleManager; RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; std::shared_ptr _reactNativeConfig; diff --git a/performance-tests/TestAppSentry/ios/TestAppSentry/AppDelegate.mm b/performance-tests/TestAppSentry/ios/TestAppSentry/AppDelegate.mm index 729d9941e9..872faaaae2 100644 --- a/performance-tests/TestAppSentry/ios/TestAppSentry/AppDelegate.mm +++ b/performance-tests/TestAppSentry/ios/TestAppSentry/AppDelegate.mm @@ -18,8 +18,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot"; -@interface -AppDelegate () { +@interface AppDelegate () { RCTTurboModuleManager *_turboModuleManager; RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; std::shared_ptr _reactNativeConfig; diff --git a/samples/react-native/ios/SentryNativeInitializer.m b/samples/react-native/ios/SentryNativeInitializer.m index 20a4bcaa44..3a68b07574 100644 --- a/samples/react-native/ios/SentryNativeInitializer.m +++ b/samples/react-native/ios/SentryNativeInitializer.m @@ -11,8 +11,7 @@ + (void)initializeSentry options.dsn = @"https://1df17bd4e543fdb31351dee1768bb679@o447951.ingest.sentry.io/5428561"; options.debug = YES; // Enabled debug when first installing is always helpful - options.beforeSend = ^SentryEvent *(SentryEvent *event) - { + options.beforeSend = ^SentryEvent *(SentryEvent *event) { // We don't want to send an event after startup that came from a Unhandled JS Exception // of react native Because we sent it already before the app crashed. if (nil != event.exceptions.firstObject.type && diff --git a/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm b/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm index 0df8934ff1..604da2dbf4 100644 --- a/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm +++ b/samples/react-native/ios/sentryreactnativesample/AppDelegate.mm @@ -15,8 +15,7 @@ #import "SentryNativeInitializer.h" -@interface -AppDelegate () { +@interface AppDelegate () { } @end diff --git a/samples/react-native/ios/sentryreactnativesample/RCTAssetsModule.m b/samples/react-native/ios/sentryreactnativesample/RCTAssetsModule.m index 7096c4240a..6a616916e5 100644 --- a/samples/react-native/ios/sentryreactnativesample/RCTAssetsModule.m +++ b/samples/react-native/ios/sentryreactnativesample/RCTAssetsModule.m @@ -2,9 +2,8 @@ @implementation RCTAssetsModule -RCT_EXPORT_METHOD(getExampleAssetData - : (RCTPromiseResolveBlock)resolve rejecter - : (RCTPromiseRejectBlock)reject) +RCT_EXPORT_METHOD( + getExampleAssetData : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) { NSDataAsset *data = [[NSDataAsset alloc] initWithName:@"ExampleBinaryData"]; if (data == nil) { diff --git a/samples/react-native/src/Screens/ErrorsScreen.tsx b/samples/react-native/src/Screens/ErrorsScreen.tsx index 79d23489f7..0a3531e610 100644 --- a/samples/react-native/src/Screens/ErrorsScreen.tsx +++ b/samples/react-native/src/Screens/ErrorsScreen.tsx @@ -164,7 +164,7 @@ const ErrorsScreen = (_props: Props) => { Sentry.logger.warn('warn log'); Sentry.logger.error('error log'); - Sentry.logger.info('info log with data', { database: 'admin', number: 123, obj: { password: 'admin'} }); + Sentry.logger.info('info log with data', { database: 'admin', number: 123, obj: { password: 'admin' } }); }} /> {Platform.OS === 'android' && ( diff --git a/scripts/clang-format.sh b/scripts/clang-format.sh index 30987410e4..f2dbd626f2 100755 --- a/scripts/clang-format.sh +++ b/scripts/clang-format.sh @@ -2,6 +2,44 @@ set -eo pipefail +echo "💡 If you get 'spawn Unknown system error -86', try running this script manually:" +echo " ./scripts/clang-format.sh $1" +echo "💡 It is also recommended to use clang-version v20 or v21." + +# Prioritize finding clang-format executable from brew since the run-s may introduce X86/ARM64 mismatch. +CLANG_FORMAT_PATH="" +if [ -f "/opt/homebrew/bin/clang-format" ]; then + CLANG_FORMAT_PATH="/opt/homebrew/bin/clang-format" +else + CLANG_FORMAT_PATH=$(which clang-format 2>/dev/null || true) +fi + +if [ -z "$CLANG_FORMAT_PATH" ]; then + echo "❌ clang-format is not installed or not found in PATH" + echo "" + echo "To install clang-format:" + echo " * macOS: brew install clang-format" + echo " * Ubuntu: follow steps used on file .github/workflows/buildandtest.yml clang-format setup." + echo " * Arch: pacman -S clang llvm llvm-libs" + exit 1 +fi + +CLANG_VERSION="$("$CLANG_FORMAT_PATH" --version 2>/dev/null)" +CLANG_MAJOR_VERSION="$(printf '%s' "$CLANG_VERSION" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1 | cut -d. -f1)" + +echo "clang-format version: $CLANG_VERSION, MAJOR: $CLANG_MAJOR_VERSION" + +if ! printf '%s' "$CLANG_MAJOR_VERSION" | grep -qE '^[0-9]+$'; then + echo "❌ Could not parse clang-format version from: $CLANG_VERSION" + exit 1 +fi + +REQUIRED_MAJOR=20 +if [ "$CLANG_MAJOR_VERSION" -lt "$REQUIRED_MAJOR" ]; then + echo "❌ clang-format major version $CLANG_MAJOR_VERSION is lower than required $REQUIRED_MAJOR" + exit 1 +fi + # Check if an argument is provided if [ $# -eq 0 ]; then echo "Usage: $0 " @@ -32,7 +70,7 @@ cmd="find . -type f \( \ -path \"**/node_modules/**\" -or \ -path \"**/gems/**\" -or \ -path \"**/Pods/**\" \) \ - | xargs npx clang-format --Werror --verbose -i -style=file" + | xargs \"$CLANG_FORMAT_PATH\" --Werror --verbose -i -style=file" # Add --replace flag if mode is 'fix' if [ "$mode" = "fix" ]; then diff --git a/yarn.lock b/yarn.lock index effcadb205..082e1bbbd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13749,21 +13749,6 @@ __metadata: languageName: node linkType: hard -"clang-format@npm:^1.8.0": - version: 1.8.0 - resolution: "clang-format@npm:1.8.0" - dependencies: - async: ^3.2.3 - glob: ^7.0.0 - resolve: ^1.1.6 - bin: - check-clang-format: bin/check-clang-format.js - clang-format: index.js - git-clang-format: bin/git-clang-format - checksum: 8e4198e976e8ca1dcb6f7eba09db89db44ce39c326a249b1a28ea2b3fd7dc5ece389d328bb9781424a708e63044b1432d85b9d8f65c46d3d5c13d2b6bf745a50 - languageName: node - linkType: hard - "clean-stack@npm:^2.0.0": version: 2.2.0 resolution: "clean-stack@npm:2.2.0" @@ -27595,7 +27580,7 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@^1.1.6#~builtin, resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.22.2#~builtin, resolve@patch:resolve@^1.22.8#~builtin, resolve@patch:resolve@npm%3A^1.1.6#~builtin, resolve@patch:resolve@npm%3A^1.10.0#~builtin, resolve@patch:resolve@npm%3A^1.14.2#~builtin, resolve@patch:resolve@npm%3A^1.20.0#~builtin, resolve@patch:resolve@npm%3A^1.21.0#~builtin, resolve@patch:resolve@npm%3A^1.22.4#~builtin, resolve@patch:resolve@npm%3A^1.22.8#~builtin": +"resolve@patch:resolve@^1.10.1#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.22.2#~builtin, resolve@patch:resolve@^1.22.8#~builtin, resolve@patch:resolve@npm%3A^1.1.6#~builtin, resolve@patch:resolve@npm%3A^1.10.0#~builtin, resolve@patch:resolve@npm%3A^1.14.2#~builtin, resolve@patch:resolve@npm%3A^1.20.0#~builtin, resolve@patch:resolve@npm%3A^1.21.0#~builtin, resolve@patch:resolve@npm%3A^1.22.4#~builtin, resolve@patch:resolve@npm%3A^1.22.8#~builtin": version: 1.22.8 resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin::version=1.22.8&hash=c3c19d" dependencies: @@ -28345,7 +28330,6 @@ __metadata: "@expo/swiftlint": ^0.57.1 "@naturalcycles/ktlint": ^1.13.0 "@sentry/cli": 2.53.0 - clang-format: ^1.8.0 downlevel-dts: ^0.11.0 google-java-format: ^1.4.0 lerna: ^8.1.8