Showing 15 of 33 total issues

Function targetContentOffset has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

        override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint,
                                          withScrollingVelocity velocity: CGPoint) -> CGPoint {
            guard style.shouldCenterOnCells == true else {
                return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity)
            }
Severity: Minor
Found in Sources/ComposeUI/Collection View/ComposeCollectionView+Layout.swift - About 6 hrs 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 bind has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    @discardableResult
    public func bind() -> Self {
        /* Storing lifecycle for the component in the component descriptor */
        
        let node = ObservationTree.shared.currentNode?.addChild(id: self.id)
Severity: Minor
Found in Sources/Compose/Component/Component+Bind.swift - About 4 hrs 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 bind has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @discardableResult
    public func bind() -> Self {
        /* Storing lifecycle for the component in the component descriptor */
        
        let node = ObservationTree.shared.currentNode?.addChild(id: self.id)
Severity: Major
Found in Sources/Compose/Component/Component+Bind.swift - About 3 hrs to fix

    Function targetContentOffset has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint,
                                              withScrollingVelocity velocity: CGPoint) -> CGPoint {
                guard style.shouldCenterOnCells == true else {
                    return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity)
                }
    Severity: Major
    Found in Sources/ComposeUI/Collection View/ComposeCollectionView+Layout.swift - About 2 hrs to fix

      Function describe has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          fileprivate mutating func describe(value : Any, parentValue : Any? = nil) -> Content {
              let mirror = Mirror(reflecting: value)
      
              if value is AnyOptionalValue, let optionalValue = mirror.descendant("some") {
                  return describe(value: optionalValue)
      Severity: Minor
      Found in Sources/Compose/Introspection/Descriptors/StoreDescriptor.swift - About 1 hr 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 send has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func send<T : Encodable>(_ value : T) throws {
              guard session.connectedPeers.count > 0 else {
                  return
              }
              
      Severity: Minor
      Found in Sources/Compose/Introspection/IntrospectionClient.swift - About 1 hr to fix

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

            func send<T : Encodable>(_ value : T) throws {
                guard session.connectedPeers.count > 0 else {
                    return
                }
                
        Severity: Minor
        Found in Sources/Compose/Introspection/IntrospectionClient.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

        Avoid deeply nested control flow statements.
        Open

                                guard window.isUserInteractionEnabled == true else {
                                    continue
                                }
        Severity: Major
        Found in Sources/ComposeUI/Extensions/UIApplication+TopViewController.swift - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if window.isKeyWindow {
                                      topViewController = window.rootViewController
                                  }
          Severity: Major
          Found in Sources/ComposeUI/Extensions/UIApplication+TopViewController.swift - About 45 mins to fix

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

                func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String,
                             fromPeer peerID: MCPeerID,
                             at localURL: URL?,
                             withError error: Error?) {
            Severity: Minor
            Found in Sources/Compose/Introspection/IntrospectionClient.swift - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return super.targetContentOffset(forProposedContentOffset: proposedContentOffset)
              Severity: Major
              Found in Sources/ComposeUI/Collection View/ComposeCollectionView+Layout.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return .scalar(String(describing: value))
                Severity: Major
                Found in Sources/Compose/Introspection/Descriptors/StoreDescriptor.swift - About 30 mins to fix

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

                      public static func main() {
                          willBindRootComponent()
                          RuntimeStorage.RootComponent = self.init().bind()
                          didBindRootComponent()
                          
                  Severity: Minor
                  Found in Sources/Compose/Component/Startup/StartupComponent.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 updateChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      fileprivate func updateChanges(oldValues : [T], newValues : [T]) {
                          guard oldValues.count == newValues.count else {
                              return
                          }
                              
                  Severity: Minor
                  Found in Sources/Compose/State/Ref/RefCollection.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 dismiss has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public func dismiss(id : UUID? = nil) {
                          guard presenters.count > 0 else {
                              return
                          }
                          
                  Severity: Minor
                  Found in Sources/ComposeUI/Modal/ComposeModalManager.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