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

ci: Private State and Environment #1637

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,29 @@ excluded:
- Derived/
- Tuist/.build/
- Tuist/DerivedData/
custom_rules:
private_state:
included:
- ".*\\.swift"
regex: "@State\\s+var"
message: "State should be private"
private_state_object:
included:
- ".*\\.swift"
regex: "@StateObject\\s+var"
message: "StateObject should be private"
private_modal_state:
included:
- ".*\\.swift"
regex: "@ModalState\\s+var"
message: "ModalState should be private"
private_environment:
included:
- ".*\\.swift"
regex: "@Environment\\([^)]*\\)\\s+var"
message: "Environment should be private"
private_environment_object:
included:
- ".*\\.swift"
regex: "@EnvironmentObject\\s+var"
message: "EnvironmentObject should be private"
2 changes: 1 addition & 1 deletion Mail/Components/Custom Buttons/ModalButtonsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import SwiftUI
struct ModalButtonsView: View {
@Environment(\.dismiss) private var dismiss

@State var isButtonLoading = false
@State private var isButtonLoading = false

let primaryButtonTitle: String
var secondaryButtonTitle: String? = MailResourcesStrings.Localizable.buttonCancel
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Attachment/ActivityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import SwiftUI

struct ActivityView: UIViewControllerRepresentable {
@Environment(\.dismiss) var dismiss
@Environment(\.dismiss) private var dismiss

let activityItems: [Any]

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Bottom sheets/RestoreEmailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import MailResources
import SwiftUI

struct RestoreEmailsView: View {
@EnvironmentObject var mailboxManager: MailboxManager
@EnvironmentObject private var mailboxManager: MailboxManager

@Environment(\.dismiss) private var dismiss
@Environment(\.isCompactWindow) private var isCompactWindow
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/LockedAppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import SwiftUI
struct LockedAppView: View {
@LazyInjectService var appLockHelper: AppLockHelper

@EnvironmentObject var navigationState: RootViewState
@EnvironmentObject private var navigationState: RootViewState

@State private var isEvaluatingPolicy = false

Expand Down
6 changes: 3 additions & 3 deletions Mail/Views/Menu Drawer/Folders/FolderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct FolderCell: View {
@Environment(\.folderCellType) private var cellType
@Environment(\.isCompactWindow) private var isCompactWindow

@EnvironmentObject var mainViewState: MainViewState
@EnvironmentObject var navigationDrawerState: NavigationDrawerState
@EnvironmentObject private var mainViewState: MainViewState
@EnvironmentObject private var navigationDrawerState: NavigationDrawerState

let folder: NestableFolder
var level = 0
Expand Down Expand Up @@ -131,7 +131,7 @@ struct FolderCellContent: View {

@LazyInjectService private var matomo: MatomoUtils

@Environment(\.folderCellType) var cellType
@Environment(\.folderCellType) private var cellType

private let frozenFolder: Folder
private let level: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import SwiftUI
struct MailboxesManagementView: View {
@LazyInjectService private var matomo: MatomoUtils

@EnvironmentObject var mailboxManager: MailboxManager
@EnvironmentObject var navigationDrawerState: NavigationDrawerState
@EnvironmentObject private var mailboxManager: MailboxManager
@EnvironmentObject private var navigationDrawerState: NavigationDrawerState

@Environment(\.currentUser) private var currentUser

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ enum NewMessageAlertType {

struct ComposeMessageView: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.dismissModal) var dismissModal
@Environment(\.dismissModal) private var dismissModal
@EnvironmentObject private var mainViewState: MainViewState

@LazyInjectService private var matomo: MatomoUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct SettingsNotificationsView: View {

@AppStorage(UserDefaults.shared.key(.notificationsEnabled)) private var notificationsEnabled = DefaultPreferences
.notificationsEnabled
@State var subscribedTopics: [String]?
@State private var subscribedTopics: [String]?

@ModalState(context: ContextKeys.settings) private var showAlertNotification = false
@State private var showWarning = false
Expand Down
4 changes: 2 additions & 2 deletions Mail/Views/Thread List/ThreadListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct ThreadListView: View {
@ModalState private var isShowingUpdateAlert = false
@ModalState private var flushAlert: FlushAlertState?

@StateObject var viewModel: ThreadListViewModel
@StateObject var multipleSelectionViewModel: MultipleSelectionViewModel
@StateObject private var viewModel: ThreadListViewModel
@StateObject private var multipleSelectionViewModel: MultipleSelectionViewModel
@StateObject private var scrollObserver = ScrollObserver()
@ObservedObject private var networkMonitor = NetworkMonitor.shared

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread/Message/Attachment/AttachmentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import SwiftUI
struct AttachmentsView: View {
@LazyInjectService private var matomo: MatomoUtils

@EnvironmentObject var mailboxManager: MailboxManager
@EnvironmentObject private var mailboxManager: MailboxManager
@ObservedRealmObject var message: Message

@ModalState private var previewedAttachment: Attachment?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct MessageHeaderDetailView: View {
}

struct RecipientLabel: View {
@EnvironmentObject var mailboxManager: MailboxManager
@EnvironmentObject private var mailboxManager: MailboxManager

@Binding var labelWidth: CGFloat
let title: String
Expand Down
1 change: 1 addition & 0 deletions MailCore/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum DeeplinkConstants {

public static func presentsNotificationSettings() {
@InjectService var platformDetector: PlatformDetectable
// swiftlint:disable:next private_environment
@Environment(\.openURL) var openURL

let settingsURL: URL?
Expand Down
Loading