JohnCoates/Slate

View on GitHub

Showing 69 of 304 total issues

Function receive has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def receive(self):
        pairs = []
        timeout = 1
        while self.running:
            sockets = list(map(lambda x: x[0], pairs))
Severity: Minor
Found in Research/Motion/Blender/server.py - About 2 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 draw has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func draw(path codePath: Path) {
        var instructions = codePath.instructions
        let first = instructions.removeFirst()
        
        let path: UIBezierPath

    Function readInstructions has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func readInstructions() -> [Path.Instruction] {
            let count = readUInt16()
            
            var instructions: [Path.Instruction] = Array()
            for _ in 0..<count {
    Severity: Major
    Found in Source/UI/Assets/Vector Images/Models/Reader/VectorAssetReader.swift - About 2 hrs to fix

      Function cgPath has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func cgPath() -> CGPath {
              var instructions = self.instructions
              let first = instructions.removeFirst()
              
              let path: UIBezierPath
      Severity: Minor
      Found in Source/UI/Assets/Vector Images/Views/InverseMaskImageButton.swift - About 1 hr to fix

        Function constraintsInvolvingView has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            func constraintsInvolvingView(_ view: UIView,
                                          attribute: LayoutAttribute) -> [NSLayoutConstraint]? {
                
                let allConstraints = self.constraints
                var constraints = [NSLayoutConstraint]()
        Severity: Minor
        Found in Source/UI/Auto Layout/Constraints/Views+AutoLayout.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 performOperation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private func performOperation(kind: Compression.Kind, algorithm: Compression.Algorithm) throws -> Data {
                let scratchSize = compression_encode_scratch_buffer_size(algorithm.rawValue)
                var destination = Data(count: count * 4)
                let scratchBuffer: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>.allocate(capacity: scratchSize)
                
        Severity: Minor
        Found in Source/Extensions/Standard Library/Data+Compression.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 dataFloats has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func dataFloats() -> [DataFloat] {
                var floats = [Float]()
                let instructions: [Path.Instruction] = sourceInstructions
                for instruction in instructions {
                    switch instruction {

          Function constraintsBetween has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              func constraintsBetween(view: UIView, view2: UIView,
                                      viewAttribute: LayoutAttribute) -> [NSLayoutConstraint]? {
                  
                  let allConstraints = self.constraints
                  var constraints = [NSLayoutConstraint]()
          Severity: Minor
          Found in Source/UI/Auto Layout/Constraints/Views+AutoLayout.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 dataInstruction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func dataInstruction(fromInstruction instruction: Path.Instruction) -> DataInstruction {
                  switch instruction {
                  case .move(let point):
                      return DataInstruction.move(to: dataPoint(fromPoint: point))
                  case .addLine(let point):

            Function longPressed has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @objc func longPressed(gesture: UILongPressGestureRecognizer) {
                    guard let control = control else { return }
                    if gesture.state == .began || gesture.state == .ended || gesture.state == .cancelled {
                        lastLocation = nil
                    }

              Function performOperation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private func performOperation(kind: Compression.Kind, algorithm: Compression.Algorithm) throws -> Data {
                      let scratchSize = compression_encode_scratch_buffer_size(algorithm.rawValue)
                      var destination = Data(count: count * 4)
                      let scratchBuffer: UnsafeMutablePointer<UInt8> = UnsafeMutablePointer<UInt8>.allocate(capacity: scratchSize)
                      
              Severity: Minor
              Found in Source/Extensions/Standard Library/Data+Compression.swift - About 1 hr to fix

                Function add has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func add(instructions: [DataInstruction]) {
                        let max = UInt16.max
                        guard instructions.count < Int(max) else {
                            fatalError("There are \(instructions.count) instructions, but we can only store \(max)")
                        }

                  Function testDoubleConstrainedResolution has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      func testDoubleConstrainedResolution() {
                          let targetResolution = IntSize(width: 1920, height: 1080)
                          let frameRateBestResolution = IntSize(width: 1280, height: 720)
                          let burstSpeedBestResolution = IntSize(width: 640, height: 480)
                          

                    Function resetToInitialState has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        func resetToInitialState(component: Component) {
                            if let target = component as? EditPosition {
                                guard let value = initialValues[.position] as? CGPoint else {
                                    fatalError("Didn't record initial position for component: \(component)")
                                }

                    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 constraints has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private func constraints<Follower: PhotoSettingsConstrainable>(for follower: Follower,
                                                                                       camera: Camera) -> [Follower.Constraint]? {
                            typealias FollowerValue = Follower.ValueType
                            typealias Constraint = Follower.Constraint
                            let optimalValue = follower.optimalValue(for: camera)

                      Function render has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func render(toView view: MTKView) {
                              guard let currentDrawable = view.currentDrawable, dirtyTexture else {
                                  return
                              }
                              
                      Severity: Minor
                      Found in Source/UI/Capture/Metal/Renderer/Extensions/Renderer+View.swift - About 1 hr to fix

                        Function switchToNextCamera has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            func switchToNextCamera() {
                                var devices = AVCaptureDevice.devices(for: AVMediaType.video)
                                if devices.count < 2 {
                                    print("Can't switch to next camera, only \(devices.count) cameras available")
                                    return
                        Severity: Minor
                        Found in Source/Camera/Controllers/Extensions/CameraController+Device.swift - About 1 hr to fix

                          Method readResults has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def readResults(filename: nil, iteration: nil)
                            totalTime = 0.to_f
                            File.open(filename).each do |line|
                              match = /([0-9\.]+)ms.*?([^\/]+\.swift[0-9\:]+)[^\(]+func ([^\(]+)\(+/.match(line)
                              if !match
                          Severity: Minor
                          Found in Scripts/benchmarkSwitCompilation.rb - 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 constraintInvolvingView has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              func constraintInvolvingView(_ view: UIView,
                                                           attribute: LayoutAttribute,
                                                           relation: LayoutRelation) -> NSLayoutConstraint? {
                                  let allConstraints = self.constraints
                                  
                          Severity: Minor
                          Found in Source/UI/Auto Layout/Constraints/Views+AutoLayout.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 hydrate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              func hydrate(mappingModel: NSMappingModel) {
                                  guard let mappings = mappingModel.entityMappings else {
                                      fatalError("Missing entity mappings")
                                  }
                                  
                          Severity: Minor
                          Found in Source/Database/Data Model/Migrating/SingleMigration.swift - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language