Showing 70 of 260 total issues
Function upload
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func upload() {
guard let uploadables = uploadables else { return }
config.currentUploaders.append(self)
state = .inProgress
- 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 upload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@discardableResult
func upload(data: Data,
to url: URL,
method: String,
headers: [String: String]? = nil,
Function handleResponse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
func handleResponse(response: JSONResponse) {
// Ensure that there's a response and JSON payload or fail.
guard let json = response.json else {
finish(with: .failure(.custom("Unable to obtain JSON from /multipart/start response.")))
return
Function testMinifyJSTransformationWithOptionalsURL
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testMinifyJSTransformationWithOptionalsURL() {
transformable.add(transform: MinifyJSTransform()
.booleans(true)
.builtIns(false)
.consecutiveAdds(true)
Function testGetImageTaggingResponse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testGetImageTaggingResponse() {
stub(condition: cdnStubConditions) { _ in
let headers = ["Content-Type": "application/json"]
let json = [
Function testObserversOnCancelledOperation
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testObserversOnCancelledOperation() throws {
let queue = serialOperationQueue()
let semaphore = DispatchSemaphore(value: 0)
let operation = WorkOperation<Bool>() { work in
Function testGetExistingContent
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testGetExistingContent() {
stub(condition: cdnStubConditions) { _ in
let stubPath = Helpers.url(forResource: "sample", withExtension: "jpg", subdirectory: "Fixtures")!.path
let httpHeaders: [AnyHashable: Any] = [
Function store
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
public func store(fileName: String? = nil,
location: StorageLocation,
path: String? = nil,
container: String? = nil,
region: String? = nil,
Function upload
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
@discardableResult
func upload(data: Data,
to url: URL,
method: String,
headers: [String: String]? = 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 download
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
@objc func download(destinationURL: URL,
parameters: [String: Any]? = nil,
queue: DispatchQueue? = .main,
downloadProgress: ((Progress) -> Void)? = nil,
completionHandler: @escaping (DownloadResponse) -> Void) {
- 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 testMultiFileUploadWithOneFile
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testMultiFileUploadWithOneFile() {
var hitCount = 0
stubRegularMultipartRequest(hitCount: &hitCount)
let expectation = self.expectation(description: "request should succeed")
Function stubMultipartCompleteRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
func stubMultipartCompleteRequest(requestTime: TimeInterval = 0,
responseTime: TimeInterval = 0,
workflows: [String]? = nil,
uploadTags: [String: String]? = nil) {
let uploadMultipartCompleteStubConditions = isScheme(Constants.uploadURL.scheme!) &&
Function testUploadFileAtTemporaryLocation
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testUploadFileAtTemporaryLocation() {
var hitCount = 0
stubRegularMultipartRequest(hitCount: &hitCount)
Function uploadDataChunk
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func uploadDataChunk(using response: JSONResponse) {
guard !isCancelled else { return }
if let apiErrorDescription = error(from: response) {
finish(with: .failure(.api(apiErrorDescription)))
Function testAudioConvertTransformationURL
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testAudioConvertTransformationURL() {
transformable
.add(transform: AVTransform()
.preset("m4a")
.force(false)
Function testGetContentWithParametersAndSecurity
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testGetContentWithParametersAndSecurity() {
stub(condition: cdnStubConditions) { _ in
HTTPStubsResponse(data: Data(), statusCode: 200, headers: nil)
}
Function enqueue
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func enqueue(operations: [SubmitPartUploadOperation]) {
var partsAndEtags: [Int: String] = [:]
var completeCount = 0
Function uploadDataChunk
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func uploadDataChunk(using response: JSONResponse) {
guard !isCancelled else { return }
if let apiErrorDescription = error(from: response) {
finish(with: .failure(.api(apiErrorDescription)))
Function testRegularMultiPartUpload
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
func testRegularMultiPartUpload() {
var hitCount = 0
stubRegularMultipartRequest(hitCount: &hitCount)
Function multiFileUpload
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public func multiFileUpload(from localURLs: [URL],
storeOptions: StorageOptions = StorageOptions(location: .s3, access: .private),
useIntelligentIngestionIfAvailable: Bool = true,
queue: DispatchQueue = .main,
startUploadImmediately: Bool = true,