OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

const vueLifecycles = singleSpaVue({
  Vue,
  appOptions: {
    router,
    store,
Severity: Major
Found in openc3/templates/tool_vue/src/main.js and 14 other locations - About 1 hr to fix
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-admin/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-bucketexplorer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-dataextractor/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-dataviewer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-handbooks/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-iframe/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-limitsmonitor/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tablemanager/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tlmgrapher/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tlmviewer/src/main.js on lines 21..34

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

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

const vueLifecycles = singleSpaVue({
  Vue,
  appOptions: {
    router,
    store,
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-admin/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-bucketexplorer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdsender/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-dataextractor/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-dataviewer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-handbooks/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-iframe/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-limitsmonitor/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-packetviewer/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-scriptrunner/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tablemanager/src/main.js on lines 21..34
openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-tlmgrapher/src/main.js on lines 21..34
openc3/templates/tool_vue/src/main.js on lines 21..34

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

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

function copy(acediff, e, dir) {
  const diffIndex = parseInt(e.target.getAttribute('data-diff-index'), 10)
  const diff = acediff.diffs[diffIndex]
  let sourceEditor
  let targetEditor

    Function diff has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      diff() {
        const dmp = new diff_match_patch()
        const val1 = this.editors.left.ace.getSession().getValue()
        const val2 = this.editors.right.ace.getSession().getValue()
        // Main diff method that calculates the diffs

      Function __init__ has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              write_port,
              read_port,
              write_timeout,
      Severity: Minor
      Found in openc3/python/openc3/interfaces/tcpip_server_interface.py - About 1 hr to fix

        Function __init__ has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(self):
                self.state = "DISCONNECTED"
                self.target_names = []
                self.cmd_target_names = []
                self.tlm_target_names = []
        Severity: Minor
        Found in openc3/python/openc3/interfaces/interface.py - About 1 hr to fix

          Method create_telemetry has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create_telemetry(xml, telemetry, target_name)
                # Gather and make unique all the packet items
                unique_items = telemetry[target_name] ? get_unique(telemetry[target_name]) : {}
          
                xml['xtce'].TelemetryMetaData do
          Severity: Minor
          Found in openc3/lib/openc3/packets/parsers/xtce_converter.rb - About 1 hr to fix

            Method start_listen_thread has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def start_listen_thread(port, listen_write = false, listen_read = false)
                  # Create a socket to accept connections from clients
                  addr = Socket.pack_sockaddr_in(port, @listen_address)
                  if RUBY_ENGINE == 'ruby'
                    listen_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
            Severity: Minor
            Found in openc3/lib/openc3/interfaces/tcpip_server_interface.rb - About 1 hr to fix

              Method protocol_cmd has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def protocol_cmd(cmd_name, *cmd_args, read_write: :READ_WRITE, index: -1)
                    read_write = read_write.to_s.upcase.intern
                    raise "Unknown protocol descriptor: #{read_write}. Must be :READ, :WRITE, or :READ_WRITE." unless [:READ, :WRITE, :READ_WRITE].include?(read_write)
                    handled = false
              
              
              Severity: Minor
              Found in openc3/lib/openc3/interfaces/interface.rb - About 1 hr to fix

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

                    def initialize(write_port,
                                   read_port,
                                   write_timeout,
                                   read_timeout,
                                   protocol_type = nil,
                Severity: Minor
                Found in openc3/lib/openc3/interfaces/tcpip_server_interface.rb - About 1 hr to fix

                  Method write_item has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def write_item(item, value, buffer)
                        item_name = item.name
                        case item_name
                        when 'HTTP_STATUS'
                          @packet.extra ||= {}
                  Severity: Minor
                  Found in openc3/lib/openc3/accessors/http_accessor.rb - About 1 hr to fix

                    Method call has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def call(log, _appender = nil)
                          #<SemanticLogger::Log:0x0000ffffa5002b20 @level=:info, @thread_name="puma srv tp 001", @name="MicroservicesController",
                          # @time=2024-09-22 18:04:27.955490052 +0000, @tags=[], @named_tags={}, @level_index=2, @message="Completed #traefik",
                          # @payload={:controller=>"MicroservicesController", :action=>"traefik", :format=>"HTML", :method=>"GET",
                          # :path=>"/openc3-api/traefik", :status=>200, :view_runtime=>0.41, :allocations=>1438, :status_message=>"OK",
                    Severity: Minor
                    Found in openc3/lib/openc3/utilities/cosmos_rails_formatter.rb - About 1 hr to fix

                      Method _limits_group has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def _limits_group(group_name, action:, manual:, scope:, token:)
                            authorize(permission: 'tlm_set', manual: manual, scope: scope, token: token)
                            group_name.upcase!
                            group = get_limits_groups(scope: scope, token: token)[group_name]
                            raise "LIMITS_GROUP #{group_name} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_name}" unless group
                      Severity: Minor
                      Found in openc3/lib/openc3/api/limits_api.rb - About 1 hr to fix

                        Method multi_create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def multi_create
                            return unless authorization('script_run')
                            input_activities = params.to_unsafe_h.slice(:multi).to_h['multi']
                            unless input_activities.is_a?(Array)
                              render json: { status: 'error', message: 'invalid input, must be json list/array' }, status: 400
                        Severity: Minor
                        Found in openc3-cosmos-cmd-tlm-api/app/controllers/activity_controller.rb - About 1 hr to fix

                          Method file_thread_body has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def file_thread_body(objects)
                              topics, offsets, item_objects_by_topic, packet_objects_by_topic = @collection.topics_offsets_and_objects
                              results = []
                          
                              # This will read out packets until nothing is left
                          Severity: Minor
                          Found in openc3-cosmos-cmd-tlm-api/app/models/logged_streaming_thread.rb - About 1 hr to fix

                            Function patch_addPadding has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            diff_match_patch.prototype.patch_addPadding = function (patches) {
                              var paddingLength = this.Patch_Margin
                              var nullPadding = ''
                              for (var x = 1; x <= paddingLength; x++) {
                                nullPadding += String.fromCharCode(x)

                              Function getSingleDiffInfo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function getSingleDiffInfo(editor, offset, diffString) {
                                const info = {
                                  startLine: 0,
                                  startChar: 0,
                                  endLine: 0,

                                Function diff_linesToChars_ has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                diff_match_patch.prototype.diff_linesToChars_ = function (text1, text2) {
                                  var lineArray = [] // e.g. lineArray[4] == 'Hello\n'
                                  var lineHash = {} // e.g. lineHash['Hello\n'] == 4
                                
                                  // '\x00' is a valid character, but various debuggers don't like it.

                                  Function diff_main has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  diff_match_patch.prototype.diff_main = function (
                                    text1,
                                    text2,
                                    opt_checklines,
                                    opt_deadline,

                                    Method identify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        def identify(packet_data, target_names = nil)
                                          identified_packet = nil
                                    
                                          target_names = target_names() unless target_names
                                    
                                    
                                    Severity: Minor
                                    Found in openc3/lib/openc3/packets/commands.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language