Showing 10 of 28 total issues
Function fileNameFromFontName
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func fileNameFromFontName(fontName: String) -> String? {
let fm = FileManager.default
let path = Bundle.main.resourcePath!
let directoryItems = try? fm.contentsOfDirectory(atPath: path)
- 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 sendEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public func sendEvent(name: String, complete: ((Survey?, Error?) -> Void)? = nil) {
guard self.api != nil else {
if let callback = complete {
callback(nil, IterateError.invalidAPIKey)
}
- 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 encode
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public func encode(to encoder: Encoder) throws {
if let date = value as? Date {
let timestamp = Int(date.timeIntervalSince1970)
var container = encoder.container(keyedBy: DateCodingKeys.self)
try container.encode("date", forKey: DateCodingKeys.type)
- 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 performDataTask
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func performDataTask<T: Codable>(request: URLRequest, completion: @escaping (T?, Error?) -> Void) {
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
DispatchQueue.main.async {
guard error == nil else {
print("Error calling the Iterate API: \(String(describing: error))")
Function prepareStyle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private func prepareStyle() {
guard let promptButton = promptButton else {
return
}
- 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 fontNamesFromFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
func fontNamesFromFile(for file: URL) -> [String]? {
var fontNames: [String] = []
guard let data = try? Data(contentsOf: file) else {
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
Avoid too many return
statements within this function. Open
return nil
Function visitImage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
mutating public func visitImage(_ image: Image) -> NSAttributedString {
guard let urlString = image.source, let url = URL(string: urlString) else {
return NSMutableAttributedString()
}
- 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 getPresentingViewController
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func getPresentingViewController() -> UIViewController? {
// Find the first key window that is not our own passthrough window
var window = UIApplication.shared.windows.first { $0.isKeyWindow && $0 != self.window }
// If we didn't find one, get the first non-key window since our window may be key (happens in iOS 14.2)
if window == 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 webView
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let url = navigationAction.request.url else {
decisionHandler(.cancel)
return
}
- 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"