OpenC3/cosmos

View on GitHub
openc3/lib/openc3/models/target_model.rb

Summary

Maintainability
F
4 days
Test Coverage

Method handle_config has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle_config(parser, keyword, parameters)
      case keyword
      when 'CMD_BUFFER_DEPTH'
        parser.verify_num_parameters(1, 1, "#{keyword} <Number of commands to buffer to ensure logged in order>")
        @cmd_buffer_depth = parameters[0].to_i
Severity: Major
Found in openc3/lib/openc3/models/target_model.rb - About 4 hrs to fix

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

            def deploy(gem_path, variables, validate_only: false)
              variables["target_name"] = @name
              start_path = "/targets/#{@folder_name}/"
              temp_dir = Dir.mktmpdir
              found = false
        Severity: Major
        Found in openc3/lib/openc3/models/target_model.rb - About 2 hrs to fix

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

              def initialize(
                name:,
                folder_name: nil,
                requires: [],
                ignored_parameters: [],
          Severity: Minor
          Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

            Method undeploy has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def undeploy
                  prefix = "#{@scope}/targets/#{@name}/"
                  @bucket.list_objects(bucket: ENV['OPENC3_CONFIG_BUCKET'], prefix: prefix).each do |object|
                    @bucket.delete_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: object.key)
                  end
            Severity: Minor
            Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

              Method as_json has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def as_json(*_a)
                    {
                      'name' => @name,
                      'folder_name' => @folder_name,
                      'requires' => @requires,
              Severity: Minor
              Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

                Method deploy_target_microservices has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def deploy_target_microservices(type, base_topic_list, topic_prefix)
                      target_microservices = @target_microservices[type]
                      if target_microservices
                        # These are stand alone microservice(s) ... not part of MULTI
                        if base_topic_list
                Severity: Minor
                Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

                  Method build_target_archive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def build_target_archive(temp_dir, target_folder)
                        target_files = []
                        Find.find(target_folder) { |file| target_files << file }
                        target_files.sort!
                        @id = OpenC3.hash_files(target_files, nil, 'SHA256').hexdigest
                  Severity: Minor
                  Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

                    Method download has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.download(target_name, scope:)
                          tmp_dir = Dir.mktmpdir
                          zip_filename = File.join(tmp_dir, "#{target_name}.zip")
                          Zip.continue_on_exists_proc = true
                          zip = Zip::File.open(zip_filename, Zip::File::CREATE)
                    Severity: Minor
                    Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                            if @cmd_log_retain_time or @cmd_decom_log_retain_time or @tlm_log_retain_time or @tlm_decom_log_retain_time or
                               @reduced_minute_log_retain_time or @reduced_hour_log_retain_time or @reduced_day_log_retain_time
                              # Cleanup Microservice
                              deploy_target_microservices('CLEANUP', nil, nil) do |_, instance, parent|
                                deploy_cleanup_microservice(gem_path, variables, instance, parent)
                      Severity: Major
                      Found in openc3/lib/openc3/models/target_model.rb - About 1 hr to fix

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

                            def deploy_decom_microservice(target, gem_path, variables, topics, instance = nil, parent = nil)
                        Severity: Minor
                        Found in openc3/lib/openc3/models/target_model.rb - About 45 mins to fix

                          Method deploy_decomlog_microservice has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def deploy_decomlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                          Severity: Minor
                          Found in openc3/lib/openc3/models/target_model.rb - About 35 mins to fix

                            Method deploy_reducer_microservice has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def deploy_reducer_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                            Severity: Minor
                            Found in openc3/lib/openc3/models/target_model.rb - About 35 mins to fix

                              Method deploy_commmandlog_microservice has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def deploy_commmandlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                              Severity: Minor
                              Found in openc3/lib/openc3/models/target_model.rb - About 35 mins to fix

                                Method deploy_decomcmdlog_microservice has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def deploy_decomcmdlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                Severity: Minor
                                Found in openc3/lib/openc3/models/target_model.rb - About 35 mins to fix

                                  Method deploy_packetlog_microservice has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def deploy_packetlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                  Severity: Minor
                                  Found in openc3/lib/openc3/models/target_model.rb - About 35 mins to fix

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

                                        def deploy_commmandlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                          microservice_name = "#{@scope}__COMMANDLOG#{instance}__#{@name}"
                                          microservice = MicroserviceModel.new(
                                            name: microservice_name,
                                            folder_name: @folder_name,
                                    Severity: Major
                                    Found in openc3/lib/openc3/models/target_model.rb and 3 other locations - About 1 hr to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 933..956
                                    openc3/lib/openc3/models/target_model.rb on lines 959..982
                                    openc3/lib/openc3/models/target_model.rb on lines 985..1008

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

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

                                        def deploy_decomcmdlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                          microservice_name = "#{@scope}__DECOMCMDLOG#{instance}__#{@name}"
                                          microservice = MicroserviceModel.new(
                                            name: microservice_name,
                                            folder_name: @folder_name,
                                    Severity: Major
                                    Found in openc3/lib/openc3/models/target_model.rb and 3 other locations - About 1 hr to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 907..930
                                    openc3/lib/openc3/models/target_model.rb on lines 959..982
                                    openc3/lib/openc3/models/target_model.rb on lines 985..1008

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

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

                                        def deploy_packetlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                          microservice_name = "#{@scope}__PACKETLOG#{instance}__#{@name}"
                                          microservice = MicroserviceModel.new(
                                            name: microservice_name,
                                            folder_name: @folder_name,
                                    Severity: Major
                                    Found in openc3/lib/openc3/models/target_model.rb and 3 other locations - About 1 hr to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 907..930
                                    openc3/lib/openc3/models/target_model.rb on lines 933..956
                                    openc3/lib/openc3/models/target_model.rb on lines 985..1008

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

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

                                        def deploy_decomlog_microservice(gem_path, variables, topics, instance = nil, parent = nil)
                                          microservice_name = "#{@scope}__DECOMLOG#{instance}__#{@name}"
                                          microservice = MicroserviceModel.new(
                                            name: microservice_name,
                                            folder_name: @folder_name,
                                    Severity: Major
                                    Found in openc3/lib/openc3/models/target_model.rb and 3 other locations - About 1 hr to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 907..930
                                    openc3/lib/openc3/models/target_model.rb on lines 933..956
                                    openc3/lib/openc3/models/target_model.rb on lines 959..982

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

                                    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

                                              begin
                                                Store.hset("#{@scope}__openc3cmd__#{target_name}", packet_name, JSON.generate(packet.as_json(:allow_nan => true)))
                                              rescue JSON::GeneratorError => e
                                                Logger.error("Invalid text present in #{target_name} #{packet_name} cmd packet")
                                                raise e
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 35 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 761..766

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

                                    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

                                              begin
                                                Store.hset("#{@scope}__openc3tlm__#{target_name}", packet_name, JSON.generate(packet.as_json(:allow_nan => true)))
                                              rescue JSON::GeneratorError => e
                                                Logger.error("Invalid text present in #{target_name} #{packet_name} tlm packet")
                                                raise e
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 35 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 781..786

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

                                    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

                                          begin
                                            system.telemetry.packets(@name).each do |packet_name, _packet|
                                              packet_topic_list << "#{@scope}__TELEMETRY__{#{@name}}__#{packet_name}"
                                              decom_topic_list  << "#{@scope}__DECOM__{#{@name}}__#{packet_name}"
                                            end
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 30 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 1145..1150

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

                                    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

                                          begin
                                            system.commands.packets(@name).each do |packet_name, _packet|
                                              command_topic_list << "#{@scope}__COMMAND__{#{@name}}__#{packet_name}"
                                              decom_command_topic_list << "#{@scope}__DECOMCMD__{#{@name}}__#{packet_name}"
                                            end
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 30 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 1153..1158

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

                                    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

                                              raw_topics << "#{@scope}__COMMAND__{#{@name}}__#{packet.packet_name.upcase}"
                                              decom_topics << "#{@scope}__DECOMCMD__{#{@name}}__#{packet.packet_name.upcase}"
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 20 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 877..878

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

                                    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

                                              raw_topics << "#{@scope}__TELEMETRY__{#{@name}}__#{packet.packet_name.upcase}"
                                              decom_topics << "#{@scope}__DECOM__{#{@name}}__#{packet.packet_name.upcase}"
                                    Severity: Minor
                                    Found in openc3/lib/openc3/models/target_model.rb and 1 other location - About 20 mins to fix
                                    openc3/lib/openc3/models/target_model.rb on lines 880..881

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

                                    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

                                    There are no issues that match your filters.

                                    Category
                                    Status