Function consolidateLoadedRanges
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func consolidateLoadedRanges() {
var consolidatedRanges: [NSRange] = []
let sortedRanges = loadedRanges.sorted { $0.location < $1.location }
- 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 isAvailableOffline
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static func isAvailableOffline(video: AerialVideo) -> Bool {
let fileManager = FileManager.default
if video.url.absoluteString.starts(with: "file") {
return fileManager.fileExists(atPath: video.url.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 canFulfillLoadingRequest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
func canFulfillLoadingRequest(_ loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
if !loading {
return true
}
- 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
TODO comments should be formatted either as <todo: description> or <todo description></todo></todo:> Open
// TODO : temporary for the migration
- Read upRead up
- Exclude checks
todo-syntax
TODO comments should be defined separately using non-nested single line comments. They should adhere to the <TODO: description>
or <TODO(developer-name): description>
syntax. Empty TODO comments will be flagged.
Preferred
// TODO: <insert mandatory todo comment>
// TODO(dev-name): <insert mandatory todo comment></insert></insert>
Not Preferred
// TODO:
/// TODO: Documentation comments should not have TODOs
//// TODO: Nested comments should not have TODOs
// //TODO: Nested comments should not have TODOs
// TODO: Nested comments should not have TODOs // some comment
//// TODO: Nested comments should not have TODOs
Function should have at least one blank line after it Open
}
- Read upRead up
- Exclude checks
function-whitespace
Every function and method declaration should have one blank line before and after itself. An exception to this rule are functions that are declared at the start of a file (only need one blank line after their declaration) or at the end of a file (only need one blank line before their declaration). Comments immediately before a function declaration (no blank lines between them and the function) are considered to be part of the declaration.
Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
Not Preferred
func function1() {
var text = 1
var text = 2
}
function1()
// a comment
func function2() {
// something goes here
}
struct SomeStruct {
func function3() {
// something goes here
}
func function4() {
// something else goes here
};
}
func function5() {
// something goes here
}
TODO comments should be formatted either as <todo: description> or <todo description></todo></todo:> Open
// TODO : Until refactor is done
- Read upRead up
- Exclude checks
todo-syntax
TODO comments should be defined separately using non-nested single line comments. They should adhere to the <TODO: description>
or <TODO(developer-name): description>
syntax. Empty TODO comments will be flagged.
Preferred
// TODO: <insert mandatory todo comment>
// TODO(dev-name): <insert mandatory todo comment></insert></insert>
Not Preferred
// TODO:
/// TODO: Documentation comments should not have TODOs
//// TODO: Nested comments should not have TODOs
// //TODO: Nested comments should not have TODOs
// TODO: Nested comments should not have TODOs // some comment
//// TODO: Nested comments should not have TODOs