Skip to content

Commit

Permalink
Fix swiftlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArielDemarco committed Dec 27, 2024
1 parent fed2584 commit 9a17e0a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
5 changes: 3 additions & 2 deletions Sources/EmbraceCommonInternal/Swizzling/EmbraceSwizzler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import ObjectiveC.runtime

public class EmbraceSwizzler {
public init() {}

public init() {
}

/// Swizzles a specific instance method of a given class.
///
/// This method allows you to replace the implementation of an instance method in the specified class (`type`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension CaptureServices {
}

guard let builder = viewCaptureService.otel?.buildSpan(
name: name,
name: name,
type: type,
attributes: attributes,
autoTerminationCode: nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ extension UIViewController {

var emb_instrumentation_state: ViewInstrumentationState? {
get {
if let value = objc_getAssociatedObject(self, &AssociatedKeys.anotherIdentifier) as? ViewInstrumentationState {
if let value = objc_getAssociatedObject(
self,
&AssociatedKeys.anotherIdentifier
) as? ViewInstrumentationState {
return value as ViewInstrumentationState
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class UIViewControllerHandler {
}
}


func onViewDidAppearStart(_ vc: UIViewController, now: Date = Date()) {
vc.emb_instrumentation_state?.viewDidAppearSpanCreated = true
queue.async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ extension ViewCaptureService {
/// If the `UIViewController` disappears before the interaction is set as ready, the span status will be set to `error`
/// with the `userAbandon` error code.
@objc public var instrumentFirstRender: Bool {
get {
instrumentFirstRenderMode.isOn()
}
instrumentFirstRenderMode.isOn()
}

let instrumentFirstRenderMode: InstrumentFirstRenderMode
Expand Down
20 changes: 14 additions & 6 deletions Sources/EmbraceCore/Capture/UX/View/ViewCaptureService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,18 @@ private extension ViewCaptureService {
try swizzler.swizzleDeclaredInstanceMethod(
in: UIViewController.self,
selector: selector,
implementationType: (@convention(c) (UIViewController, Selector, NSCoder) -> UIViewController?).self,
blockImplementationType: (@convention(block) (UIViewController, NSCoder) -> UIViewController?).self
implementationType: (
@convention(c) (UIViewController, Selector, NSCoder) -> UIViewController?
).self,
blockImplementationType: (
@convention(block) (UIViewController, NSCoder) -> UIViewController?
).self
) { originalImplementation in
{ viewController, coder in
// Get the class and bundle path of the view controller being initialized and check
// if the view controller belongs to the main bundle (this excludes, for eaxmple, UIKit classes)
let viewControllerClass = type(of: viewController)
let viewControllerBundlePath = Bundle(for: viewControllerClass).bundlePath;
let viewControllerBundlePath = Bundle(for: viewControllerClass).bundlePath
guard viewControllerBundlePath.contains(self.bundlePath) else {
return originalImplementation(viewController, selector, coder)
}
Expand All @@ -268,14 +272,18 @@ private extension ViewCaptureService {
try swizzler.swizzleDeclaredInstanceMethod(
in: UIViewController.self,
selector: selector,
implementationType: (@convention(c) (UIViewController, Selector, String?, Bundle?) -> UIViewController).self,
blockImplementationType: (@convention(block) (UIViewController, String?, Bundle?) -> UIViewController).self
implementationType: (
@convention(c) (UIViewController, Selector, String?, Bundle?) -> UIViewController
).self,
blockImplementationType: (
@convention(block) (UIViewController, String?, Bundle?) -> UIViewController
).self
) { originalImplementation in
{ viewController, nibName, bundle in
// Get the class and bundle path of the view controller being initialized and check
// if the view controller belongs to the main bundle (this excludes, for eaxmple, UIKit classes)
let viewControllerClass = type(of: viewController)
let viewControllerBundlePath = Bundle(for: viewControllerClass).bundlePath;
let viewControllerBundlePath = Bundle(for: viewControllerClass).bundlePath
guard viewControllerBundlePath.contains(self.bundlePath) else {
return originalImplementation(viewController, selector, nibName, bundle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Foundation

class ViewInstrumentationState: NSObject {
var identifier: String? = nil
var identifier: String?
var viewDidLoadSpanCreated = false
var viewWillAppearSpanCreated = false
var viewIsAppearingSpanCreated = false
Expand Down

0 comments on commit 9a17e0a

Please sign in to comment.