PDF-Archiver/PDF-Archiver

View on GitHub
ArchiveCore/Sources/ArchiveBackend/FolderAccess/local/DirectoryWatcher/DirectoryDeepWatcher.swift

Summary

Maintainability
A
25 mins
Test Coverage

Function startWatching has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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

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

        let source = DispatchSource.makeFileSystemObjectSource(fileDescriptor: descriptor, eventMask: [.write, .rename, .delete], queue: queue)

Line should be 120 characters or less: currently 123 characters
Open

            Self.log.criticalAndAssert("Directory enumerator error", metadata: ["error": "\(error)", "url": "\(url.path)"])

Line should be 120 characters or less: currently 150 characters
Open

            // if a folder was deleted during enumeration, there occurs a "no such file" error - we assume that there will be another change triggered

There are no issues that match your filters.

Category
Status