OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

Method build has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build
      klass = OpenC3.require_class(@config_params[0])
      if @config_params.length > 1
        interface_or_router = klass.new(*@config_params[1..-1])
      else
Severity: Minor
Found in openc3/lib/openc3/models/interface_model.rb - About 1 hr to fix

    Method format_seconds has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.format_seconds(seconds)
        result = ""
        mm, ss = seconds.divmod(60)
        hh, mm = mm.divmod(60)
        dd, hh = hh.divmod(24)
    Severity: Minor
    Found in openc3/lib/openc3/core_ext/time.rb - About 1 hr to fix

      Method setup_open_telemetry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.setup_open_telemetry(service_name, support_rails = false)
          if ENV['OTEL_EXPORTER_OTLP_ENDPOINT']
            split_services = ENV['OPENC3_OTEL'].to_s.split(',')
            @otel_enabled = true if split_services.include?(service_name) or split_services.include?('ALL')
      
      
      Severity: Minor
      Found in openc3/lib/openc3/utilities/open_telemetry.rb - About 1 hr to fix

        Method mark_stopped has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def mark_stopped
            @state = :stopped
            OpenC3::Store.publish([SCRIPT_API, "running-script-channel:#{@id}"].compact.join(":"), JSON.generate({ type: :line, filename: @current_filename, line_no: @current_line_number, state: @state }))
            if OpenC3::SuiteRunner.suite_results
              OpenC3::SuiteRunner.suite_results.complete
        Severity: Minor
        Found in openc3-cosmos-script-runner-api/app/models/running_script.rb - About 1 hr to fix

          Method handle_log_entry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def handle_log_entry(log_entry)
              log_entry_time = log_entry["time"].to_i
          
              # Filter based on start_time
              return nil if @start_time and log_entry_time < @start_time
          Severity: Minor
          Found in openc3-cosmos-cmd-tlm-api/app/models/messages_thread.rb - About 1 hr to fix

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

                def critical_cmd_approve(uuid, scope: $openc3_scope)
                  begin
                    endpoint = "/openc3-api/criticalcmd/approve/#{uuid}"
                    response = $api_server.request('post', endpoint, :json => true, scope: scope)
                    if response.nil? || response.status != 200
            Severity: Major
            Found in openc3/lib/openc3/script/critical_cmd.rb and 1 other location - About 1 hr to fix
            openc3/lib/openc3/script/critical_cmd.rb on lines 55..70

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

            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

                      when 16
                        if data_type == :INT
                          if endianness == HOST_ENDIANNESS
                            value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_16_BIT_INT_ARRAY)
                          else # endianness != HOST_ENDIANNESS
            Severity: Major
            Found in openc3/lib/openc3/accessors/binary_accessor.rb and 1 other location - About 1 hr to fix
            openc3/lib/openc3/accessors/binary_accessor.rb on lines 975..987

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

            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

                      when 32
                        if data_type == :INT
                          if endianness == HOST_ENDIANNESS
                            value = buffer[lower_bound..upper_bound].unpack(PACK_NATIVE_32_BIT_INT_ARRAY)
                          else # endianness != HOST_ENDIANNESS
            Severity: Major
            Found in openc3/lib/openc3/accessors/binary_accessor.rb and 1 other location - About 1 hr to fix
            openc3/lib/openc3/accessors/binary_accessor.rb on lines 959..971

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

            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

                def critical_cmd_reject(uuid, scope: $openc3_scope)
                  begin
                    endpoint = "/openc3-api/criticalcmd/reject/#{uuid}"
                    response = $api_server.request('post', endpoint, :json => true, scope: scope)
                    if response.nil? || response.status != 200
            Severity: Major
            Found in openc3/lib/openc3/script/critical_cmd.rb and 1 other location - About 1 hr to fix
            openc3/lib/openc3/script/critical_cmd.rb on lines 37..52

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

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

            function decorate(acediff) {
              clearGutter(acediff)
              clearArrows(acediff)
            
              acediff.diffs.forEach((info, diffIndex) => {

              Function __init__ has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def __init__(self, name, is_plugin=False):
                      self.shutdown_complete = False
                      if name is None:
                          raise RuntimeError("Microservice must be named")
              
              
              Severity: Minor
              Found in openc3/python/openc3/microservices/microservice.py - About 1 hr to fix

                Function redis_metrics has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def redis_metrics(cls):
                        result = {}
                
                        metrics = Store.info("all")
                        result["redis_connected_clients_total"] = metrics["connected_clients"]
                Severity: Minor
                Found in openc3/python/openc3/models/metric_model.py - About 1 hr to fix

                  Method _wait_packet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def _wait_packet(check,
                                       target_name,
                                       packet_name,
                                       num_packets,
                                       timeout,
                  Severity: Minor
                  Found in openc3/lib/openc3/script/api_shared.rb - About 1 hr to fix

                    Method plugin_install_phase2 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def plugin_install_phase2(plugin_hash, update: false, scope: $openc3_scope)
                          response_body = nil
                          begin
                            plugin_name = plugin_hash['name']
                            if update
                    Severity: Minor
                    Found in openc3/lib/openc3/script/plugins.rb - About 1 hr to fix

                      Method update_converted_hour_day_stats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def update_converted_hour_day_stats(packet, reduced, state)
                            # Update statistics for this packet's converted values
                            state.converted_max_values.each do |key, value|
                              if value
                                max_key = "#{key}__CX"
                      Severity: Minor
                      Found in openc3/lib/openc3/microservices/reducer_microservice.rb - About 1 hr to fix

                        Method initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def initialize(filename, archive: nil)
                              if archive
                                time = Time.now.sys
                                timestamp = sprintf("%04u_%02u_%02u_%02u_%02u_%02u", time.year, time.month, time.mday, time.hour, time.min, time.sec)
                                # If archive is true we use the system LOGS path
                        Severity: Minor
                        Found in openc3/lib/openc3/win32/excel.rb - About 1 hr to fix

                          Method plugin_install_phase1 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def plugin_install_phase1(file_path, update: false, existing_plugin_name: nil, scope: $openc3_scope)
                                response_body = nil
                                begin
                                  if update
                                    endpoint = "/openc3-api/plugins/#{existing_plugin_name}?scope=#{scope}"
                          Severity: Minor
                          Found in openc3/lib/openc3/script/plugins.rb - About 1 hr to fix

                            Method decom_packet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def decom_packet(_topic, msg_id, msg_hash, _redis)
                                  OpenC3.in_span("decom_packet") do
                                    msgid_seconds_from_epoch = msg_id.split('-')[0].to_i / 1000.0
                                    delta = Time.now.to_f - msgid_seconds_from_epoch
                                    @metric.set(name: 'decom_topic_delta_seconds', value: delta, type: 'gauge', unit: 'seconds', help: 'Delta time between data written to stream and decom start')
                            Severity: Minor
                            Found in openc3/lib/openc3/microservices/decom_microservice.rb - About 1 hr to fix

                              Method write_packet has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def write_packet(packet)
                                    # Make sure we are past the initial data dropping period
                                    if @initial_read_delay and @initial_read_delay_needed and @connect_complete_time and Time.now < @connect_complete_time
                                      delay_needed = @connect_complete_time - Time.now
                                      sleep(delay_needed) if delay_needed > 0
                              Severity: Minor
                              Found in openc3/lib/openc3/interfaces/protocols/template_protocol.rb - About 1 hr to fix

                                Method redis_metrics has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def self.redis_metrics
                                      result = {}
                                
                                      metrics = OpenC3::Store.info("all")
                                      result['redis_connected_clients_total'] = metrics['connected_clients']
                                Severity: Minor
                                Found in openc3/lib/openc3/models/metric_model.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language