Skip to content

Commit

Permalink
update swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Jan 9, 2024
1 parent bb308d7 commit 6d1c784
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
19 changes: 17 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ opt_in_rules:
- unavailable_function
- no_space_in_method_call
- discouraged_assert
# - legacy_objc_type
# - file_name
- file_name_no_space
- discouraged_none_name
- return_value_from_void_function
- prefer_zero_over_explicit_init
- shorthand_optional_binding
- xct_specific_matcher
- unneeded_synthesized_initializer

# style
- attributes
Expand All @@ -63,19 +70,27 @@ opt_in_rules:
- unneeded_parentheses_in_closure_argument
- vertical_whitespace_between_cases
- prefer_self_in_static_references
- comma_inheritance
- direct_return
- period_spacing
- superfluous_else
# - sorted_enum_cases
- non_overridable_class_declaration

# lint
- overridden_super_call
- override_in_extension
- yoda_condition
- anyobject_protocol
- array_init
- empty_xctest_method
- identical_operands
- prohibited_super_call
- unused_capture_list
- duplicate_enum_cases
- legacy_multiple
- accessibility_label_for_image
- lower_acl_than_parent
- unhandled_throwing_task
- private_swiftui_state

# Rules run by `swiftlint analyze` (experimental)
analyzer_rules:
Expand Down
3 changes: 1 addition & 2 deletions Example/ExampleApp/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ extension UICollectionViewCompositionalLayout {
var configuration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
configuration.headerMode = .supplementary
configuration.footerMode = .supplementary
let section = NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
return section
return NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreDataStackProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public struct CoreDataStackProvider {
}
}

if let queue = queue {
if let queue {
queue.async(execute: creationClosure)
} else {
creationClosure()
Expand Down
3 changes: 1 addition & 2 deletions Sources/FetchedResultsDiffableDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ extension _FetchedResultsDiffableDataSource {
}
let sectionInfo = controller.section(at: indexPath.section)
let config = configMap[kind]!
let view = config._dequeueAndConfigureViewFor(
return config._dequeueAndConfigureViewFor(
collectionView: collectionView,
at: indexPath,
with: object,
in: sectionInfo
)
return view
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/Migrate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ func findModelsInBundle(_ bundle: Bundle) -> [NSManagedObjectModel] {
.joined()
.sorted { $0.absoluteString < $1.absoluteString }

let managedObjectModels = modelVersionFileURLs.compactMap { url -> NSManagedObjectModel? in
return modelVersionFileURLs.compactMap { url -> NSManagedObjectModel? in
NSManagedObjectModel(contentsOf: url)
}

return managedObjectModels
}

func buildMigrationMappingSteps(bundle: Bundle,
Expand Down
2 changes: 2 additions & 0 deletions Sources/NSManagedObjectContext+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extension NSManagedObjectContext {
completion?(.failure(error))
}
}

// swiftlint:disable:next void_function_in_ternary
wait ? self.performAndWait(block) : self.perform(block)
}
}
9 changes: 6 additions & 3 deletions scripts/lint.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#
# Runs SwiftLint and checks for installation of correct version.

set -e
export PATH="$PATH:/opt/homebrew/bin"

PROJECT="JSQCoreDataKit.xcodeproj"
SCHEME="JSQCoreDataKit"

VERSION="0.46.2"
VERSION="0.54.0"

FOUND=$(swiftlint version)
LINK="https://github.com/realm/SwiftLint"
Expand All @@ -36,15 +39,15 @@ if which swiftlint >/dev/null; then
if [[ "$argval" == "fix" ]]; then
echo "Auto-correcting lint errors..."
echo ""
swiftlint --fix --config $CONFIG && swiftlint --config $CONFIG
swiftlint --fix --progress --config $CONFIG && swiftlint --config $CONFIG
echo ""
# run analyze
elif [[ "$argval" == "analyze" ]]; then
LOG="xcodebuild.log"
echo "Running anaylze..."
echo ""
xcodebuild -scheme $SCHEME -project $PROJECT clean build-for-testing > $LOG
swiftlint analyze --fix --format --strict --config $CONFIG --compiler-log-path $LOG
swiftlint analyze --fix --progress --format --strict --config $CONFIG --compiler-log-path $LOG
rm $LOG
echo ""
else
Expand Down

0 comments on commit 6d1c784

Please # to comment.