exsilium/ruby-xbee

View on GitHub

Showing 33 of 33 total issues

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

    def Frame.new(source_io, api_mode = :API1)
      stray_bytes = []
      unless api_mode == :API1 or api_mode == :API2
        raise "XBee api_mode must be either :API1 (non-escaped) or :API2 (escaped, default)"
      end
Severity: Minor
Found in lib/apimode/frame/frame.rb - About 1 day 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

File command_mode.rb has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module XBee
  class BaseCommandModeInterface < RFModule

    VERSION = "1.0" # Version of this class

Severity: Minor
Found in lib/legacy/command_mode.rb - About 7 hrs to fix

    Class BaseAPIModeInterface has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class BaseAPIModeInterface < RFModule
    
        VERSION = "1.2.0" # Version of this class
    
        ##
    Severity: Minor
    Found in lib/apimode/xbee_api.rb - About 5 hrs to fix

      Class BaseCommandModeInterface has 37 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class BaseCommandModeInterface < RFModule
      
          VERSION = "1.0" # Version of this class
      
          ##
      Severity: Minor
      Found in lib/legacy/command_mode.rb - About 4 hrs to fix

        File xbee_api.rb has 356 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        $: << File.dirname(__FILE__)
        require 'frame/frame'
        require File.dirname(File.dirname(__FILE__)) + '/ruby_xbee'
        
        module XBee
        Severity: Minor
        Found in lib/apimode/xbee_api.rb - About 4 hrs to fix

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

              def Frame.new(source_io, api_mode = :API1)
                stray_bytes = []
                unless api_mode == :API1 or api_mode == :API2
                  raise "XBee api_mode must be either :API1 (non-escaped) or :API2 (escaped, default)"
                end
          Severity: Major
          Found in lib/apimode/frame/frame.rb - About 3 hrs to fix

            Method io_input has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                def io_input
            
                  tmp = @xbee_serialport.read_timeout
                  @xbee_serialport.read_timeout = read_timeout(:long)
            
            
            Severity: Minor
            Found in lib/legacy/command_mode.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 get_param has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_param(at_param_name, at_param_unpack_string = nil)
                  frame_id = self.next_frame_id
                  at_command_frame = XBee::Frame::ATCommand.new(at_param_name,frame_id,nil,at_param_unpack_string)
                  puts "Sending ... [#{at_command_frame._dump(self.api_mode.in_symbol).unpack("C*").join(", ")}]" if $VERBOSE
                  self.xbee_serialport.write(at_command_frame._dump(self.api_mode.in_symbol))
            Severity: Minor
            Found in lib/apimode/xbee_api.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 execute_configuration has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def execute_configuration
              # start the configuration
            
              @xbee = XBee.new( @xbee_usbdev_str, @xbee_baud, @data_bits, @stop_bits, @parity )
            
            
            Severity: Minor
            Found in bin/xbeeconfigure.rb - About 1 hr to fix

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

                  def neighbors
                    # neighbors often takes more than 1000ms to return data
                    tmp = @xbee_serialport.read_timeout
                    @xbee_serialport.read_timeout = read_timeout(:long)
                    @xbee_serialport.write("ATND\r")
              Severity: Minor
              Found in lib/legacy/command_mode.rb - About 1 hr to fix

                Method initialize has 11 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def initialize(frame_id = nil, destination_address = 0x000000000000ffff, destination_network = 0x0000fffe, source_endpoint = nil, destination_endpoint = nil, cluster_id = nil, profile_id = nil, broadcast_radius = 0x00, transmit_options = 0x00, payload = nil, payload_pack_string = "a*")
                Severity: Major
                Found in lib/apimode/frame/explicit_addressing_command.rb - About 1 hr to fix

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

                      def io_input
                  
                        tmp = @xbee_serialport.read_timeout
                        @xbee_serialport.read_timeout = read_timeout(:long)
                  
                  
                  Severity: Minor
                  Found in lib/apimode/xbee_api.rb - About 1 hr to fix

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

                        def neighbors
                          frame_id = self.next_frame_id
                          # neighbors often takes more than 1000ms to return data
                          node_discover_cmd = XBee::Frame::ATCommand.new("ND",frame_id,nil)
                          #puts "Node discover command dump: #{node_discover_cmd._dump(self.api_mode.in_symbol).unpack("C*").join(", ")}"
                    Severity: Minor
                    Found in lib/apimode/xbee_api.rb - About 1 hr to fix

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

                      def process_cli_options
                      
                        @options.each do | opt, arg |
                      
                            case opt
                      Severity: Minor
                      Found in bin/xbeeconfigure.rb - About 1 hr to fix

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

                            def io_input
                        
                              tmp = @xbee_serialport.read_timeout
                              @xbee_serialport.read_timeout = read_timeout(:long)
                        
                        
                        Severity: Minor
                        Found in lib/apimode/xbee_api.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 io_input has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def io_input
                        
                              tmp = @xbee_serialport.read_timeout
                              @xbee_serialport.read_timeout = read_timeout(:long)
                        
                        
                        Severity: Minor
                        Found in lib/legacy/command_mode.rb - About 1 hr to fix

                          Method neighbors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def neighbors
                                frame_id = self.next_frame_id
                                # neighbors often takes more than 1000ms to return data
                                node_discover_cmd = XBee::Frame::ATCommand.new("ND",frame_id,nil)
                                #puts "Node discover command dump: #{node_discover_cmd._dump(self.api_mode.in_symbol).unpack("C*").join(", ")}"
                          Severity: Minor
                          Found in lib/apimode/xbee_api.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

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

                                if self.transmission_mode == :SYNC
                                r = XBee::Frame.new(self.xbee_serialport, self.api_mode.in_symbol)
                                  if r.kind_of?(XBee::Frame::ATCommandResponse) && r.status == :OK && r.frame_id == frame_id
                                    if block_given?
                                      yield r
                          Severity: Major
                          Found in lib/apimode/xbee_api.rb and 2 other locations - About 1 hr to fix
                          lib/apimode/xbee_api.rb on lines 118..128
                          lib/apimode/xbee_api.rb on lines 137..147

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

                          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 set_remote_param has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def set_remote_param(at_param_name, param_value, remote_address = 0x000000000000ffff, remote_network_address = 0xfffe, at_param_unpack_string = nil)
                                frame_id = self.next_frame_id
                                at_command_frame = XBee::Frame::RemoteCommandRequest.new(at_param_name, remote_address, remote_network_address, frame_id, param_value, at_param_unpack_string)
                                puts "Sending ... [#{at_command_frame._dump(self.api_mode.in_symbol).unpack("C*").join(", ")}]"
                                self.xbee_serialport.write(at_command_frame._dump(self.api_mode.in_symbol))
                          Severity: Minor
                          Found in lib/apimode/xbee_api.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 neighbors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def neighbors
                                # neighbors often takes more than 1000ms to return data
                                tmp = @xbee_serialport.read_timeout
                                @xbee_serialport.read_timeout = read_timeout(:long)
                                @xbee_serialport.write("ATND\r")
                          Severity: Minor
                          Found in lib/legacy/command_mode.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