OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

  put: function (
    path,
    { data, params, headers = fullDefaultHeaders, noScope, noAuth } = {}
  ) {
    return request('put', path, { data, params, headers, noScope, noAuth })
Severity: Major
Found in openc3/templates/tool_svelte/src/services/api.js and 1 other location - About 2 hrs to fix
openc3/templates/tool_svelte/src/services/api.js on lines 79..84

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

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

diff_match_patch.prototype.patch_fromText = function (textline) {
  var patches = []
  if (!textline) {
    return patches
  }

    Method deploy_microservices has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def deploy_microservices(gem_path, variables, system)
          command_topic_list = []
          decom_command_topic_list = []
          packet_topic_list = []
          decom_topic_list = []
    Severity: Major
    Found in openc3/lib/openc3/models/target_model.rb - About 2 hrs to fix

      Method handle_packet has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def handle_packet(packet)
            if packet.stored
              # Stored telemetry does not update the current value table
              identified_packet = System.telemetry.identify_and_define_packet(packet, @interface.tlm_target_names)
            else
      Severity: Major
      Found in openc3/lib/openc3/tools/cmd_tlm_server/interface_thread.rb - About 2 hrs to fix

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

          if (!noAuth) {
            try {
              let refreshed = await OpenC3Auth.updateToken(
                OpenC3Auth.defaultMinValidity
              )
        openc3/templates/tool_svelte/src/services/api.js on lines 30..42

        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

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

          if (!noAuth) {
            try {
              let refreshed = await OpenC3Auth.updateToken(
                OpenC3Auth.defaultMinValidity
              )
        Severity: Major
        Found in openc3/templates/tool_svelte/src/services/api.js and 1 other location - About 2 hrs to fix
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/services/api.js on lines 37..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 unsegment_packet has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def unsegment_packet(packet)
              @ccsds_packet.buffer = packet.buffer
        
              previous_sequence_count = @sequence_count
              @sequence_count = @ccsds_packet.read('CcsdsSeqcnt')
        Severity: Major
        Found in openc3/lib/openc3/ccsds/ccsds_parser.rb - About 2 hrs to fix

          Function __init__ has 18 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in openc3/python/openc3/models/microservice_model.py - About 2 hrs to fix

            Method _openc3_script_wait_implementation has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def _openc3_script_wait_implementation(target_name, packet_name, item_name, value_type, timeout, polling_rate, exp_to_eval, scope: $openc3_scope, token: $openc3_token, &block)
                  end_time = Time.now.sys + timeout
                  if exp_to_eval and !exp_to_eval.is_printable?
                    raise "ERROR: Invalid comparison to non-ascii value"
                  end
            Severity: Major
            Found in openc3/lib/openc3/script/api_shared.rb - About 2 hrs to fix

              Method create has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def create(overlap: true)
                    if @recurring['end'] and @recurring['frequency'] and @recurring['span']
                      # First validate the initial recurring activity ... all others are just offsets
                      validate_input(start: @start, stop: @stop, kind: @kind, data: @data)
              
              
              Severity: Major
              Found in openc3/lib/openc3/models/activity_model.rb - About 2 hrs to fix

                Method dynamic_update has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def dynamic_update(packets, cmd_or_tlm = :TELEMETRY, filename = "dynamic_tlm.txt")
                      # Build hash of targets/packets
                      packet_hash = {}
                      packets.each do |packet|
                        target_name = packet.target_name.upcase
                Severity: Major
                Found in openc3/lib/openc3/models/target_model.rb - About 2 hrs to fix

                  Method define has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def define(item)
                        # Handle Overwriting Existing Item
                        if @items[item.name]
                          item_index = nil
                          @sorted_items.each_with_index do |sorted_item, index|
                  Severity: Major
                  Found in openc3/lib/openc3/packets/structure.rb - About 2 hrs to fix

                    Method syntax has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.syntax(filename, text)
                        language = detect_language(text, filename)
                        if language == 'ruby'
                          check_process = IO.popen('ruby -c -rubygems 2>&1', 'r+')
                          check_process.write("require 'openc3'; require 'openc3/script'; " + text)
                    Severity: Major
                    Found in openc3-cosmos-script-runner-api/app/models/script.rb - About 2 hrs to fix

                      Method start_service has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def start_service(hostname = nil, port = nil, object = nil, max_threads = 1000)
                            server_started = false
                            @server_mutex.synchronize do
                              server_started = true if @server
                            end
                      Severity: Major
                      Found in openc3/lib/openc3/io/json_drb.rb - About 2 hrs to fix

                        Method from_json has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def self.from_json(hash)
                              # Convert strings to symbols
                              endianness = hash['endianness'] ? hash['endianness'].intern : nil
                              data_type = hash['data_type'] ? hash['data_type'].intern : nil
                              overflow = hash['overflow'] ? hash['overflow'].intern : nil
                        Severity: Major
                        Found in openc3/lib/openc3/packets/packet_item.rb - About 2 hrs to fix

                          Method monitor has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def monitor
                                processes_to_delete = []
                                cleanup_time = Time.now
                                while true
                                  current_time = Time.now
                          Severity: Major
                          Found in openc3/lib/openc3/utilities/process_manager.rb - About 2 hrs to fix

                            Method install_phase1 has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def self.install_phase1(gem_file_path, existing_variables: nil, existing_plugin_txt_lines: nil, process_existing: false, scope:, validate_only: false)
                                  gem_name = File.basename(gem_file_path).split("__")[0]
                            
                                  temp_dir = Dir.mktmpdir
                                  tf = nil
                            Severity: Major
                            Found in openc3/lib/openc3/models/plugin_model.rb - About 2 hrs to fix

                              Method set_min_max_default has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def set_min_max_default(item, type, data_type)
                                    return unless @current_cmd_or_tlm == PacketConfig::COMMAND
                              
                                    # Need to set min, max, and default
                                    if data_type == :INT || data_type == :UINT
                              Severity: Major
                              Found in openc3/lib/openc3/packets/parsers/xtce_parser.rb - About 2 hrs to fix

                                Method reduce_to_single_packet has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def reduce_to_single_packet
                                      # Discard sync pattern if present
                                      if @sync_pattern
                                        if @reduction_state == :START
                                          return :STOP if @data.length < @sync_pattern.length
                                Severity: Major
                                Found in openc3/lib/openc3/interfaces/protocols/preidentified_protocol.rb - About 2 hrs to fix

                                  Method instrumented has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    def self.instrumented(filename, text)
                                      language = detect_language(text, filename)
                                      if language == 'ruby'
                                        return {
                                          'title' => 'Instrumented Script',
                                  Severity: Major
                                  Found in openc3-cosmos-script-runner-api/app/models/script.rb - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language