OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

    def _extract_target_command_parameter_names(method_name, *args)
      target_name = nil
      command_name = nil
      parameter_name = nil
      case args.length
Severity: Major
Found in openc3/lib/openc3/api/cmd_api.rb and 1 other location - About 1 hr to fix
openc3/lib/openc3/api/tlm_api.rb on lines 445..463

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

Function exec has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async exec(
    method,
    params,
    kwparams = {},
    headerOptions = {},

    Method handle_limits_values has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def handle_limits_values(item, value, limits_set, ignore_persistence)
          # Retrieve limits settings for the specified limits_set
          limits = item.limits.values[limits_set]
    
          # Use the default limits set if limits aren't specified for the
    Severity: Minor
    Found in openc3/lib/openc3/packets/packet.rb - About 1 hr to fix

      Method build_cmd_output_string has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def build_cmd_output_string(target_name, cmd_name, cmd_params, raw = false)
            if raw
              output_string = 'cmd_raw("'
            else
              output_string = 'cmd("'
      Severity: Minor
      Found in openc3/lib/openc3/packets/commands.rb - About 1 hr to fix

        Method write has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def write(packet)
              raise "Interface not connected for write: #{@name}" unless connected?
              raise "Interface not writable: #{@name}" unless write_allowed?
        
              _write do
        Severity: Minor
        Found in openc3/lib/openc3/interfaces/interface.rb - About 1 hr to fix

          Method instrument_script_implementation has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.instrument_script_implementation(ruby_lex_utils,
                                                      comments_removed_text,
                                                      _num_lines,
                                                      filename,
                                                      mark_private = false)
          Severity: Minor
          Found in openc3-cosmos-script-runner-api/app/models/running_script.rb - About 1 hr to fix

            Method api has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def api
                OpenC3.in_span('jsonrpc_api') do |span|
                  req = Rack::Request.new(request.env)
            
                  if request.post?
            Severity: Minor
            Found in openc3-cosmos-cmd-tlm-api/app/controllers/api_controller.rb - About 1 hr to fix

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

                  for (let i = 0; i < len; i++) {
                    converted = this.decode_openc3_type(data[0][i])
                    if (converted !== null) {
                      data[0][i] = converted
                    }
              Severity: Major
              Found in openc3/templates/tool_svelte/src/services/openc3-api.js and 1 other location - About 1 hr to fix
              openc3-cosmos-init/plugins/packages/openc3-tool-common/src/services/openc3-api.js on lines 320..325

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

              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

                  for (let i = 0; i < len; i++) {
                    converted = this.decode_openc3_type(data[0][i])
                    if (converted !== null) {
                      data[0][i] = converted
                    }
              openc3/templates/tool_svelte/src/services/openc3-api.js on lines 272..277

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

              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

                get: function (
                  path,
                  { params, headers = acceptOnlyDefaultHeaders, noScope, noAuth } = {}
                ) {
                  return request('get', path, { params, headers, noScope, noAuth })
              Severity: Major
              Found in openc3/templates/tool_svelte/src/services/api.js and 1 other location - About 1 hr to fix
              openc3/templates/tool_svelte/src/services/api.js on lines 86..91

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

              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

                delete: function (
                  path,
                  { params, headers = acceptOnlyDefaultHeaders, noScope, noAuth } = {}
                ) {
                  return request('delete', path, { params, headers, noScope, noAuth })
              Severity: Major
              Found in openc3/templates/tool_svelte/src/services/api.js and 1 other location - About 1 hr to fix
              openc3/templates/tool_svelte/src/services/api.js on lines 65..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 72.

              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

                class ScriptWebSocketApi < WebSocketApi
                  def initialize(url: nil, write_timeout: 10.0, read_timeout: 10.0, connect_timeout: 5.0, authentication: nil, scope: $openc3_scope)
                    url = generate_url() unless url
                    super(url: url, write_timeout: write_timeout, read_timeout: read_timeout, connect_timeout: connect_timeout, authentication: authentication, scope: scope)
                  end
              Severity: Major
              Found in openc3/lib/openc3/script/web_socket_api.rb and 1 other location - About 1 hr to fix
              openc3/lib/openc3/script/web_socket_api.rb on lines 176..187

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

              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

                class CmdTlmWebSocketApi < WebSocketApi
                  def initialize(url: nil, write_timeout: 10.0, read_timeout: 10.0, connect_timeout: 5.0, authentication: nil, scope: $openc3_scope)
                    url = generate_url() unless url
                    super(url: url, write_timeout: write_timeout, read_timeout: read_timeout, connect_timeout: connect_timeout, authentication: authentication, scope: scope)
                  end
              Severity: Major
              Found in openc3/lib/openc3/script/web_socket_api.rb and 1 other location - About 1 hr to fix
              openc3/lib/openc3/script/web_socket_api.rb on lines 192..203

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

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

                  applySetting(style, setting) {
                    switch (setting[0]) {
                      case 'TEXTALIGN':
                        style['text-align'] = setting[1].toLowerCase() + ' !important'
                        style['--text-align'] = setting[1].toLowerCase()

                Method wait_check_tolerance has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def wait_check_tolerance(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token, &block)
                      raise "Invalid type '#{type}' for wait_check_tolerance" unless %i(RAW CONVERTED).include?(type)
                
                      target_name, packet_name, item_name, expected_value, tolerance, timeout, polling_rate = _wait_tolerance_process_args(args)
                      start_time = Time.now.sys
                Severity: Minor
                Found in openc3/lib/openc3/script/api_shared.rb - About 1 hr to fix

                  Method write has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.write(event, scope:)
                        case event[:type]
                        when :LIMITS_CHANGE
                          # The current_limits hash keeps only the current limits state of items
                          # It is used by the API to determine the overall limits state
                  Severity: Minor
                  Found in openc3/lib/openc3/topics/limits_event_topic.rb - About 1 hr to fix

                    Method read_item has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def read_item(item, buffer)
                          item_name = item.name
                          case item_name
                          when 'HTTP_STATUS'
                            return nil unless @packet.extra
                    Severity: Minor
                    Found in openc3/lib/openc3/accessors/http_accessor.rb - About 1 hr to fix

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

                        def initialize
                          # Create local file cache location
                          @cache_dir = Dir.mktmpdir
                          FileUtils.mkdir_p(@cache_dir)
                          at_exit do
                      Severity: Minor
                      Found in openc3/lib/openc3/utilities/bucket_file_cache.rb - About 1 hr to fix

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

                          def initialize(key, start_time_nsec, end_time_nsec, item_key: nil, scope:, token: nil)
                            key = key.upcase
                            @key = key
                            @item_key = item_key
                            key_split = key.split('__')
                        Severity: Minor
                        Found in openc3-cosmos-cmd-tlm-api/app/models/streaming_object.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language