add swiftlint

This commit is contained in:
Woit 2024-11-19 15:05:25 +01:00
parent cc7a3b9286
commit a808af8057
5 changed files with 183 additions and 7 deletions

125
Monal/.swiftlint.yml Normal file
View file

@ -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

View file

@ -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 = "<group>"; };
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 = "<group>"; };
7E995F222CEAC5D2005B30EE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
7E995F222CEAC5D2005B30EE /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
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 = "<group>"; };
7ED6F0182CECC3BF0035B3B7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
@ -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 = "<group>";
};
7E8D7AE42CECD037009AD3DF /* Views */ = {
isa = PBXGroup;
children = (
7E995F222CEAC5D2005B30EE /* RootView.swift */,
);
path = Views;
sourceTree = "<group>";
};
7E8D7AE52CECD05C009AD3DF /* XMPP */ = {
isa = PBXGroup;
children = (
7E6AF38E2CEB9110004328B5 /* MonalXmppWrapper.swift */,
);
path = XMPP;
sourceTree = "<group>";
};
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 = "<group>";
@ -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;

View file

@ -6,7 +6,7 @@ struct AnotherIMApp: App {
var body: some Scene {
WindowGroup {
ContentView()
RootView()
.environmentObject(wrapper)
}
}

View file

@ -1,6 +1,6 @@
import SwiftUI
struct ContentView: View {
struct RootView: View {
@EnvironmentObject var wrapper: MonalXmppWrapper
var body: some View {