OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

    hasRaw: function () {
      for (let i = 0; i < this.currentPackets.length; i++) {
        if (this.currentPackets[i].mode === 'RAW') {
          return true
        }
openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/dataviewer/Component.js on lines 49..56

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

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

    hasDecom: function () {
      for (let i = 0; i < this.currentPackets.length; i++) {
        if (this.currentPackets[i].mode === 'DECOM') {
          return true
        }
openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/dataviewer/Component.js on lines 41..48

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

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 get_all_interface_info(manual: false, scope: $openc3_scope, token: $openc3_token)
      authorize(permission: 'system', manual: manual, scope: scope, token: token)
      info = []
      InterfaceStatusModel.all(scope: scope).each do |_int_name, int|
        info << [int['name'], int['state'], int['clients'], int['txsize'], int['rxsize'],
Severity: Major
Found in openc3/lib/openc3/api/interface_api.rb and 1 other location - About 1 hr to fix
openc3/lib/openc3/api/router_api.rb on lines 115..123

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

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 get_all_router_info(manual: false, scope: $openc3_scope, token: $openc3_token)
      authorize(permission: 'system', manual: manual, scope: scope, token: token)
      info = []
      RouterStatusModel.all(scope: scope).each do |_router_name, router|
        info << [router['name'], router['state'], router['clients'], router['txsize'], router['rxsize'],\
Severity: Major
Found in openc3/lib/openc3/api/router_api.rb and 1 other location - About 1 hr to fix
openc3/lib/openc3/api/interface_api.rb on lines 117..125

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

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

    def check_tolerance(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
      raise "Invalid type '#{type}' for check_tolerance" unless %i(RAW CONVERTED).include?(type)

      target_name, packet_name, item_name, expected_value, tolerance =
        _check_tolerance_process_args(args)
Severity: Minor
Found in openc3/lib/openc3/script/api_shared.rb - About 1 hr to fix

    Method handle_output_io has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def handle_output_io(filename = @current_filename, line_number = @current_line_number)
        @output_time = Time.now.sys
        if @output_io.string[-1..-1] == "\n"
          time_formatted = Time.now.sys.formatted
          color = 'BLACK'
    Severity: Minor
    Found in openc3-cosmos-script-runner-api/app/models/running_script.rb - About 1 hr to fix

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

            when 'PORT'
              usage = "PORT <Number> <Protocol (Optional)"
              parser.verify_num_parameters(1, 2, usage)
              begin
                @ports << [Integer(parameters[0])]
      Severity: Major
      Found in openc3/lib/openc3/models/microservice_model.rb and 1 other location - About 1 hr to fix
      openc3/lib/openc3/models/interface_model.rb on lines 308..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 69.

      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

            when 'PORT'
              usage = "PORT <Number> <Protocol (Optional)"
              parser.verify_num_parameters(1, 2, usage)
              begin
                @ports << [Integer(parameters[0])]
      Severity: Major
      Found in openc3/lib/openc3/models/interface_model.rb and 1 other location - About 1 hr to fix
      openc3/lib/openc3/models/microservice_model.rb on lines 168..185

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

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

      diff_match_patch.prototype.digit16 = function (c) {
        switch (c) {
          case '0':
            return 0
          case '1':

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

            def handle_packet(packet)
              InterfaceStatusModel.set(@interface.as_json(:allow_nan => true), queued: true, scope: @scope)
              packet.received_time = Time.now.sys unless packet.received_time
        
              if packet.stored
        Severity: Minor
        Found in openc3/lib/openc3/microservices/interface_microservice.rb - About 1 hr to fix

          Method limits_change_callback has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def limits_change_callback(packet, item, old_limits_state, value, log_change)
                return if @cancel_thread
                # Make a copy because packet_time is frozen
                packet_time = packet.packet_time.dup
                if value
          Severity: Minor
          Found in openc3/lib/openc3/microservices/decom_microservice.rb - About 1 hr to fix

            Method wait has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def wait(*args, type: :CONVERTED, quiet: false, scope: $openc3_scope, token: $openc3_token)
                  time_diff = nil
            
                  case args.length
                  # wait() # indefinitely until they click Go
            Severity: Minor
            Found in openc3/lib/openc3/script/api_shared.rb - About 1 hr to fix

              Method read_packet has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def read_packet(packet)
                    if @response_template && @response_packet
                      # If lines make it this far they are part of a response
                      @response_packets << packet
                      return :STOP if @response_packets.length < (@ignore_lines + @response_lines)
              Severity: Minor
              Found in openc3/lib/openc3/interfaces/protocols/template_protocol.rb - About 1 hr to fix

                Method formatted has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def formatted(
                    word_size = 1,
                    words_per_line = 16,
                    word_separator = ' ',
                    indent = 0,
                Severity: Minor
                Found in openc3/lib/openc3/core_ext/string.rb - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                                              if (
                                                  instance.cycle_time
                                                  and (utc_now - instance.start_time).total_seconds() > instance.cycle_time
                                              ):
                                                  Logger.debug("Log writer start new file due to cycle time")
                  Severity: Critical
                  Found in openc3/python/openc3/logs/log_writer.py - About 1 hr to fix

                    Method sync_system_thread_body has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.sync_system_thread_body(scope:, block_ms: nil)
                          telemetry = System.telemetry.all
                          topics = ["#{scope}__openc3_limits_events"]
                          Topic.read_topics(topics, nil, block_ms) do |_topic, _msg_id, event, _redis|
                            event = JSON.parse(event['event'], :allow_nan => true, :create_additions => true)
                    Severity: Minor
                    Found in openc3/lib/openc3/topics/limits_event_topic.rb - About 1 hr to fix

                      Method <=> has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def <=>(other)
                              return nil unless other.kind_of?(StructureItem)
                      
                              other_original_bit_offset = other.original_bit_offset
                      
                      
                      Severity: Minor
                      Found in openc3/lib/openc3/packets/structure_item.rb - About 1 hr to fix

                        Method linc_interface_command has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def linc_interface_command(packet)
                              if @error_ignore_commands
                                @error_ignore_commands.each do |error_ignore_command|
                                  if error_ignore_command.identify?(packet.buffer(false))
                                    linc_cmd = error_ignore_command.clone
                        Severity: Minor
                        Found in openc3/lib/openc3/interfaces/linc_interface.rb - About 1 hr to fix

                          Method ensure_public has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def ensure_public(bucket)
                                unless ENV['OPENC3_NO_BUCKET_POLICY']
                                  policy = <<~EOL
                                  {
                                    "Version": "2012-10-17",
                          Severity: Minor
                          Found in openc3/lib/openc3/utilities/aws_bucket.rb - About 1 hr to fix

                            Function set_limits has 13 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def set_limits(
                            Severity: Major
                            Found in openc3/python/openc3/api/limits_api.py - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language