Showing 33 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    import Foundation
    import Combine
    
    extension Emitters {
        
    Severity: Major
    Found in Sources/Compose/Events/Emitters/Emitters+Delay.swift and 1 other location - About 3 hrs to fix
    Sources/Compose/Events/Emitters/Emitters+Debounce.swift on lines 1..35

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 235.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    import Foundation
    import Combine
    
    extension Emitters {
        
    Severity: Major
    Found in Sources/Compose/Events/Emitters/Emitters+Debounce.swift and 1 other location - About 3 hrs to fix
    Sources/Compose/Events/Emitters/Emitters+Delay.swift on lines 1..35

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 235.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    for attributes in self.layoutAttributesForElements(in: proposedRect)! {
                        if attributes.representedElementCategory != .cell {
                            continue
                        }
                        
    Sources/ComposeUI/Collection View/ComposeCollectionView+Layout.swift on lines 45..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                    for attributes in self.layoutAttributesForElements(in: proposedRect)! {
                        if attributes.representedElementCategory != .cell {
                            continue
                        }
                        
    Sources/ComposeUI/Collection View/ComposeCollectionView+Layout.swift on lines 85..107

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              while let router = enumerator?.nextObject() as? Router {
                  router.target = nil
                  router.routes.removeAll()
                  
                  ObservationTree.shared.node(for: router.didPush.id)?.remove()
      Sources/Compose/Component/Container/InstanceComponentStorage.swift on lines 34..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              while let router = enumerator?.nextObject() as? Router {
                  router.target = nil
                  router.routes.removeAll()
                  
                  ObservationTree.shared.node(for: router.didPush.id)?.remove()
      Sources/Compose/Component/Container/DynamicComponentStorage.swift on lines 37..44

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public struct Undup<Upstream : Emitter> : Emitter where Upstream.Value : Equatable {
                
                public let id : UUID
                public let publisher: AnyPublisher<Upstream.Value, Never>
                
        Severity: Major
        Found in Sources/Compose/Events/Emitters/Emitters+Undup.swift and 1 other location - About 1 hr to fix
        Sources/Compose/Events/Emitters/Emitters+Once.swift on lines 6..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public struct Once<Upstream : Emitter> : Emitter {
                
                public let id : UUID
                public let publisher: AnyPublisher<Upstream.Value, Never>
                
        Severity: Major
        Found in Sources/Compose/Events/Emitters/Emitters+Once.swift and 1 other location - About 1 hr to fix
        Sources/Compose/Events/Emitters/Emitters+Undup.swift on lines 6..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          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

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public static func == (lhs: RefCollection<T>, rhs: RefCollection<T>) -> Bool {
                    lhs.wrappedValue == rhs.wrappedValue
                }
            Severity: Minor
            Found in Sources/Compose/State/Ref/RefCollection.swift and 1 other location - About 40 mins to fix
            Sources/Compose/State/Validation/Rule.swift on lines 16..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public static func == (lhs: Rule<T>, rhs: Rule<T>) -> Bool {
                    lhs.id == rhs.id
                }
            Severity: Minor
            Found in Sources/Compose/State/Validation/Rule.swift and 1 other location - About 40 mins to fix
            Sources/Compose/State/Ref/RefCollection.swift on lines 54..56

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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
              Severity
              Category
              Status
              Source
              Language