PDF-Archiver/PDF-Archiver

View on GitHub

Showing 38 of 599 total issues

Function handleAttachments has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private func handleAttachments() {
        do {
            let url = PathConstants.extensionTempPdfURL
            let inputItems = (extensionContext?.inputItems as? [NSExtensionItem]) ?? []
            var success = false
Severity: Minor
Found in ShareExtension/ShareViewController.swift - About 45 mins to fix

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

Function createAndPost has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public func createAndPost(title: LocalizedStringKey, message: LocalizedStringKey, primaryButtonTitle: LocalizedStringKey, file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
Severity: Minor
Found in Shared/Other/Constants/ErrorHandling/NotificationCenter+Error.swift - About 45 mins to fix

    Function createDetails has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        static func createDetails(from item: NSMetadataItem) -> FileChange.Details? {
            // get the document path
            guard let documentPath = item.value(forAttribute: NSMetadataItemURLKey) as? URL else {
                log.errorAndAssert("Could not parse Metadata URL.")
                return nil
    Severity: Minor
    Found in Shared/Other/FolderAccess/iCloud/ICloudFolderProvider.swift - About 45 mins to fix

    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

    Function info has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        func info(_ message: String,
                   metadata: @autoclosure () -> [String: String],
                   file: StaticString = #file,
                   function: StaticString = #function,
                   line: UInt = #line) {
    Severity: Minor
    Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

      Function debug has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          func debug(_ message: String,
                     metadata: @autoclosure () -> [String: String],
                     file: StaticString = #file,
                     function: StaticString = #function,
                     line: UInt = #line) {
      Severity: Minor
      Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

        Function errorAndAssert has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            func errorAndAssert(_ message: String,
                                metadata: @autoclosure () -> [String: String]? = nil,
                                file: StaticString = #file,
                                function: StaticString = #function,
                                line: UInt = #line) {
        Severity: Minor
        Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

          Function criticalAndAssert has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              func criticalAndAssert(_ message: String,
                                     metadata: @autoclosure () -> [String: String]? = nil,
                                     file: StaticString = #file,
                                     function: StaticString = #function,
                                     line: UInt = #line) {
          Severity: Minor
          Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

            Function trace has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                func trace(_ message: String,
                           metadata: @autoclosure () -> [String: String],
                           file: StaticString = #file,
                           function: StaticString = #function,
                           line: UInt = #line) {
            Severity: Minor
            Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

              Function error has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  func error(_ message: String,
                             metadata: @autoclosure () -> [String: String]?,
                             file: StaticString = #file,
                             function: StaticString = #function,
                             line: UInt = #line) {
              Severity: Minor
              Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

                Function input2message has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private func input2message(_ message: String,
                                               metadata: [String: String]?,
                                               file: StaticString,
                                               function: StaticString,
                                               line: UInt) -> String {
                Severity: Minor
                Found in Shared/Other/Constants/Logging/Log.swift - About 35 mins to fix

                  Function snapshot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      open class func snapshot(_ name: String, timeWaitingForIdle timeout: TimeInterval = 20) {
                          if timeout > 0 {
                              waitForLoadingIndicatorToDisappear(within: timeout)
                          }
                  
                  
                  Severity: Minor
                  Found in UITests iOS/SnapshotHelper.swift - About 35 mins to fix

                  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

                  Function handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private func handle(url: URL) throws {
                          documentProcessingState = .processing
                          try url.securityScope { url in
                              if let pdf = PDFDocument(url: url) {
                                  handle(pdf: pdf)
                  Severity: Minor
                  Found in Shared/Import/PDFDropHandler.swift - About 35 mins to fix

                  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

                  Avoid too many return statements within this function.
                  Open

                          return FileChange.Details(url: documentPath, filename: filename, size: Int(size), downloadStatus: documentStatus)
                  Severity: Major
                  Found in Shared/Other/FolderAccess/iCloud/ICloudFolderProvider.swift - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return UIImage(cgImage: cgImage).png
                    Severity: Major
                    Found in Tests macOS/ArchiveBackendTests/helper/XCTestCase.swift - About 30 mins to fix

                      Function parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static func parse(_ text: String) -> Set<String> {
                              var documentTags = Set<String>()
                      
                              let tagger = NLTagger(tagSchemes: [.nameType])
                              tagger.string = text
                      Severity: Minor
                      Found in Shared/Archive/TagParser.swift - About 25 mins to fix

                      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

                      Function moveContents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public func moveContents(of sourceFolder: URL, to destinationFolder: URL) throws {
                              guard directoryExists(at: sourceFolder),
                                    directoryExists(at: destinationFolder) else {
                                  preconditionFailure("Source/Destionation is no folder - this should not happen.")
                              }
                      Severity: Minor
                      Found in Shared/Other/Extensions/FileManager.swift - About 25 mins to fix

                      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

                      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

                      Function renderPdf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private static func renderPdf(from observations: [TextObservation]) -> PDFDocument {
                      
                              var pages = [PDFPage]()
                              for observation in observations {
                      
                      
                      Severity: Minor
                      Found in Shared/Other/DocumentProcessing/PDFProcessing.swift - About 25 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language