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

Fix issue where conditional compilation blocks would be sorted incorrectly #1714

Merged

Conversation

calda
Copy link
Collaborator

@calda calda commented Jun 2, 2024

This PR fixes a regression introduced by #1678 where conditional compilation blocks would be sorted incorrectly (always at the bottom).

Previously the organizeDeclarations rule supported a partial ordering, where any declaration without a defined type would just preserve its existing relative ordering. The architecture changes to the organizeDeclaration rule now require a total ordering of declarations, so every declaration must have a well defined type.

Since conditional compilation blocks can have multiple nested declarations with different types, we previously just used type: nil for these. #1678 made these a type of their own which was sorted last. Now, we instead use the type of the first declaration in the conditional compilation block. This better matches the previous behavior.

Before

class Foo {

    // MARK: Lifecycle

    init() {}

    // MARK: Internal

    func test() {}

    #if DEBUG
    init() {
        print("Debug")
    }
    #endif

}

After

class Foo {

    // MARK: Lifecycle

    init() {}

    #if DEBUG
    init() {
        print("Debug")
    }
    #endif

    // MARK: Internal

    func test() {}
}

Copy link

codecov bot commented Jun 2, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.15%. Comparing base (f487996) to head (de86b97).

Files Patch % Lines
Sources/FormattingHelpers.swift 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1714      +/-   ##
===========================================
+ Coverage    95.13%   95.15%   +0.02%     
===========================================
  Files           20       20              
  Lines        23124    23130       +6     
===========================================
+ Hits         21998    22010      +12     
+ Misses        1126     1120       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nicklockwood nicklockwood merged commit d18c8b3 into nicklockwood:develop Jun 3, 2024
7 of 9 checks passed
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.

None yet

2 participants