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 or report all current small Swiftlint warnings in xcode #5103

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Sep 5, 2023

This PR fixes all smaller lint warnings we have in the project.


This change is Reviewable

@rablador rablador force-pushed the fix-swiftlint-warnings-in-xcode-ios-296 branch from 1054284 to dd0f9ba Compare September 5, 2023 09:34
@linear
Copy link

linear bot commented Sep 5, 2023

IOS-296 Fix Swiftlint warnings in Xcode

Go through the existing warnings and either fix them or disable + report them (in Linear).

@rablador rablador force-pushed the fix-swiftlint-warnings-in-xcode-ios-296 branch 2 times, most recently from bafb04f to 1716fb6 Compare September 5, 2023 10:32
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 34 files reviewed, 5 unresolved discussions


ios/MullvadVPN/AppDelegate.swift line 408 at r1 (raw file):

        let initTunnelManagerOperation = AsyncBlockOperation(dispatchQueue: .main) { finish in
            self.tunnelManager.loadConfiguration { error in
                // TODO: avoid throwing fatal error and show the problem report UI instead.

Reported separately in Linear.


ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift line 120 at r1 (raw file):

    }

    // swiftlint:disable:next function_body_length

Having a hard time shaving off more code from this function. It's certainly doable by eg. moving all localizable string creations outside, but there seems little point in doing so.


ios/MullvadVPN/View controllers/ProblemReport/ProblemReportInteractor.swift line 20 at r1 (raw file):

    private lazy var consolidatedLog: ConsolidatedApplicationLog = {
        let securityGroupIdentifier = ApplicationConfiguration.securityGroupIdentifier

Seems we redact all 16-digit numbers, so I'm assuming this is already taken care of.


ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift line 78 at r1 (raw file):

        outAddressRow.translatesAutoresizingMaskIntoConstraints = false

        // Remove this line when we have out address

Reported to Linear. Kept this line to make it easy to find when fixing.


ios/MullvadVPN/Views/AppButton.swift line 289 at r1 (raw file):

    }

    // swiftlint:disable:next cyclomatic_complexity

The switch is what's causing the warning. I think it's fine to keep it as-is and disable the warning.

@rablador rablador force-pushed the fix-swiftlint-warnings-in-xcode-ios-296 branch from 1716fb6 to 220ee2b Compare September 5, 2023 10:35
@rablador rablador requested review from pronebird, buggmagnet and mojganii and removed request for pronebird and buggmagnet September 5, 2023 10:45
@rablador rablador added the iOS Issues related to iOS label Sep 5, 2023
Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 29 of 34 files at r1, 7 of 7 files at r2, all commit messages.
Reviewable status: 36 of 38 files reviewed, 15 unresolved discussions (waiting on @rablador)


ios/MullvadVPN/AppDelegate.swift line 495 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

We should definitely have a Linear issue for this file (if we don't already)


ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift line 179 at r2 (raw file):

    private static func redactAccountNumber(string: String) -> String {
        redact(
            // swiftlint:disable:next force_try

Instead of manually using regexes to redact stuff, we should entirely get rid of this system and instead use
the OSLogPrivacy feature of the logging system to not log sensitive information in the first place.

Now that we've dropped iOS 13, we can use it everywhere without having to backport the API.

I will create a Linear issue about this


ios/MullvadVPN/Containers/Root/RootContainerViewController.swift line 844 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

We should have a Linear issue about this.


ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift line 983 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

We should have a Linear issue about this


ios/MullvadVPN/Notifications/NotificationManager.swift line 210 at r2 (raw file):

        }

        invalidateInAppNotification(notificationProvider)

Simple, but efficient, love it !


ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift line 426 at r2 (raw file):

}

// swiftlint:disable:next file_length

There are a lot of classes in this file that merit being in their own files, and we should do that instead.
This should get rid of this warning.


ios/MullvadVPN/TunnelManager/TunnelManager.swift line 757 at r2 (raw file):

                }

            case .invalid:

Why was this TODO removed ? Do we not want to handle this anymore ?


ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift line 120 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Having a hard time shaving off more code from this function. It's certainly doable by eg. moving all localizable string creations outside, but there seems little point in doing so.

The Localisation of the app has been a pet peeve of mine for a long while, we should definitely spend some time working on that, this adds so much visual noise for no good reason.


ios/MullvadVPN/Views/AppButton.swift line 289 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

The switch is what's causing the warning. I think it's fine to keep it as-is and disable the warning.

I think still think this could be rewritten to remove this omega switch.
But ain't nobody go'time fo'dat


ios/MullvadVPNTests/DeviceCheckOperationTests.swift line 571 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

Lots of non test code in this file that should be moved somewhere else.
I will create a Linear issue about this


ios/Operations/AsyncOperation.swift line 427 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

If we instead move the OperationBlockObserverSupport definition and extension to its own file, this should get rid of the warning


ios/PacketTunnel/PacketTunnelProvider.swift line 767 at r2 (raw file):

    }

    // swiftlint:disable:next file_length

