OpenC3/cosmos

View on GitHub

Showing 842 of 1,379 total issues

Avoid deeply nested control flow statements.
Open

              if endianness == :BIG_ENDIAN
                value = buffer[lower_bound..upper_bound].unpack(PACK_BIG_ENDIAN_32_BIT_UINT_ARRAY)
              else # endianness == :LITTLE_ENDIAN
                value = buffer[lower_bound..upper_bound].unpack(PACK_LITTLE_ENDIAN_32_BIT_UINT_ARRAY)
              end
Severity: Major
Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                  if endianness == HOST_ENDIANNESS
                    packed = values.pack(PACK_NATIVE_32_BIT_INT_ARRAY)
                  else # endianness != HOST_ENDIANNESS
                    packed = values.pack(PACK_NATIVE_32_BIT_INT_ARRAY)
                    self.byte_swap_buffer!(packed, 4)
    Severity: Major
    Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if endianness == HOST_ENDIANNESS
                      value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_64_BIT_INT_ARRAY)
                    else # endianness != HOST_ENDIANNESS
                      temp = self.byte_swap_buffer(buffer[lower_bound..upper_bound], 8)
                      value = temp.to_s.unpack(PACK_NATIVE_64_BIT_INT_ARRAY)
      Severity: Major
      Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if parent == previous_parent
                          # Same Parent - Respawn parent
                          @changed_microservices[parent] = @microservices[parent] if @microservices[parent] and @previous_microservices[parent]
                        elsif parent and previous_parent
                          # Parent changed - Respawn both parents
        Severity: Major
        Found in openc3/lib/openc3/operators/microservice_operator.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  packet_name_length -= OPENC3_ID_FIXED_SIZE if id
          Severity: Major
          Found in openc3/lib/openc3/logs/packet_log_reader.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                  elsif flags & OPENC3_ENTRY_TYPE_MASK == OPENC3_KEY_MAP_ENTRY_TYPE_MASK
                    packet_index = entry[2..3].unpack('n')[0]
                    key_map_length = length - OPENC3_PRIMARY_FIXED_SIZE - OPENC3_KEY_MAP_SECONDARY_FIXED_SIZE
                    if cbor
                      key_map = CBOR.decode(entry[4..(key_map_length + 3)])
            Severity: Major
            Found in openc3/lib/openc3/logs/packet_log_reader.rb - About 45 mins to fix

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

                    log_name,
                    log_type,
                    cycle_time = 600, # 10 minutes, matches time in target_model
                    cycle_size = 50_000_000, # 50MB, matches size in target_model
                    cycle_hour = nil,
              Severity: Minor
              Found in openc3/lib/openc3/logs/stream_log.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if byte_aligned(bit_offset)
                            case bit_size
                            when 32
                              if endianness == :BIG_ENDIAN
                                return buffer[lower_bound..upper_bound].unpack(PACK_BIG_ENDIAN_32_BIT_FLOAT)[0]
                Severity: Major
                Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if data_type == :INT
                                # Convert to negative if necessary
                                if (bit_size > 1) && (temp[bit_size - 1] == 1)
                                  temp = -((1 << bit_size) - temp)
                                end
                  Severity: Major
                  Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if (lower_bound + end_bytes) > buffer.length
                                    raise_buffer_error(:write, buffer, data_type, given_bit_offset, given_bit_size)
                                  end
                    Severity: Major
                    Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              unless target_name
                                # There was a bug in the PacketLogWriter before version 5.6.0 that stored an invalid target_index
                                # Attempt to work around by reading the target_name from the filename
                                filename_split = @filename.to_s.split('__')
                                target_name = filename_split[3]
                      Severity: Major
                      Found in openc3/lib/openc3/logs/packet_log_reader.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  unless @out_of_order
                                    Logger.error("Log writer out of order time detected (increase buffer depth?): #{Time.from_nsec_from_epoch(@previous_time_nsec_since_epoch)} #{Time.from_nsec_from_epoch(time_nsec_since_epoch)}")
                                    @out_of_order = true
                                  end
                        Severity: Major
                        Found in openc3/lib/openc3/logs/log_writer.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if endianness == :LITTLE_ENDIAN
                                        # Bitoffset always refers to the most significant bit of a bitfield
                                        num_bytes = (((bit_offset % 8) + bit_size - 1) / 8) + 1
                                        upper_bound = bit_offset / 8
                                        lower_bound = upper_bound - num_bytes + 1
                          Severity: Major
                          Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if byte_aligned(bit_offset)
                                        case bit_size
                                        when 32
                                          if endianness == :BIG_ENDIAN
                                            buffer[lower_bound..upper_bound] = [value].pack(PACK_BIG_ENDIAN_32_BIT_FLOAT)
                            Severity: Major
                            Found in openc3/lib/openc3/accessors/binary_accessor.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                              if plugin_instance
                                                if old_plugin_name
                                                  # And we're updating a plugin
                                                  data = File.read(plugin_instance)
                                                  json = JSON.parse(data, :allow_nan => true, :create_additions => true)
                              Severity: Major
                              Found in openc3/lib/openc3/utilities/local_mode.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                if input == 'REJECTED'
                                                  raise "Critical Cmd Rejected"
                                                end
                                Severity: Major
                                Found in openc3-cosmos-script-runner-api/app/models/running_script.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                if packet_objects.length == 0
                                                  # Nothing left in either for this topic
                                                  @topics_and_offsets.delete(object.topic)
                                                end
                                  Severity: Major
                                  Found in openc3-cosmos-cmd-tlm-api/app/models/streaming_object_collection.rb - About 45 mins to fix

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

                                          dest_address,
                                          dest_port,
                                          src_port = nil,
                                          multicast_interface_address = nil,
                                          ttl = 1,
                                    Severity: Minor
                                    Found in openc3/lib/openc3/io/udp_sockets.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                      if parsed_cmd["password"]
                                                        running_script.user_input = parsed_cmd["password"].to_s
                                                      elsif parsed_cmd["multiple"]
                                                        running_script.user_input = JSON.parse(parsed_cmd["multiple"])
                                                        run_script_log(id, "Multiple input: #{running_script.user_input}")
                                      Severity: Major
                                      Found in openc3-cosmos-script-runner-api/scripts/run_script.rb - About 45 mins to fix

                                        Consider simplifying this complex logical expression.
                                        Open

                                                            if not isinstance(error, StopScript) and (
                                                                not openc3.script.RUNNING_SCRIPT
                                                                or not openc3.script.RUNNING_SCRIPT.instance
                                                                or not openc3.script.RUNNING_SCRIPT.instance.exceptions
                                                                or error not in openc3.script.RUNNING_SCRIPT.instance.exceptions
                                        Severity: Major
                                        Found in openc3/python/openc3/script/suite.py - About 40 mins to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language