adobe / aepsdk-edge-ios

Adobe Experience Platform Edge Network mobile extension in Swift
Apache License 2.0
13 stars 24 forks source link

Refactor wildcard index logic #416

Closed timkimadobe closed 1 year ago

timkimadobe commented 1 year ago

Description

This PR:

  1. Updates how wildcard indexes are allowed to be specified, only allowing a strictly validated format of a single wildcard character to the left of the index, ex: [*123]. If the wildcard candidate fails validation, it causes a test failure to help test writers and maintainers enforce consistency across usages
  2. Updates JSON comparison public method docs to reflect this change
  3. Updates relevant test case to validate new wildcard format and strict test failure enforcement
  4. Splits the logic of extracting and validating the wildcard indexes from the flexible array comparison method, which has the benefits of:
    1. Abstracting away the complexity of the string processing and validation
    2. Moving the verbose documentation away from the business logic of the array comparison

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist:

codecov[bot] commented 1 year ago

Codecov Report

Merging #416 (c014f56) into feature/json-comparison-parity (b8dd273) will not change coverage. The diff coverage is n/a.

@@                       Coverage Diff                       @@
##           feature/json-comparison-parity     #416   +/-   ##
===============================================================
  Coverage                           96.77%   96.77%           
===============================================================
  Files                                  27       27           
  Lines                                1671     1671           
===============================================================
  Hits                                 1617     1617           
  Misses                                 54       54           
timkimadobe commented 1 year ago

Based on offline discussion with @emdobrin and @addb, aligned on the following updates:

  1. Extract the else block of logic that filters and processes wildcard indexes into its own method and simplify callsite
  2. Refactor the logic for wildcard indexes to strictly validate the following cases, and emit a test error upon failure:
    1. Wildcard character must be placed on the left side of the array integer, as the first character in the array brackets
    2. The inner string must be parsable as a valid Int once the wildcard character is removed

With the consequences of

  1. Abstracts away the more complicated logic of handling wildcard processing into its own module, simplifying the intent of the flexible array comparison method
  2. Creates test case writing and maintaining consistency, where wildcard usage is standardized, and when encountered in a test case the intent is clear