Skip to content
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

[MOB-3028] Ecosia Framework #816

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

lucaschifino
Copy link

@lucaschifino lucaschifino commented Nov 15, 2024

MOB-3028

Context

As a first step towards moving Core into Client, we want to create an Ecosia framework and move Braze into it.

This was jump started while pairing with @d4r1091 🙂

Approach

  • Create Ecosia Framework
  • Move Braze into it
  • Move Analytics and dependencies
  • Move tests and make sure they still work
  • Add new tests target to CI

Other

Before merging

Checklist

  • I performed some relevant testing on a real device and/or simulator
  • I wrote Unit Tests that confirm the expected behaviour
  • I made sure that any change to the Analytics events included in PR won't alter current analytics (e.g. new users, upgrading users)
  • I included documentation updates to the coding standards or Confluence doc, when needed

@lucaschifino lucaschifino changed the base branch from main to ls-mob-2959-braze-ntp-card-newsletter November 15, 2024 15:51
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Access Modifiers
The access modifiers for several methods and properties have been changed from internal to public. This increases the visibility and potential for misuse of these methods. It's important to ensure that exposing these methods is necessary and that they are properly documented to prevent misuse.

Singleton Pattern
The BrazeService class has been modified to use the singleton pattern with a publicly accessible instance. This pattern can lead to issues with testing and state management. Consider if there are alternatives that could provide better encapsulation and testability.

Public Interface
The Version struct and its methods have been made public. This change should be reviewed to ensure that it aligns with the intended use cases and that the public methods are necessary.

Static Properties
The NewsletterCardExperiment struct now has public static properties and methods. This change increases the risk of unintended interactions and makes the code harder to maintain. Consider encapsulating this functionality in a more controlled way.

Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Possible bug
Enhance the robustness of version string parsing by checking for non-integer values

Consider adding a check for non-integer values in the version string components to
prevent runtime errors when casting to Int.

Ecosia/Helpers/Version/Version.swift [19-22]

 let components = versionString.split(separator: ".")
 guard components.count == 3,
       let major = Int(components[0]),
       let minor = Int(components[1]),
       let patch = Int(components[2]) else {
           return nil
       }
+if components.contains(where: { Int($0) == nil }) {
+    return nil
+}
Suggestion importance[1-10]: 7

Why: This suggestion adds a check for non-integer values in the version string, which prevents potential runtime errors and enhances the robustness of the version parsing logic.

7
Enhancement
Improve the documentation for the public initializer to clarify expected input format and behavior

Add documentation to the public initializer to explain the format of the version
string expected and the conditions under which it returns nil.

Ecosia/Helpers/Version/Version.swift [19-22]

+/// Initializes a new `Version` from a string representation.
+/// The string should be in the format "major.minor.patch" where all parts are integers.
+/// If the format does not meet these criteria, the initialization will fail and return nil.
 public init?(_ versionString: String) {
     let components = versionString.split(separator: ".")
     guard components.count == 3,
           let major = Int(components[0]),
           let minor = Int(components[1]),
           let patch = Int(components[2]) else {
               return nil
           }
 }
Suggestion importance[1-10]: 5

Why: Adding detailed documentation for the public initializer clarifies the expected input format and behavior, which improves code readability and usability.

5
Add a debugDescription to provide more detailed debugging output for the Version struct

Implement a custom debugDescription for the Version struct to provide more detailed
debug information.

Ecosia/Helpers/Version/Version.swift [34-35]

 public var description: String {
     return "\(major).\(minor).\(patch)"
 }
+public var debugDescription: String {
+    return "Version(major: \(major), minor: \(minor), patch: \(patch))"
+}
Suggestion importance[1-10]: 3

Why: Implementing a custom debugDescription provides more detailed debug information, which can be helpful during development, but it's a minor enhancement.

3
Include the description property in the hash(into:) method to ensure consistent hashing

Ensure that the hash(into:) method also includes the description property to
maintain consistency in hash calculation.

Ecosia/Helpers/Version/Version.swift [75-78]

 public func hash(into hasher: inout Hasher) {
     hasher.combine(major)
     hasher.combine(minor)
     hasher.combine(patch)
+    hasher.combine(description)
 }
Suggestion importance[1-10]: 2

Why: Including the description property in the hash calculation could potentially improve the uniqueness of the hash, but it might not be necessary as major, minor, and patch already provide sufficient uniqueness. This suggestion could introduce unnecessary complexity.

2

Base automatically changed from ls-mob-2959-braze-ntp-card-newsletter to main November 18, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant