PDF-Archiver/PDF-Archiver

View on GitHub

Showing 484 of 484 total issues

Function testJPGMultiplePages has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func testJPGMultiplePages() throws {
        let uuid = UUID()
        try FileManager.default.copyItem(at: Bundle.billJPGGUrl, to: Self.tempFolder.appendingPathComponent(uuid.uuidString + "-1").appendingPathExtension("jpg"))
        try FileManager.default.copyItem(at: Bundle.billJPGGUrl, to: Self.tempFolder.appendingPathComponent(uuid.uuidString + "-2").appendingPathExtension("jpg"))
        try FileManager.default.copyItem(at: Bundle.billJPGGUrl, to: Self.tempFolder.appendingPathComponent(uuid.uuidString + "-3").appendingPathExtension("jpg"))
Severity: Minor
Found in ArchiveCore/Tests/ArchiveBackendTests/PDFProcessingTests.swift - About 1 hr to fix

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

        public static func parse(_ text: String) -> Set<String> {
            var documentTags = Set<String>()
    
            if #available(iOS 12.0, OSX 10.14, *) {
                let tagger = NLTagger(tagSchemes: [.nameType])
    Severity: Minor
    Found in ArchiveCore/Sources/ArchiveBackend/Helpers/TagParser.swift - About 55 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 saveData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        func saveData(at url: URL, with validUTIs: [UTType]) throws -> Bool {
            var error: Error?
            var data: Data?
    
            for uti in validUTIs where hasItemConformingToTypeIdentifier(uti.identifier) {

    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 syncLoadItem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        func syncLoadItem(forTypeIdentifier uti: UTType) throws -> Data? {
            var data: Data?
            var error: Error?
            let semaphore = DispatchSemaphore(value: 0)
            self.loadItem(forTypeIdentifier: uti.identifier, options: nil) { rawData, rawError in

    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 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public func createAndPost(title: LocalizedStringKey, message: LocalizedStringKey, primaryButton: Alert.Button, secondaryButton: Alert.Button, file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func testSelectTag() throws {
              let tabBar = app.tabBars.firstMatch
              _ = tabBar.waitForExistence(timeout: 10)
              tabBar.buttons[NSLocalizedString("Tag", comment: "")].tap()
              snapshot("02-Tag-Screen")
      Severity: Major
      Found in UITests iOS/UITests_iOS.swift and 3 other locations - About 50 mins to fix
      UITests iOS/UITests_iOS.swift on lines 25..30
      UITests iOS/UITests_iOS.swift on lines 39..44
      UITests iOS/UITests_iOS.swift on lines 46..51

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 59.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func testSelectMore() throws {
              let tabBar = app.tabBars.firstMatch
              _ = tabBar.waitForExistence(timeout: 10)
              tabBar.buttons[NSLocalizedString("More", comment: "")].tap()
              snapshot("04-More-Screen")
      Severity: Major
      Found in UITests iOS/UITests_iOS.swift and 3 other locations - About 50 mins to fix
      UITests iOS/UITests_iOS.swift on lines 25..30
      UITests iOS/UITests_iOS.swift on lines 32..37
      UITests iOS/UITests_iOS.swift on lines 39..44

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 59.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func testSelectScan() throws {
              let tabBar = app.tabBars.firstMatch
              _ = tabBar.waitForExistence(timeout: 10)
              tabBar.buttons[NSLocalizedString("Scan", comment: "")].tap()
              snapshot("01-Scan-Screen")
      Severity: Major
      Found in UITests iOS/UITests_iOS.swift and 3 other locations - About 50 mins to fix
      UITests iOS/UITests_iOS.swift on lines 32..37
      UITests iOS/UITests_iOS.swift on lines 39..44
      UITests iOS/UITests_iOS.swift on lines 46..51

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 59.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          func testSelectArchive() throws {
              let tabBar = app.tabBars.firstMatch
              _ = tabBar.waitForExistence(timeout: 10)
              tabBar.buttons[NSLocalizedString("Archive", comment: "")].tap()
              snapshot("03-Archive-Screen")
      Severity: Major
      Found in UITests iOS/UITests_iOS.swift and 3 other locations - About 50 mins to fix
      UITests iOS/UITests_iOS.swift on lines 25..30
      UITests iOS/UITests_iOS.swift on lines 32..37
      UITests iOS/UITests_iOS.swift on lines 46..51

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 59.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public static var untaggedURL: URL? {
              get {
                  appGroup.object(forKey: Names.untaggedURL.rawValue) as? URL
              }
              set {
      Severity: Minor
      Found in ArchiveCore/Sources/ArchiveSharedConstants/UserDefaults.swift and 1 other location - About 45 mins to fix
      ArchiveCore/Sources/ArchiveSharedConstants/UserDefaults.swift on lines 111..118

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public static var archiveURL: URL? {
              get {
                  appGroup.object(forKey: Names.archiveURL.rawValue) as? URL
              }
              set {
      Severity: Minor
      Found in ArchiveCore/Sources/ArchiveSharedConstants/UserDefaults.swift and 1 other location - About 45 mins to fix
      ArchiveCore/Sources/ArchiveSharedConstants/UserDefaults.swift on lines 120..127

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 57.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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 log has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata? = nil, file: String = #file, function: String = #function, line: UInt = #line) {

        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) {

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

          public func sort<Type: CustomComparable>(_ items: [Type], by sortDescriptors: [NSSortDescriptor]) throws -> [Type] {
              return try items.sorted { (lhs, rhs) -> Bool in
                  for sortDescriptor in sortDescriptors {
                      if try lhs.isBefore(rhs, sortDescriptor) { return true }
                      if try rhs.isBefore(lhs, sortDescriptor) { return false }
          Severity: Minor
          Found in ArchiveCore/Sources/ArchiveBackend/Helpers/SortDescriptors.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 criticalAndAssert has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              func criticalAndAssert(_ message: @autoclosure () -> Logger.Message,
                                     metadata: @autoclosure () -> Logger.Metadata? = nil,
                                     source: @autoclosure () -> String? = nil,
                                     file: StaticString = #file,
                                     function: StaticString = #function,
          Severity: Minor
          Found in ArchiveCore/Sources/ArchiveSharedConstants/Logging/Log.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

            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 errorAndAssert has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                func errorAndAssert(_ message: @autoclosure () -> Logger.Message,
                                    metadata: @autoclosure () -> Logger.Metadata? = nil,
                                    source: @autoclosure () -> String? = nil,
                                    file: StaticString = #file,
                                    function: StaticString = #function,
            Severity: Minor
            Found in ArchiveCore/Sources/ArchiveSharedConstants/Logging/Log.swift - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          for observation in (request.results as? [VNRecognizedTextObservation] ?? []) {
                                              guard let candidate = observation.topCandidates(1).first,
                                                  !candidate.string.isEmpty else { continue }
                                              thisObservation.append(candidate.string)
                                          }
              Severity: Major
              Found in ArchiveCore/Sources/ArchiveBackend/PDFRendering/PDFProcessing.swift - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        guard let item = matrix[prevColumn, row - 1] else { continue }
                Severity: Major
                Found in ArchiveCore/Sources/ArchiveBackend/Search/Array+FuzzyMatch.swift - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language