I think we already have a Linear issue about this, but I will create one if there isn't

Copy link
Contributor

@pronebird pronebird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 34 files at r1.
Reviewable status: 37 of 38 files reviewed, 14 unresolved discussions (waiting on @buggmagnet and @rablador)


ios/MullvadVPN/Views/AppButton.swift line 289 at r1 (raw file):

Previously, buggmagnet wrote…

I think still think this could be rewritten to remove this omega switch.
But ain't nobody go'time fo'dat

One iOS version away from UIButton.Configuration


ios/MullvadVPNTests/DeviceCheckOperationTests.swift line 571 at r2 (raw file):

Previously, buggmagnet wrote…

Lots of non test code in this file that should be moved somewhere else.
I will create a Linear issue about this

If someone is going to pick up on async support for device check then it's possible that a lot of stuff will go away from here.

@rablador rablador force-pushed the fix-swiftlint-warnings-in-xcode-ios-296 branch from 220ee2b to b15c0e7 Compare September 7, 2023 14:05
Copy link
Contributor Author

@rablador rablador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 37 of 38 files reviewed, 14 unresolved discussions (waiting on @buggmagnet)


ios/MullvadVPN/AppDelegate.swift line 495 at r2 (raw file):

Previously, buggmagnet wrote…

We should definitely have a Linear issue for this file (if we don't already)

We have a general issue for all file lenghts.


ios/MullvadVPN/Classes/ConsolidatedApplicationLog.swift line 179 at r2 (raw file):

Previously, buggmagnet wrote…

Instead of manually using regexes to redact stuff, we should entirely get rid of this system and instead use
the OSLogPrivacy feature of the logging system to not log sensitive information in the first place.

Now that we've dropped iOS 13, we can use it everywhere without having to backport the API.

I will create a Linear issue about this

 👍


ios/MullvadVPN/Containers/Root/RootContainerViewController.swift line 844 at r2 (raw file):

Previously, buggmagnet wrote…

We should have a Linear issue about this.

We have a general issue for all file lenghts.


ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift line 983 at r2 (raw file):

Previously, buggmagnet wrote…

We should have a Linear issue about this

We have a general issue for all file lenghts.


ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelProvider.swift line 426 at r2 (raw file):

Previously, buggmagnet wrote…

There are a lot of classes in this file that merit being in their own files, and we should do that instead.
This should get rid of this warning.

Done, will be handled in a separate PR.


ios/MullvadVPN/TunnelManager/TunnelManager.swift line 757 at r2 (raw file):

Previously, buggmagnet wrote…

Why was this TODO removed ? Do we not want to handle this anymore ?

It has been there for some time and I didn't think it had a clear purpose. We can add a Linear issue if you insist.


ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift line 120 at r1 (raw file):

Previously, buggmagnet wrote…

The Localisation of the app has been a pet peeve of mine for a long while, we should definitely spend some time working on that, this adds so much visual noise for no good reason.

Sure thing, but let's keep that in another PR for now :)


ios/Operations/AsyncOperation.swift line 427 at r2 (raw file):

Previously, buggmagnet wrote…

If we instead move the OperationBlockObserverSupport definition and extension to its own file, this should get rid of the warning

Done.

Copy link
Contributor

@buggmagnet buggmagnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r3.
Reviewable status: 36 of 39 files reviewed, 6 unresolved discussions (waiting on @rablador)


ios/MullvadVPN/TunnelManager/TunnelManager.swift line 757 at r2 (raw file):

Previously, rablador (Jon Petersson) wrote…

It has been there for some time and I didn't think it had a clear purpose. We can add a Linear issue if you insist.

Not necessarily, I was just being curious. I would have suggested to leave it instead, but I'm not strung up on it either.


ios/MullvadVPN/View controllers/Preferences/PreferencesViewController.swift line 120 at r1 (raw file):

Previously, rablador (Jon Petersson) wrote…

Sure thing, but let's keep that in another PR for now :)

Oh yes absolutely, I'm sorry if it seemed like I suggested to do it here, definitely not the intent !

@rablador rablador force-pushed the fix-swiftlint-warnings-in-xcode-ios-296 branch from b15c0e7 to 7509670 Compare September 7, 2023 14:46
@buggmagnet buggmagnet merged commit 350719c into main Sep 8, 2023
5 checks passed
@buggmagnet buggmagnet deleted the fix-swiftlint-warnings-in-xcode-ios-296 branch September 8, 2023 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants