rubymotion/BubbleWrap

View on GitHub

Showing 50 of 50 total issues

Method buildMenu has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def buildMenu
    @mainMenu = NSMenu.new

    appName = NSBundle.mainBundle.infoDictionary['CFBundleName']
    addMenu(appName) do
Severity: Major
Found in samples/osx/app/menu.rb - About 3 hrs to fix

    Method handle_result has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          private def handle_result(result_data, error, handler)
            if result_data
              result = {
                data: result_data,
                attitude: result_data.attitude,
    Severity: Major
    Found in motion/motion/device_motion.rb - About 2 hrs to fix

      Method set_deferred_status has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_deferred_status(status, *args)
              cancel_timeout
              @errbacks ||= nil
              @callbacks ||= nil
              @deferred_status = status
      Severity: Minor
      Found in motion/reactor/deferrable.rb - 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

      Method play has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

            def play(content_url, options = {}, &block)
              options = {
                delay_play: false
              }.merge(options)
      
      
      Severity: Minor
      Found in motion/media/player.rb - 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

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

          addMenu(appName) do
            addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
            addItem(NSMenuItem.separatorItem)
            addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
            addItem(NSMenuItem.separatorItem)
      Severity: Major
      Found in motion/test_suite_delegate.rb and 1 other location - About 2 hrs to fix
      samples/osx/app/menu.rb on lines 6..19

      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 84.

      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

          addMenu(appName) do
            addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
            addItem(NSMenuItem.separatorItem)
            addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
            addItem(NSMenuItem.separatorItem)
      Severity: Major
      Found in samples/osx/app/menu.rb and 1 other location - About 2 hrs to fix
      motion/test_suite_delegate.rb on lines 30..43

      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 84.

      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 3 locations. Consider refactoring.
      Open

        module Motion
          class Magnetometer < GenericMotionInterface
      
            def start(options={}, &handler)
              if options.key?(:interval)
      Severity: Major
      Found in motion/motion/magnetometer.rb and 2 other locations - About 2 hrs to fix
      motion/motion/accelerometer.rb on lines 2..49
      motion/motion/gyroscope.rb on lines 2..49

      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 81.

      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 3 locations. Consider refactoring.
      Open

        module Motion
          class Accelerometer < GenericMotionInterface
      
            def start(options={}, &handler)
              if options.key?(:interval)
      Severity: Major
      Found in motion/motion/accelerometer.rb and 2 other locations - About 2 hrs to fix
      motion/motion/gyroscope.rb on lines 2..49
      motion/motion/magnetometer.rb on lines 2..49

      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 81.

      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 3 locations. Consider refactoring.
      Open

        module Motion
          class Gyroscope < GenericMotionInterface
      
            def start(options={}, &handler)
              if options.key?(:interval)
      Severity: Major
      Found in motion/motion/gyroscope.rb and 2 other locations - About 2 hrs to fix
      motion/motion/accelerometer.rb on lines 2..49
      motion/motion/magnetometer.rb on lines 2..49

      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 81.

      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

      Method picture has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def picture(options = {}, presenting_controller = nil, &block)
              @callback = block
              @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
      
              @options = {
      Severity: Minor
      Found in motion/core/device/ios/camera.rb - About 2 hrs to fix

        Method handle_result has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              private def handle_result(result_data, error, handler)
                if result_data
                  result = {
                    data: result_data,
                    attitude: result_data.attitude,
        Severity: Minor
        Found in motion/motion/device_motion.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

        Method picture has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

              def picture(options = {}, presenting_controller = nil, &block)
                @callback = block
                @callback.weak! if @callback && BubbleWrap.use_weak_callbacks?
        
                @options = {
        Severity: Minor
        Found in motion/core/device/ios/camera.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

        Method get has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(base, *values)
              if values.is_a? NSArray
                value = values.size == 1 ? values.first : values.flatten
              else
                value = values
        Severity: Minor
        Found in motion/util/constants.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

        Method setup_gesture has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def setup_gesture
            @panned_recognizer = self.whenPanned do |recognizer|
              case(recognizer.state)
              when UIGestureRecognizerStateBegan
                @last_position = self.position
        Severity: Minor
        Found in samples/gesture/app/views/drawing/gesture_view.rb - About 1 hr to fix

          Method play has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def play(content_url, options = {}, &block)
                  options = {
                    delay_play: false
                  }.merge(options)
          
          
          Severity: Minor
          Found in motion/media/player.rb - About 1 hr to fix

            Method future has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def future arg, cb=nil, eb=nil, &blk
                    arg = arg.call if arg.respond_to?(:call)
            
                    if arg.respond_to?(:set_deferred_status)
                      if cb || eb
            Severity: Minor
            Found in motion/reactor/future.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

            Method new has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def new(params = {}, *args)
                  if params.is_a?(UIFont)
                    return params
                  end
                  _font = nil
            Severity: Minor
            Found in motion/font/font.rb - About 1 hr to fix

              Method styled has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def styled(type, *objects, &block)
                      if block.nil?
                        action = nil
                      else
                        block.weak! if BubbleWrap.use_weak_callbacks?
              Severity: Minor
              Found in motion/ui/ui_bar_button_item.rb - About 1 hr to fix

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

                    def new(params = {}, *args)
                      if params.is_a?(UIFont)
                        return params
                      end
                      _font = nil
                Severity: Minor
                Found in motion/font/font.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

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

                      def styled(type, *objects, &block)
                        if block.nil?
                          action = nil
                        else
                          block.weak! if BubbleWrap.use_weak_callbacks?
                Severity: Minor
                Found in motion/ui/ui_bar_button_item.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

                Severity
                Category
                Status
                Source
                Language