ArchiveCore/Sources/ArchiveBackend/FolderAccess/local/DirectoryWatcher/DirectoryDeepWatcher.swift
Function startWatching
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private func startWatching(contentsOf url: URL) throws {
let enumerator = FileManager.default.enumerator(at: url,
includingPropertiesForKeys: [.creationDateKey, .isDirectoryKey],
options: [.skipsHiddenFiles]) { (url, error) -> Bool in
// if a folder was deleted during enumeration, there occurs a "no such file" error - we assume that there will be another change triggered
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Line should be 120 characters or less: currently 143 characters Open
Open
let source = DispatchSource.makeFileSystemObjectSource(fileDescriptor: descriptor, eventMask: [.write, .rename, .delete], queue: queue)
- Exclude checks
Line should be 120 characters or less: currently 123 characters Open
Open
Self.log.criticalAndAssert("Directory enumerator error", metadata: ["error": "\(error)", "url": "\(url.path)"])
- Exclude checks
Line should be 120 characters or less: currently 150 characters Open
Open
// if a folder was deleted during enumeration, there occurs a "no such file" error - we assume that there will be another change triggered
- Exclude checks