Showing 39 of 484 total issues
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
- 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
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) {
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
- 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
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 }
- 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
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,
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
- 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
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,
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)
}
Avoid deeply nested control flow statements. Open
guard let item = matrix[prevColumn, row - 1] else { continue }
Function tapped
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
func tapped(button: IAPButton, presentationMode: Binding<PresentationMode>) {
switch button {
case .level1:
log.info("IAPView - buy: Monthly subscription.")
- 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
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)
}
- 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
Avoid too many return
statements within this function. Open
return (score, matrix)
Avoid too many return
statements within this function. Open
return UIImage(cgImage: cgImage).png
Avoid too many return
statements within this function. Open
return FileChange.Details(url: documentPath, filename: filename, size: Int(size), downloadStatus: documentStatus)
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 {
- 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
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
- 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
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.")
}
- 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"