FabrizioBrancati/BFKit-Swift

View on GitHub

Showing 36 of 147 total issues

Function handleErrorOS11 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @available(iOS 11.0, *)
    private static func handleErrorOS11(_ error: NSError) -> Result {
        switch error {
        case LAError.authenticationFailed:
            return .authenticationFailed
Severity: Minor
Found in Sources/BFKit/Apple/BFKit/BFBiometrics.swift - About 1 hr to fix

    Function smoothGradient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        func smoothGradient(colors: [UIColor], direction: UIViewGradientDirection, type: UIViewGradientType = .linear) {
            UIGraphicsBeginImageContextWithOptions(bounds.size, false, UIImage.screenScale())
            guard let context = UIGraphicsGetCurrentContext() else {
                return
            }
    Severity: Minor
    Found in Sources/BFKit/Apple/UIKit/UIView+Extensions.swift - About 55 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

    Function flatten has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    public func flatten<T>(_ array: [T]) -> [T] {
        /// Returned flattened array.
        var flattened: [T] = []
        
        /// For every element inside the array.
    Severity: Minor
    Found in Sources/BFKit/Linux/Foundation/Array+Extensions.swift - About 45 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

    Function scaleProportionally has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        func scaleProportionally(toSize targetSize: CGSize) -> UIImage {
            let sourceImage: UIImage = self
            let newTargetSize: CGSize = targetSize
    
            let imageSize: CGSize = sourceImage.size
    Severity: Minor
    Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 45 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

    Function cmykHalftone has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            func cmykHalftone(center: CIVector, width: Float, angle: Float, sharpness: Float, gcr: Float, ucr: Float) -> UIImage { // swiftlint:disable:this function_parameter_count
    Severity: Minor
    Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 45 mins to fix

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

          func shadow(offset: CGSize, opacity: Float, radius: CGFloat, cornerRadius: CGFloat = 0, color: UIColor = UIColor.black) {
      Severity: Minor
      Found in Sources/BFKit/Apple/UIKit/UIView+Extensions.swift - About 35 mins to fix

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

            func translateAround(topView: UIView, duration: CGFloat, direction: UIViewAnimationTranslationDirection, repeatAnimation: Bool = true, startFromEdge: Bool = true) {
        Severity: Minor
        Found in Sources/BFKit/Apple/UIKit/UIView+Extensions.swift - About 35 mins to fix

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

              func scaleProportionally(toMinimumSize targetSize: CGSize) -> UIImage {
                  let sourceImage: UIImage = self
                  let newTargetSize: CGSize = targetSize
                  
                  let imageSize: CGSize = sourceImage.size
          Severity: Minor
          Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.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 self
          Severity: Major
          Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return self
            Severity: Major
            Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return outputImage
              Severity: Major
              Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return self
                Severity: Major
                Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 30 mins to fix

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

                      mutating func swap(from fromIndex: Int, to toIndex: Int) {
                          if toIndex != fromIndex {
                              guard let object: Element = safeObject(at: fromIndex) else {
                                  return
                              }
                  Severity: Minor
                  Found in Sources/BFKit/Linux/Foundation/Array+Extensions.swift - About 25 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

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

                      func scaleProportionally(toMaximumSize targetSize: CGSize) -> UIImage {
                          let newTargetSize: CGSize = targetSize
                          
                          if size.width > newTargetSize.width || newTargetSize.width == newTargetSize.height, size.width > size.height {
                              let factor: CGFloat = (newTargetSize.width * 100) / size.width
                  Severity: Minor
                  Found in Sources/BFKit/Apple/UIKit/UIImage+Extensions.swift - About 25 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

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

                      public static func useBiometric(localizedReason: String, fallbackTitle: String? = nil, completion: @escaping (_ result: Result) -> Void) {
                          let context = LAContext()
                          
                          context.localizedFallbackTitle = fallbackTitle
                          
                  Severity: Minor
                  Found in Sources/BFKit/Apple/BFKit/BFBiometrics.swift - About 25 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

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

                      static func saveAPNSIdentifier(_ uniqueIdentifier: Any, completion: @escaping (_ isValid: Bool, _ needsUpdate: Bool, _ oldUUID: String?, _ newUUID: String) -> Void) {
                          var newUUID: String = ""
                          var oldUUID: String?
                          var isValid = false, needsUpdate = false
                          
                  Severity: Minor
                  Found in Sources/BFKit/Apple/UIKit/UIDevice+Extensions.swift - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language