rwbutler/Updates

View on GitHub

Showing 26 of 41 total issues

Function presentAppStore has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static func presentAppStore(animated: Bool = true,
                                       appStoreId: String?,
                                       appStoreURL: URL?,
                                       delegate: SKStoreProductViewControllerDelegate,
                                       presentingViewController: UIViewController) {
Severity: Minor
Found in Updates/Classes/UI/UpdatesUI.swift - About 35 mins to fix

    Function fetchSettings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        private func fetchSettings(configurationURL: URL, defaults: ConfigurationResult) -> ConfigurationServiceResult {
            guard let configurationData = try? Data(contentsOf: configurationURL) else {
                return .failure(.networking)
            }
            let parsingResult = parsingService.parse(configurationData)

    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 checkForUpdates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        func checkForUpdates(completion: @escaping (UpdatesResult) -> Void) {
            DispatchQueue.global(qos: .background).async {
                self.appMetadataService.fetchAppMetadata { result in
                    switch result {
                    case .success(let apiResult):
    Severity: Minor
    Found in Updates/Classes/Services/Updates/AutomaticUpdateResolutionService.swift - About 35 mins to fix

    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 .success(result)

      Avoid too many return statements within this function.
      Open

              return willNotify ? .available(update) : .none(isAppUpdated)
      Severity: Major
      Found in Updates/Classes/Services/App Metadata/Model/UpdatesResultFactory.swift - About 30 mins to fix

        Function parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func parse(_ data: Data) -> Result<ITunesSearchAPIResult, ParsingError> {
                guard !data.isEmpty else {
                    return .failure(.emptyPayload)
                }
                let decoder = JSONDecoder()

        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

        Severity
        Category
        Status
        Source
        Language