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
- 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 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 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 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) {
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) {
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) {
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) {
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) {
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) {
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 {
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
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)
- 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 FileChange.Details(url: documentPath, filename: filename, size: Int(size), downloadStatus: documentStatus)
Avoid too many return
statements within this function. Open
return UIImage(cgImage: cgImage).png
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
- 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"
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 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"