Showing 5 of 15 total issues
Function executeRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private class func executeRequest(_ request: URLRequest, completionHandler: @escaping RequestBlock) {
URLSession.shared.dataTask(with: request) { (data, response, error) in
guard let data = data else {
let error = HTTPError.parsing(response: nil)
print("Request '\(request.url?.path ?? "")', '\(request.httpMethod ?? "")' [-]")
Function executeRequest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private class func executeRequest(_ request: URLRequest, completionHandler: @escaping RequestBlock) {
URLSession.shared.dataTask(with: request) { (data, response, error) in
guard let data = data else {
let error = HTTPError.parsing(response: nil)
print("Request '\(request.url?.path ?? "")', '\(request.httpMethod ?? "")' [-]")
- 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 main
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
override func main() {
cancelOperation()
StoriesManager.getStory(storyID, completionHandler: { (response, error) in
guard let json = response as? JSON, error == nil 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 setDataForDisplay
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public class func setDataForDisplay(with title: String? = nil,
contentDescription: String? = nil,
keywords: [String]? = nil,
creationDate: Date? = nil,
url: URL? = nil,
Function downloadImageFrom
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private func downloadImageFrom(_ url: URL?) {
guard let url = url else { return }
URLSession.shared.dataTask(with: url) { data, response, error in
guard let completionBlock = self.completionBlock, let data = data 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"