From 626f71da0b7f3ce6762f56adc3298b7fcf93ecd1 Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Thu, 20 Feb 2020 18:09:22 -0800 Subject: [PATCH 1/7] [tools] use Mint to install and upgrade SwiftLint to 0.39.1 --- Package.resolved | 88 ----------------------------------------------- Package.swift | 12 ++----- fastlane/Fastfile | 2 ++ 3 files changed, 5 insertions(+), 97 deletions(-) delete mode 100644 Package.resolved diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index d3ba1bc..0000000 --- a/Package.resolved +++ /dev/null @@ -1,88 +0,0 @@ -{ - "object": { - "pins": [ - { - "package": "Commandant", - "repositoryURL": "https://github.com/Carthage/Commandant.git", - "state": { - "branch": null, - "revision": "07cad52573bad19d95844035bf0b25acddf6b0f6", - "version": "0.15.0" - } - }, - { - "package": "Nimble", - "repositoryURL": "https://github.com/Quick/Nimble.git", - "state": { - "branch": null, - "revision": "e9d769113660769a4d9dd3afb855562c0b7ae7b0", - "version": "7.3.4" - } - }, - { - "package": "Quick", - "repositoryURL": "https://github.com/Quick/Quick.git", - "state": { - "branch": null, - "revision": "f2b5a06440ea87eba1a167cab37bf6496646c52e", - "version": "1.3.4" - } - }, - { - "package": "Result", - "repositoryURL": "https://github.com/antitypical/Result.git", - "state": { - "branch": null, - "revision": "2ca499ba456795616fbc471561ff1d963e6ae160", - "version": "4.1.0" - } - }, - { - "package": "SourceKitten", - "repositoryURL": "https://github.com/jpsim/SourceKitten.git", - "state": { - "branch": null, - "revision": "176f04295a09324673245d8ec0afcce21ace8722", - "version": "0.22.0" - } - }, - { - "package": "SwiftLint", - "repositoryURL": "https://github.com/Realm/SwiftLint", - "state": { - "branch": null, - "revision": "b2d428a4e24abd4f7cfeb0cd610b1656fb48c4a9", - "version": "0.30.1" - } - }, - { - "package": "SwiftyTextTable", - "repositoryURL": "https://github.com/scottrhoyt/SwiftyTextTable.git", - "state": { - "branch": null, - "revision": "7b8661865f0d9590a4b7c146237fecd99f3d8406", - "version": "0.8.2" - } - }, - { - "package": "SWXMLHash", - "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", - "state": { - "branch": null, - "revision": "9ba116841126f6c63435beef21a4cd247c32d2e7", - "version": "4.7.6" - } - }, - { - "package": "Yams", - "repositoryURL": "https://github.com/jpsim/Yams.git", - "state": { - "branch": null, - "revision": "26ab35f50ea891e8edefcc9d975db2f6b67e1d68", - "version": "1.0.1" - } - } - ] - }, - "version": 1 -} diff --git a/Package.swift b/Package.swift index a9b60ae..3b647e9 100644 --- a/Package.swift +++ b/Package.swift @@ -5,20 +5,14 @@ import PackageDescription let package = Package( name: "Nantes", - dependencies: [ - .package( - url: "https://github.com/Realm/SwiftLint", - from: "0.30.1" - ), - ], + dependencies: [], + // Note: SPM requires 1 target to build the package targets: [ .target( name: "Nantes", - dependencies: ["swiftlint"], path: "Source/Classes", - sources: ["NantesLabel.swift"] + exclude: ["Nantes.h"] ) ] ) - diff --git a/fastlane/Fastfile b/fastlane/Fastfile index ab0645c..19b4543 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -22,6 +22,8 @@ platform :ios do end lane :lint do + sh("brew list mint &>/dev/null || brew install mint") + sh("mint install realm/SwiftLint@0.39.1") swiftlint() end end From db44121ca86a2ab4d23af5b20eae05286c3c3ba7 Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Thu, 20 Feb 2020 18:27:41 -0800 Subject: [PATCH 2/7] update build phase script for swiftlint --- .travis.yml | 2 +- Nantes/Nantes.xcodeproj/project.pbxproj | 2 +- Source/Classes/Accessibility/Accessibility.swift | 5 ++--- Source/Classes/ActionHandling/Link.swift | 4 ++-- Source/Classes/Categories/NSAttributedString.swift | 8 ++++---- Source/Classes/Drawing/Scaling.swift | 2 +- Source/Classes/NantesLabel.swift | 8 ++++---- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7ba94e..49457ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,5 @@ before_script: - carthage bootstrap --platform iOS --no-use-binaries --cache-builds - cd ../ script: - - swift run swiftlint --strict --quiet + - bundle exec fastlane ios lint - bundle exec fastlane ios test diff --git a/Nantes/Nantes.xcodeproj/project.pbxproj b/Nantes/Nantes.xcodeproj/project.pbxproj index 5bc7957..6c3b604 100644 --- a/Nantes/Nantes.xcodeproj/project.pbxproj +++ b/Nantes/Nantes.xcodeproj/project.pbxproj @@ -350,7 +350,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"$CARTHAGE\" ]\nthen\n swift run swiftlint --path .. --strict --quiet\nfi\n"; + shellScript = "if [ -z \"$CARTHAGE\" ]\nthen\n brew list mint &>/dev/null || brew install mint\n mint install realm/SwiftLint@0.39.1\n mint run swiftlint swiftlint --path .. --strict --quiet\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Source/Classes/Accessibility/Accessibility.swift b/Source/Classes/Accessibility/Accessibility.swift index c977430..27cce2e 100644 --- a/Source/Classes/Accessibility/Accessibility.swift +++ b/Source/Classes/Accessibility/Accessibility.swift @@ -23,9 +23,8 @@ final class NantesLabelAccessibilityElement: UIAccessibilityElement { extension NantesLabel { override open var isAccessibilityElement: Bool { - get { - return false - } set { } + get { false } + set { } } func configureAccessibilityElements() { diff --git a/Source/Classes/ActionHandling/Link.swift b/Source/Classes/ActionHandling/Link.swift index 7656bde..6683f94 100644 --- a/Source/Classes/ActionHandling/Link.swift +++ b/Source/Classes/ActionHandling/Link.swift @@ -31,7 +31,7 @@ extension NantesLabel { } public static func == (lhs: NantesLabel.Link, rhs: NantesLabel.Link) -> Bool { - return (lhs.attributes as NSDictionary).isEqual(to: rhs.attributes) && + (lhs.attributes as NSDictionary).isEqual(to: rhs.attributes) && (lhs.activeAttributes as NSDictionary).isEqual(to: rhs.activeAttributes) && (lhs.inactiveAttributes as NSDictionary).isEqual(to: rhs.inactiveAttributes) && lhs.result?.range == rhs.result?.range && @@ -47,7 +47,7 @@ extension NantesLabel { /// Adds a link to a `url` with a specified `range` @discardableResult open func addLink(to url: URL, withRange range: NSRange) -> NantesLabel.Link? { - return addLinks(with: [.linkCheckingResult(range: range, url: url)], withAttributes: linkAttributes).first + addLinks(with: [.linkCheckingResult(range: range, url: url)], withAttributes: linkAttributes).first } @discardableResult diff --git a/Source/Classes/Categories/NSAttributedString.swift b/Source/Classes/Categories/NSAttributedString.swift index 679d5d0..312682e 100644 --- a/Source/Classes/Categories/NSAttributedString.swift +++ b/Source/Classes/Categories/NSAttributedString.swift @@ -68,9 +68,9 @@ extension NSAttributedString { } func findCheckingResults(usingDetector dataDetector: NSDataDetector) -> Set { - return Set(dataDetector.matches(in: string, - options: .withTransparentBounds, - range: NSRange(location: 0, - length: length))) + Set(dataDetector.matches(in: string, + options: .withTransparentBounds, + range: NSRange(location: 0, + length: length))) } } diff --git a/Source/Classes/Drawing/Scaling.swift b/Source/Classes/Drawing/Scaling.swift index 3cb20d3..4422604 100644 --- a/Source/Classes/Drawing/Scaling.swift +++ b/Source/Classes/Drawing/Scaling.swift @@ -7,7 +7,7 @@ // extension NantesLabel { - private var lineBreakWordWrapTextWidthScalingFactor: CGFloat { return CGFloat(Double.pi / M_E) } + private var lineBreakWordWrapTextWidthScalingFactor: CGFloat { CGFloat(Double.pi / M_E) } /// if the text width is greater than our available width we'll scale the font down /// Returns the scaled down NSAttributedString otherwise nil if we didn't scale anything diff --git a/Source/Classes/NantesLabel.swift b/Source/Classes/NantesLabel.swift index f2b38a4..8b63e13 100644 --- a/Source/Classes/NantesLabel.swift +++ b/Source/Classes/NantesLabel.swift @@ -178,7 +178,7 @@ /// Since we reset linkModels to make sure our links are up to date when the text changes override open var attributedText: NSAttributedString? { get { - return _attributedText + _attributedText } set { guard newValue != _attributedText else { return @@ -199,7 +199,7 @@ } override open var canBecomeFirstResponder: Bool { - return true + true } @IBInspectable override open var numberOfLines: Int { @@ -212,7 +212,7 @@ /// Since we reset linkModels to make sure our links are up to date when the text changes @IBInspectable override open var text: String? { get { - return attributedText?.string + attributedText?.string } set { guard let text = newValue else { attributedText = nil @@ -249,7 +249,7 @@ } override open func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { - return action == #selector(copy(_:)) + action == #selector(copy(_:)) } override open func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect { From d0c26dceedcda96364f85411a523ac1b2d13e3df Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Thu, 20 Feb 2020 18:53:55 -0800 Subject: [PATCH 3/7] add Mintfile --- Mintfile | 1 + Nantes/Nantes.xcodeproj/project.pbxproj | 2 +- fastlane/Fastfile | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 Mintfile diff --git a/Mintfile b/Mintfile new file mode 100644 index 0000000..9835594 --- /dev/null +++ b/Mintfile @@ -0,0 +1 @@ +realm/SwiftLint@0.39.1 \ No newline at end of file diff --git a/Nantes/Nantes.xcodeproj/project.pbxproj b/Nantes/Nantes.xcodeproj/project.pbxproj index 6c3b604..2ee1993 100644 --- a/Nantes/Nantes.xcodeproj/project.pbxproj +++ b/Nantes/Nantes.xcodeproj/project.pbxproj @@ -350,7 +350,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -z \"$CARTHAGE\" ]\nthen\n brew list mint &>/dev/null || brew install mint\n mint install realm/SwiftLint@0.39.1\n mint run swiftlint swiftlint --path .. --strict --quiet\nfi\n"; + shellScript = "if [ -z \"$CARTHAGE\" ]\nthen\n brew list mint &>/dev/null || brew install mint\n mint run --mintfile ../Mintfile swiftlint swiftlint --path .. --strict --quiet\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 19b4543..2606e88 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -23,7 +23,6 @@ platform :ios do lane :lint do sh("brew list mint &>/dev/null || brew install mint") - sh("mint install realm/SwiftLint@0.39.1") - swiftlint() + sh("mint run --mintfile ../Mintfile swiftlint swiftlint --path .. --strict --quiet") end end From 0cb336c077d1fa51109de97f3b38f2a7668f4b6a Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Thu, 20 Feb 2020 19:05:00 -0800 Subject: [PATCH 4/7] fix last implicit return lint issue --- Source/Classes/Sizing/Sizing.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Classes/Sizing/Sizing.swift b/Source/Classes/Sizing/Sizing.swift index e3a5ac1..39adb12 100644 --- a/Source/Classes/Sizing/Sizing.swift +++ b/Source/Classes/Sizing/Sizing.swift @@ -8,7 +8,7 @@ extension NantesLabel { override open var intrinsicContentSize: CGSize { - return sizeThatFits(super.intrinsicContentSize) + sizeThatFits(super.intrinsicContentSize) } override open func sizeThatFits(_ size: CGSize) -> CGSize { From 62530ec87dff2b6e03e5be07d8d7b7e85b368a49 Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Thu, 20 Feb 2020 19:06:30 -0800 Subject: [PATCH 5/7] use xcode11.3 image --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 49457ec..50d69d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: swift -osx_image: xcode10.2 +osx_image: xcode11.3 cache: bundler: true directories: From 8cf890dece47cd96335308fb97f5968afa84def0 Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Fri, 21 Feb 2020 16:28:40 -0800 Subject: [PATCH 6/7] revert to xcode10.2 and swiftlint 0.30.1 --- .travis.yml | 2 +- Mintfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50d69d8..49457ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: swift -osx_image: xcode11.3 +osx_image: xcode10.2 cache: bundler: true directories: diff --git a/Mintfile b/Mintfile index 9835594..adca466 100644 --- a/Mintfile +++ b/Mintfile @@ -1 +1 @@ -realm/SwiftLint@0.39.1 \ No newline at end of file +realm/SwiftLint@0.30.1 \ No newline at end of file From d25c8e724f8920ffc105cfc79fff054566d1ec0e Mon Sep 17 00:00:00 2001 From: Leo Ngo Date: Fri, 21 Feb 2020 16:30:47 -0800 Subject: [PATCH 7/7] revert implicit return --- Source/Classes/Accessibility/Accessibility.swift | 5 +++-- Source/Classes/ActionHandling/Link.swift | 4 ++-- Source/Classes/Categories/NSAttributedString.swift | 8 ++++---- Source/Classes/Drawing/Scaling.swift | 2 +- Source/Classes/NantesLabel.swift | 8 ++++---- Source/Classes/Sizing/Sizing.swift | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/Classes/Accessibility/Accessibility.swift b/Source/Classes/Accessibility/Accessibility.swift index 27cce2e..c977430 100644 --- a/Source/Classes/Accessibility/Accessibility.swift +++ b/Source/Classes/Accessibility/Accessibility.swift @@ -23,8 +23,9 @@ final class NantesLabelAccessibilityElement: UIAccessibilityElement { extension NantesLabel { override open var isAccessibilityElement: Bool { - get { false } - set { } + get { + return false + } set { } } func configureAccessibilityElements() { diff --git a/Source/Classes/ActionHandling/Link.swift b/Source/Classes/ActionHandling/Link.swift index 6683f94..7656bde 100644 --- a/Source/Classes/ActionHandling/Link.swift +++ b/Source/Classes/ActionHandling/Link.swift @@ -31,7 +31,7 @@ extension NantesLabel { } public static func == (lhs: NantesLabel.Link, rhs: NantesLabel.Link) -> Bool { - (lhs.attributes as NSDictionary).isEqual(to: rhs.attributes) && + return (lhs.attributes as NSDictionary).isEqual(to: rhs.attributes) && (lhs.activeAttributes as NSDictionary).isEqual(to: rhs.activeAttributes) && (lhs.inactiveAttributes as NSDictionary).isEqual(to: rhs.inactiveAttributes) && lhs.result?.range == rhs.result?.range && @@ -47,7 +47,7 @@ extension NantesLabel { /// Adds a link to a `url` with a specified `range` @discardableResult open func addLink(to url: URL, withRange range: NSRange) -> NantesLabel.Link? { - addLinks(with: [.linkCheckingResult(range: range, url: url)], withAttributes: linkAttributes).first + return addLinks(with: [.linkCheckingResult(range: range, url: url)], withAttributes: linkAttributes).first } @discardableResult diff --git a/Source/Classes/Categories/NSAttributedString.swift b/Source/Classes/Categories/NSAttributedString.swift index 312682e..679d5d0 100644 --- a/Source/Classes/Categories/NSAttributedString.swift +++ b/Source/Classes/Categories/NSAttributedString.swift @@ -68,9 +68,9 @@ extension NSAttributedString { } func findCheckingResults(usingDetector dataDetector: NSDataDetector) -> Set { - Set(dataDetector.matches(in: string, - options: .withTransparentBounds, - range: NSRange(location: 0, - length: length))) + return Set(dataDetector.matches(in: string, + options: .withTransparentBounds, + range: NSRange(location: 0, + length: length))) } } diff --git a/Source/Classes/Drawing/Scaling.swift b/Source/Classes/Drawing/Scaling.swift index 4422604..3cb20d3 100644 --- a/Source/Classes/Drawing/Scaling.swift +++ b/Source/Classes/Drawing/Scaling.swift @@ -7,7 +7,7 @@ // extension NantesLabel { - private var lineBreakWordWrapTextWidthScalingFactor: CGFloat { CGFloat(Double.pi / M_E) } + private var lineBreakWordWrapTextWidthScalingFactor: CGFloat { return CGFloat(Double.pi / M_E) } /// if the text width is greater than our available width we'll scale the font down /// Returns the scaled down NSAttributedString otherwise nil if we didn't scale anything diff --git a/Source/Classes/NantesLabel.swift b/Source/Classes/NantesLabel.swift index 8b63e13..f2b38a4 100644 --- a/Source/Classes/NantesLabel.swift +++ b/Source/Classes/NantesLabel.swift @@ -178,7 +178,7 @@ /// Since we reset linkModels to make sure our links are up to date when the text changes override open var attributedText: NSAttributedString? { get { - _attributedText + return _attributedText } set { guard newValue != _attributedText else { return @@ -199,7 +199,7 @@ } override open var canBecomeFirstResponder: Bool { - true + return true } @IBInspectable override open var numberOfLines: Int { @@ -212,7 +212,7 @@ /// Since we reset linkModels to make sure our links are up to date when the text changes @IBInspectable override open var text: String? { get { - attributedText?.string + return attributedText?.string } set { guard let text = newValue else { attributedText = nil @@ -249,7 +249,7 @@ } override open func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { - action == #selector(copy(_:)) + return action == #selector(copy(_:)) } override open func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect { diff --git a/Source/Classes/Sizing/Sizing.swift b/Source/Classes/Sizing/Sizing.swift index 39adb12..e3a5ac1 100644 --- a/Source/Classes/Sizing/Sizing.swift +++ b/Source/Classes/Sizing/Sizing.swift @@ -8,7 +8,7 @@ extension NantesLabel { override open var intrinsicContentSize: CGSize { - sizeThatFits(super.intrinsicContentSize) + return sizeThatFits(super.intrinsicContentSize) } override open func sizeThatFits(_ size: CGSize) -> CGSize {