From a808af8057fb2716eb7464696dcdbf8c4841776f Mon Sep 17 00:00:00 2001 From: Woit Date: Tue, 19 Nov 2024 15:05:25 +0100 Subject: [PATCH] add swiftlint --- Monal/.swiftlint.yml | 125 ++++++++++++++++++ Monal/Monal.xcodeproj/project.pbxproj | 61 ++++++++- Monal/another.im/AnotherIMApp.swift | 2 +- .../RootView.swift} | 2 +- .../{ => XMPP}/MonalXmppWrapper.swift | 0 5 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 Monal/.swiftlint.yml rename Monal/another.im/{ContentView.swift => Views/RootView.swift} (92%) rename Monal/another.im/{ => XMPP}/MonalXmppWrapper.swift (100%) diff --git a/Monal/.swiftlint.yml b/Monal/.swiftlint.yml new file mode 100644 index 0000000..f4d3404 --- /dev/null +++ b/Monal/.swiftlint.yml @@ -0,0 +1,125 @@ +--- +colon: + severity: error + +line_length: + ignores_comments: true + warning: 260 + error: 300 + +type_body_length: + warning: 300 + error: 500 + +file_length: + warning: 800 + error: 1000 + +function_parameter_count: + warning: 20 + error: 30 + +function_body_length: + warning: 120 + error: 150 + +cyclomatic_complexity: + warning: 40 + error: 50 + +nesting: + type_level: + warning: 3 + error: 6 + function_level: + warning: 500 + error: 10 + +vertical_parameter_alignment: + severity: warning + +implicitly_unwrapped_optional: + severity: warning + +force_unwrapping: + severity: error + +vertical_whitespace: + severity: error + +force_try: + severity: error + +trailing_semicolon: + severity: error + +type_name: + min_length: + warninig: 3 + error: 0 + max_length: + warninig: 40 + error: 80 + +identifier_name: + min_length: 3 + max_length: 60 + # validates_start_with_lowercase: true + allowed_symbols: "_" + excluded: + - iv + - id + - ip + - on + - ui + - x + - y + - tz + - to + - db + - _db + +# Disable rules from the default enabled set. +disabled_rules: + - trailing_whitespace + - implicit_getter + - redundant_string_enum_value + - switch_case_alignment + +# Enable rules not from the default set. +opt_in_rules: + # - function_default_parameter_at_end + - empty_count + - indentation_width + # - index_at_zero + - legacy_constant + # - implicitly_unwrapped_optional + - force_unwrapping + # - no header + - file_header + # - for force unwrapping + - implicitly_unwrapped_optional + - vertical_parameter_alignment_on_call + - vertical_whitespace_between_cases + - vertical_whitespace_closing_braces + - vertical_whitespace_opening_braces + +# Acts as a whitelist, only the rules specified in this list will be enabled. Can not be specified alongside disabled_rules or opt_in_rules. +only_rules: + +# This is an entirely separate list of rules that are only run by the analyze command. All analyzer rules are opt-in, so this is the only configurable rule list (there is no disabled/whitelist equivalent). +analyzer_rules: + - unused_import + - unused_declaration + +unused_declaration: + include_public_and_open: true + +# paths to ignore during linting. Takes precedence over `included`. +excluded: + - .swiftgen + - "**/Generated" + - Classes + - Pods + - MonalUITests + - MonalXMPPUnitTests diff --git a/Monal/Monal.xcodeproj/project.pbxproj b/Monal/Monal.xcodeproj/project.pbxproj index 5241324..246319f 100644 --- a/Monal/Monal.xcodeproj/project.pbxproj +++ b/Monal/Monal.xcodeproj/project.pbxproj @@ -135,8 +135,9 @@ 7E71758D2CECC5C70059F30B /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7E71758B2CECC5C70059F30B /* Localizable.strings */; }; 7E71758E2CECC5C70059F30B /* server_features.plist in Resources */ = {isa = PBXBuildFile; fileRef = 7E71758A2CECC5C70059F30B /* server_features.plist */; }; 7E71758F2CECC5C70059F30B /* launchscreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E7175892CECC5C70059F30B /* launchscreen.storyboard */; }; + 7E8D7AE32CECD011009AD3DF /* SwiftfulRouting in Frameworks */ = {isa = PBXBuildFile; productRef = 7E8D7AE22CECD011009AD3DF /* SwiftfulRouting */; }; 7E995F242CEAC5D2005B30EE /* AnotherIMApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */; }; - 7E995F252CEAC5D2005B30EE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E995F222CEAC5D2005B30EE /* ContentView.swift */; }; + 7E995F252CEAC5D2005B30EE /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E995F222CEAC5D2005B30EE /* RootView.swift */; }; 7E995F2B2CEAC9A0005B30EE /* monalxmpp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26CC579223A0867400ABB92A /* monalxmpp.framework */; }; 7E995F2C2CEAC9A0005B30EE /* monalxmpp.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 26CC579223A0867400ABB92A /* monalxmpp.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 7E995F302CEAC9F6005B30EE /* Pods_monalxmpp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B9C86E0A568734587FE9BA2 /* Pods_monalxmpp.framework */; }; @@ -607,7 +608,7 @@ 7E71758B2CECC5C70059F30B /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; 7E995F062CEAC4B8005B30EE /* another.im.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = another.im.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnotherIMApp.swift; sourceTree = ""; }; - 7E995F222CEAC5D2005B30EE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 7E995F222CEAC5D2005B30EE /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = ""; }; 7E995F282CEAC672005B30EE /* ASN1Decoder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ASN1Decoder.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7ED6F0162CECC3AB0035B3B7 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = ""; }; 7ED6F0182CECC3BF0035B3B7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; @@ -879,6 +880,7 @@ buildActionMask = 2147483647; files = ( 7E995F2B2CEAC9A0005B30EE /* monalxmpp.framework in Frameworks */, + 7E8D7AE32CECD011009AD3DF /* SwiftfulRouting in Frameworks */, 6E9488F6997650B805476F25 /* Pods_another_im.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1392,13 +1394,29 @@ path = Strings; sourceTree = ""; }; + 7E8D7AE42CECD037009AD3DF /* Views */ = { + isa = PBXGroup; + children = ( + 7E995F222CEAC5D2005B30EE /* RootView.swift */, + ); + path = Views; + sourceTree = ""; + }; + 7E8D7AE52CECD05C009AD3DF /* XMPP */ = { + isa = PBXGroup; + children = ( + 7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */, + ); + path = XMPP; + sourceTree = ""; + }; 7E995F232CEAC5D2005B30EE /* another.im */ = { isa = PBXGroup; children = ( 7E995F202CEAC5D2005B30EE /* AnotherIMApp.swift */, 7ED6F01A2CECC43D0035B3B7 /* Resources */, - 7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */, - 7E995F222CEAC5D2005B30EE /* ContentView.swift */, + 7E8D7AE42CECD037009AD3DF /* Views */, + 7E8D7AE52CECD05C009AD3DF /* XMPP */, ); path = another.im; sourceTree = ""; @@ -1728,6 +1746,7 @@ isa = PBXNativeTarget; buildConfigurationList = 7E995F172CEAC4BA005B30EE /* Build configuration list for PBXNativeTarget "another.im" */; buildPhases = ( + 7E8D7AE62CECD182009AD3DF /* swiftlint */, A9E041FD8051B08903221D89 /* [CP] Check Pods Manifest.lock */, 7E995F022CEAC4B8005B30EE /* Sources */, 7E995F032CEAC4B8005B30EE /* Frameworks */, @@ -1896,6 +1915,7 @@ 84F194CF2C15197200F0A994 /* XCRemoteSwiftPackageReference "FrameUp" */, 84E231F12C16A9CE00735FB7 /* XCRemoteSwiftPackageReference "SVGView" */, 8418B5652C87E0ED006FAF60 /* XCRemoteSwiftPackageReference "Chat" */, + 7E8D7AE12CECD011009AD3DF /* XCRemoteSwiftPackageReference "SwiftfulRouting" */, ); productRefGroup = 19C28FACFE9D520D11CA2CBB /* Products */; projectDirPath = ""; @@ -2017,6 +2037,24 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 7E8D7AE62CECD182009AD3DF /* swiftlint */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = swiftlint; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nswiftlint\n"; + }; 8FC0217E357D67979CAFB523 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -2409,7 +2447,7 @@ buildActionMask = 2147483647; files = ( 7E995F242CEAC5D2005B30EE /* AnotherIMApp.swift in Sources */, - 7E995F252CEAC5D2005B30EE /* ContentView.swift in Sources */, + 7E995F252CEAC5D2005B30EE /* RootView.swift in Sources */, 7E6AF38F2CEB9110004328B5 /* MonalXmppWrapper.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5374,6 +5412,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 7E8D7AE12CECD011009AD3DF /* XCRemoteSwiftPackageReference "SwiftfulRouting" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SwiftfulThinking/SwiftfulRouting"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.3.6; + }; + }; 841898A82957712000FEC77D /* XCRemoteSwiftPackageReference "ViewExtractor" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/GeorgeElsham/ViewExtractor"; @@ -5425,6 +5471,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + 7E8D7AE22CECD011009AD3DF /* SwiftfulRouting */ = { + isa = XCSwiftPackageProductDependency; + package = 7E8D7AE12CECD011009AD3DF /* XCRemoteSwiftPackageReference "SwiftfulRouting" */; + productName = SwiftfulRouting; + }; 8414ADFF2A7ABC4300EFFCCC /* LibMonalRustSwiftBridge */ = { isa = XCSwiftPackageProductDependency; productName = LibMonalRustSwiftBridge; diff --git a/Monal/another.im/AnotherIMApp.swift b/Monal/another.im/AnotherIMApp.swift index 18d2bdb..12ddadd 100644 --- a/Monal/another.im/AnotherIMApp.swift +++ b/Monal/another.im/AnotherIMApp.swift @@ -6,7 +6,7 @@ struct AnotherIMApp: App { var body: some Scene { WindowGroup { - ContentView() + RootView() .environmentObject(wrapper) } } diff --git a/Monal/another.im/ContentView.swift b/Monal/another.im/Views/RootView.swift similarity index 92% rename from Monal/another.im/ContentView.swift rename to Monal/another.im/Views/RootView.swift index 9019dc6..51c6472 100644 --- a/Monal/another.im/ContentView.swift +++ b/Monal/another.im/Views/RootView.swift @@ -1,6 +1,6 @@ import SwiftUI -struct ContentView: View { +struct RootView: View { @EnvironmentObject var wrapper: MonalXmppWrapper var body: some View { diff --git a/Monal/another.im/MonalXmppWrapper.swift b/Monal/another.im/XMPP/MonalXmppWrapper.swift similarity index 100% rename from Monal/another.im/MonalXmppWrapper.swift rename to Monal/another.im/XMPP/MonalXmppWrapper.swift