OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

    def xtce_handle_base_container(base_name, element)
      if element.name == base_name
        # Need to add BaseContainer items to current_packet
        # Lookup the base packet
        if base_name == 'BaseMetaCommand'
Severity: Minor
Found in openc3/lib/openc3/packets/parsers/xtce_parser.rb - About 1 hr to fix

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

        def read
          while true
            if @handshaked
              msg = @frame.next
              return msg.data if msg
    Severity: Minor
    Found in openc3/lib/openc3/streams/web_socket_client_stream.rb - About 1 hr to fix

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

        def remove(object)
          @mutex.synchronize do
            found_object = @objects_by_id[object.id]
            if found_object
              @objects.delete(found_object)
      Severity: Minor
      Found in openc3-cosmos-cmd-tlm-api/app/models/streaming_object_collection.rb - About 1 hr to fix

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

          def stop
            running_script = RunningScript.find(params[:id].to_i)
            if running_script
              target_name = running_script['name'].split('/')[0]
              return unless authorization('script_run', target_name: target_name)
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 65..75
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 78..88
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 91..101
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 104..114

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

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

          def pause
            running_script = RunningScript.find(params[:id].to_i)
            if running_script
              target_name = running_script['name'].split('/')[0]
              return unless authorization('script_run', target_name: target_name)
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 39..49
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 78..88
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 91..101
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 104..114

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

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

          def retry
            running_script = RunningScript.find(params[:id].to_i)
            if running_script
              target_name = running_script['name'].split('/')[0]
              return unless authorization('script_run', target_name: target_name)
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 39..49
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 65..75
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 91..101
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 104..114

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

        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

                    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 and 1 other location - About 1 hr to fix
        openc3/lib/openc3/accessors/binary_accessor.rb on lines 663..674

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

        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

                    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 and 1 other location - About 1 hr to fix
        openc3/lib/openc3/accessors/binary_accessor.rb on lines 415..427

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

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

          def go
            running_script = RunningScript.find(params[:id].to_i)
            if running_script
              target_name = running_script['name'].split('/')[0]
              return unless authorization('script_run', target_name: target_name)
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 39..49
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 65..75
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 78..88
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 104..114

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

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

          def step
            running_script = RunningScript.find(params[:id].to_i)
            if running_script
              target_name = running_script['name'].split('/')[0]
              return unless authorization('script_run', target_name: target_name)
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 39..49
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 65..75
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 78..88
        openc3-cosmos-script-runner-api/app/controllers/running_script_controller.rb on lines 91..101

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

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

            def put_target_file(path, io_or_string, scope: $openc3_scope)
              raise "Disallowed path modifier '..' found in #{path}" if path.include?('..')
        
              upload_path = "#{scope}/targets_modified/#{path}"
        
        
        Severity: Minor
        Found in openc3/lib/openc3/script/storage.rb - About 1 hr to fix

          Method run_script has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def run_script(activity)
                @logger.info "#{@timeline_name} run_script > #{activity.as_json(:allow_nan => true)}"
                begin
                  if get_exec_setting()
                    username = activity.data['username']
          Severity: Minor
          Found in openc3/lib/openc3/microservices/timeline_microservice.rb - About 1 hr to fix

            Method evaluate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def evaluate(name:, left:, operator:, right:)
                  @logger.debug "TriggerGroupWorker-#{@ident} evaluate: (#{left}(#{left.class}) #{operator} #{right}(#{right.class}))"
                  begin
                    case operator
                    when '>'
            Severity: Minor
            Found in openc3/lib/openc3/microservices/trigger_group_microservice.rb - About 1 hr to fix

              Method _cmd_string has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def _cmd_string(target_name, cmd_name, cmd_params, raw)
                    output_string = $disconnect ? 'DISCONNECT: ' : ''
                    if raw
                      output_string += 'cmd_raw("'
                    else
              Severity: Minor
              Found in openc3/lib/openc3/script/commands.rb - About 1 hr to fix

                Method check_for_dead_clients has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def check_for_dead_clients
                      indexes_to_delete = []
                      index = 0
                
                      @connection_mutex.synchronize do
                Severity: Minor
                Found in openc3/lib/openc3/interfaces/tcpip_server_interface.rb - About 1 hr to fix

                  Method close_file has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def close_file(take_mutex = true)
                        threads = []
                        @mutex.lock if take_mutex
                        begin
                          if @file
                  Severity: Minor
                  Found in openc3/lib/openc3/logs/log_writer.rb - About 1 hr to fix

                    Method get_cmd_time has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def get_cmd_time(target_name = nil, command_name = nil, manual: false, scope: $openc3_scope, token: $openc3_token)
                          authorize(permission: 'cmd_info', target_name: target_name, packet_name: command_name, manual: manual, scope: scope, token: token)
                          if target_name and command_name
                            target_name = target_name.upcase
                            command_name = command_name.upcase
                    Severity: Minor
                    Found in openc3/lib/openc3/api/cmd_api.rb - About 1 hr to fix

                      Method offline_access_needed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def offline_access_needed(manual: false, scope: $openc3_scope, token: $openc3_token)
                            authorize(permission: 'system', manual: manual, scope: scope, token: token)
                            begin
                              authorize(permission: 'script_view', manual: manual, scope: scope, token: token)
                            rescue
                      Severity: Minor
                      Found in openc3/lib/openc3/api/offline_access_api.rb - About 1 hr to fix

                        Method setup_thread_body has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def setup_thread_body(objects)
                            first_object = objects[0]
                        
                            # The goal of this mode is to determine if we are starting with files or from
                            # realtime
                        Severity: Minor
                        Found in openc3-cosmos-cmd-tlm-api/app/models/logged_streaming_thread.rb - About 1 hr to fix

                          Method sync_with_bucket has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def self.sync_with_bucket(bucket, scope:)
                                # Build catalogs
                                local_catalog = build_local_catalog(scope: scope)
                                remote_catalog = build_remote_catalog(bucket, scope: scope)
                          
                          
                          Severity: Minor
                          Found in openc3/lib/openc3/utilities/local_mode.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language