diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..a97fa2b --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,8 @@ +disabled_rules: + - line_length + - unused_closure_parameter + - identifier_name + +file_length: + warning: 850 + error: 1200 diff --git a/Examples/CodeExample/SignUpViewController.swift b/Examples/CodeExample/SignUpViewController.swift index 3da8436..e854766 100644 --- a/Examples/CodeExample/SignUpViewController.swift +++ b/Examples/CodeExample/SignUpViewController.swift @@ -83,6 +83,7 @@ class SignUpViewController: ScrollingContentViewController { configureTextField(passwordTextField, placeholder: "Password", textContentType: nil, autocapitalizationType: .none, keyboardType: .default, isSecureTextEntry: true) } + // swiftlint:disable:next function_parameter_count private func configureTextField(_ textField: UITextField, placeholder: String?, textContentType: UITextContentType?, autocapitalizationType: UITextAutocapitalizationType, keyboardType: UIKeyboardType, isSecureTextEntry: Bool) { textField.placeholder = placeholder textField.autocapitalizationType = autocapitalizationType @@ -97,6 +98,7 @@ class SignUpViewController: ScrollingContentViewController { textField.isSecureTextEntry = isSecureTextEntry } + // swiftlint:disable:next function_body_length private func addConstraints() { logoImageView.translatesAutoresizingMaskIntoConstraints = false nameTextField.translatesAutoresizingMaskIntoConstraints = false @@ -153,7 +155,7 @@ class SignUpViewController: ScrollingContentViewController { logoImageTopLayoutGuide.heightAnchor.constraint(equalTo: logoImageBottomLayoutGuide.heightAnchor), logoImageBottomLayoutGuide.heightAnchor.constraint(equalTo: signUpButtonBottomLayoutGuide.heightAnchor, multiplier: 2, constant: 0), - signUpButtonBottomLayoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: 16), + signUpButtonBottomLayoutGuide.heightAnchor.constraint(greaterThanOrEqualToConstant: 16) ] logoImageView.setContentHuggingPriority(.required, for: .vertical) diff --git a/Examples/ManagerExample/AppDelegate.swift b/Examples/ManagerExample/AppDelegate.swift index d9cea55..b8eba27 100644 --- a/Examples/ManagerExample/AppDelegate.swift +++ b/Examples/ManagerExample/AppDelegate.swift @@ -20,4 +20,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } } - diff --git a/Examples/Shared/GradientBackgroundView.swift b/Examples/Shared/GradientBackgroundView.swift index cf59777..f51c776 100644 --- a/Examples/Shared/GradientBackgroundView.swift +++ b/Examples/Shared/GradientBackgroundView.swift @@ -35,7 +35,7 @@ class GradientBackgroundView: UIView { gradientLayer.colors = [ UIColor(red: 37/255, green: 176/255, blue: 176/255, alpha: 1).cgColor, - UIColor(red: 72/255, green: 72/255, blue: 171/255, alpha: 1).cgColor, + UIColor(red: 72/255, green: 72/255, blue: 171/255, alpha: 1).cgColor ] } diff --git a/Examples/Shared/PillTextField.swift b/Examples/Shared/PillTextField.swift index de86d1b..600390c 100644 --- a/Examples/Shared/PillTextField.swift +++ b/Examples/Shared/PillTextField.swift @@ -56,7 +56,7 @@ class PillTextField: UITextField { private func updateAttributedPlaceholder() { let placeholderAttributes: [NSAttributedString.Key: Any] = [ .foregroundColor: placeholderColor, - .font: UIFont.systemFont(ofSize: 17, weight: .medium), + .font: UIFont.systemFont(ofSize: 17, weight: .medium) ] if let placeholder = placeholder { attributedPlaceholder = NSAttributedString(string: placeholder, attributes: placeholderAttributes) diff --git a/Examples/Shared/SignUpController.swift b/Examples/Shared/SignUpController.swift index 3cab8db..4a342e1 100644 --- a/Examples/Shared/SignUpController.swift +++ b/Examples/Shared/SignUpController.swift @@ -84,11 +84,11 @@ class SignUpController: NSObject { let signInButtonTitleRegularFontAttributes: [NSAttributedString.Key: Any] = [ .foregroundColor: signInButtonTitleColor, - .font: UIFont.systemFont(ofSize: signInButtonTitleFontSize, weight: .regular), + .font: UIFont.systemFont(ofSize: signInButtonTitleFontSize, weight: .regular) ] let signInButtonTitleMediumFontAttributes: [NSAttributedString.Key: Any] = [ .foregroundColor: signInButtonTitleColor, - .font: UIFont.systemFont(ofSize: signInButtonTitleFontSize, weight: .medium), + .font: UIFont.systemFont(ofSize: signInButtonTitleFontSize, weight: .medium) ] signInButtonTitle.append(NSAttributedString(string: "Already have an account? ", attributes: signInButtonTitleRegularFontAttributes)) diff --git a/ScrollingContentViewController.xcodeproj/project.pbxproj b/ScrollingContentViewController.xcodeproj/project.pbxproj index 82df45a..56304e8 100644 --- a/ScrollingContentViewController.xcodeproj/project.pbxproj +++ b/ScrollingContentViewController.xcodeproj/project.pbxproj @@ -509,6 +509,7 @@ 3A5702CA21E2CBB600E4CC55 /* Sources */, 3A5702CB21E2CBB600E4CC55 /* Frameworks */, 3A5702CC21E2CBB600E4CC55 /* Resources */, + 3ACE0D7A220B2D790093FE5A /* ShellScript */, ); buildRules = ( ); @@ -758,6 +759,26 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 3ACE0D7A220B2D790093FE5A /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 3A5702CA21E2CBB600E4CC55 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Source/ScrollViewFilter.swift b/Source/ScrollViewFilter.swift index 6ba5bb1..c20846c 100644 --- a/Source/ScrollViewFilter.swift +++ b/Source/ScrollViewFilter.swift @@ -241,7 +241,7 @@ internal class ScrollViewFilter { self.keyboardFrameEvent = nil keyboardDelegate?.scrollViewFilter(self, adjustViewForKeyboardFrameEvent: keyboardFrameEvent) } - + if let scrollRectEvent = scrollRectEvent { // Note: It's possible that the call to adjustViewForKeyboardFrameEvent, above, // results in a new call to submitScrollRectEvent which will be immediately handled diff --git a/Source/ScrollingContentScrollView.swift b/Source/ScrollingContentScrollView.swift index 89f9491..e6ea966 100644 --- a/Source/ScrollingContentScrollView.swift +++ b/Source/ScrollingContentScrollView.swift @@ -156,10 +156,8 @@ extension ScrollingContentScrollView: ScrollViewFilterScrollDelegate { switch scrollRectEvent.contentArea { case .scrollViewRect(let rect): scrollViewRect = rect - break case .descendantViewRect(let rect, let descendantView): scrollViewRect = convert(rect, from: descendantView) - break } scrollViewRect = scrollViewRect.insetBy(dx: 0, dy: -scrollRectEvent.margin) diff --git a/Source/ScrollingContentViewManager.swift b/Source/ScrollingContentViewManager.swift index 02777c5..a6c072c 100644 --- a/Source/ScrollingContentViewManager.swift +++ b/Source/ScrollingContentViewManager.swift @@ -98,7 +98,7 @@ public class ScrollingContentViewManager: KeyboardObservering, ScrollViewBounceC /// /// This property's access control level is `internal` so it can be accessed by unit /// tests. - internal(set) var keyboardObserver: KeyboardObserver? + internal var keyboardObserver: KeyboardObserver? /// An object that modifies the scroll view's `alwaysBounceVertical` property to /// reflect the state of the presented keyboard. @@ -465,7 +465,7 @@ public class ScrollingContentViewManager: KeyboardObservering, ScrollViewBounceC scrollView.contentLayoutGuide.topAnchor.constraint(equalTo: contentView.topAnchor), scrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), contentViewMinimumWidthConstraint, - contentViewMinimumHeightConstraint, + contentViewMinimumHeightConstraint ] scrollView.addConstraints(constraints) diff --git a/Source/UIResponder+Current.swift b/Source/UIResponder+Current.swift index 0e99f49..ff4bb8f 100644 --- a/Source/UIResponder+Current.swift +++ b/Source/UIResponder+Current.swift @@ -15,7 +15,7 @@ import UIKit -private var foundFirstResponder: UIResponder? = nil +private var foundFirstResponder: UIResponder? internal extension UIResponder {