OpenC3/cosmos

View on GitHub

Showing 1,379 of 1,379 total issues

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

  def self.get_definitions(scope, definition_filename, binary_filename = nil)
    temp_dir = Dir.mktmpdir
    definition = body(scope, definition_filename)
    # We might not find the definition, especially if the binary isn't named
    # like the convention. If not, and they pass us a binary filename,
Severity: Minor
Found in openc3-cosmos-cmd-tlm-api/app/models/table.rb - About 1 hr to fix

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

        def self.all(scope, path_matchers, target: nil, include_temp: false)
          target = target.upcase if target
    
          bucket = Bucket.getClient()
          if target
    Severity: Minor
    Found in openc3/lib/openc3/utilities/target_file.rb - About 1 hr to fix

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

          def self.local_init
            if ENV['OPENC3_LOCAL_MODE'] and Dir.exist?(OPENC3_LOCAL_MODE_PATH)
              puts "Local init running: #{OPENC3_LOCAL_MODE_PATH} exists"
              Dir.each_child(OPENC3_LOCAL_MODE_PATH).each do |scope_dir|
                next unless File.directory?("#{OPENC3_LOCAL_MODE_PATH}/#{scope_dir}")
      Severity: Minor
      Found in openc3/lib/openc3/utilities/local_mode.rb - About 1 hr to fix

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

        Rails.application.configure do
          # Settings specified here will take precedence over those in config/application.rb.
        
          # In the development environment your application's code is reloaded any time
          # it changes. This slows down response time but is perfect for development
        openc3-cosmos-cmd-tlm-api/config/environments/development.rb on lines 3..40

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

        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

        Rails.application.configure do
          # Settings specified here will take precedence over those in config/application.rb.
        
          # In the development environment your application's code is reloaded any time
          # it changes. This slows down response time but is perfect for development
        openc3-cosmos-script-runner-api/config/environments/development.rb on lines 3..40

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

        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

            def get_token(username)
              if ENV['OPENC3_API_CLIENT'].nil?
                ENV['OPENC3_API_PASSWORD'] ||= ENV['OPENC3_SERVICE_PASSWORD']
                return OpenC3Authentication.new().token
              else
        Severity: Major
        Found in openc3/lib/openc3/microservices/reaction_microservice.rb and 1 other location - About 1 hr to fix
        openc3/lib/openc3/microservices/timeline_microservice.rb on lines 45..58

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

        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

            def get_token(username)
              if ENV['OPENC3_API_CLIENT'].nil?
                ENV['OPENC3_API_PASSWORD'] ||= ENV['OPENC3_SERVICE_PASSWORD']
                return OpenC3Authentication.new().token
              else
        Severity: Major
        Found in openc3/lib/openc3/microservices/timeline_microservice.rb and 1 other location - About 1 hr to fix
        openc3/lib/openc3/microservices/reaction_microservice.rb on lines 230..243

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

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

            calcLimits(limitsSettings) {
              if (!limitsSettings) {
                return
              }
              this.yellowLow = Math.round(

          Function calcPosition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              calcPosition(value, limitsSettings) {
                if (!value || !limitsSettings) {
                  return
                }
                let lowValue = limitsSettings[0] - 10 * this.scale

            Method read_all_names has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def read_all_names(value_type = nil, reduced_type = nil)
                  result = {}
                  if value_type
                    case value_type
                    when :RAW
            Severity: Minor
            Found in openc3/lib/openc3/packets/json_packet.rb - About 1 hr to fix

              Method read has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def read(ignore_protocol_messages: true, timeout: nil)
                    start_time = Time.now
                    while true
                      message = read_message()
                      if message
              Severity: Minor
              Found in openc3/lib/openc3/script/web_socket_api.rb - About 1 hr to fix

                Method footer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def footer
                      self.puts "Completed #{@context}"
                
                      @report << ''
                      @report << "--- Test Summary ---"
                Severity: Minor
                Found in openc3/lib/openc3/script/suite_results.rb - About 1 hr to fix

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

                      def initialize(name)
                        super(name, is_plugin: false)
                  
                        if @config['options']
                          @config['options'].each do |option|
                  Severity: Minor
                  Found in openc3/lib/openc3/microservices/reducer_microservice.rb - About 1 hr to fix

                    Method write_to_clients has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def write_to_clients(method, packet_or_data)
                          @connection_mutex.synchronize do
                            # Send data to each client - On error drop the client
                            indexes_to_delete = []
                            index = 0
                    Severity: Minor
                    Found in openc3/lib/openc3/interfaces/tcpip_server_interface.rb - About 1 hr to fix

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

                          def handle_config(parser, keyword, parameters)
                            case keyword
                            when 'URL'
                              parser.verify_num_parameters(1, 1, "URL <URL>")
                              @url = parameters[0]
                      Severity: Minor
                      Found in openc3/lib/openc3/models/tool_model.rb - About 1 hr to fix

                        Method run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def self.run
                              ScopeModel.names.each do |scope|
                                # Get all existing InterfaceModels and change json for log_raw to log_stream
                                # Also remove the log key
                                interface_models = InterfaceModel.all(scope: scope)
                        Severity: Minor
                        Found in openc3/lib/openc3/migrations/20220420190000_log_stuff.rb - About 1 hr to fix

                          Method get_cmd_hazardous has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def get_cmd_hazardous(*args, manual: false, scope: $openc3_scope, token: $openc3_token, **kwargs)
                                extract_string_kwargs_to_args(args, kwargs)
                                case args.length
                                when 1
                                  target_name, command_name, parameters = extract_fields_from_cmd_text(args[0], scope: scope)
                          Severity: Minor
                          Found in openc3/lib/openc3/api/cmd_api.rb - About 1 hr to fix

                            Method convert_microservice_to_process_definition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def convert_microservice_to_process_definition(microservice_name, microservice_config)
                                  process_definition = ["ruby", "plugin_microservice.rb"]
                                  work_dir = "/openc3/lib/openc3/microservices"
                                  env = microservice_config["env"].dup
                                  if microservice_config["needs_dependencies"]
                            Severity: Minor
                            Found in openc3/lib/openc3/operators/microservice_operator.rb - About 1 hr to fix

                              Method update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def update
                                  return unless authorization('script_run')
                                  model = @model_class.score(name: params[:name], score: params[:id].to_i, scope: params[:scope])
                                  if model.nil?
                                    render json: { status: 'error', message: NOT_FOUND }, status: 404
                              Severity: Minor
                              Found in openc3-cosmos-cmd-tlm-api/app/controllers/activity_controller.rb - About 1 hr to fix

                                Method read has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def read(read_length)
                                        if read_length <= (@buffer.length - @buffer_index)
                                          # Return part of the buffer without having to go to the OS
                                          result = @buffer[@buffer_index, read_length]
                                          @buffer_index += read_length
                                Severity: Minor
                                Found in openc3/lib/openc3/io/buffered_file.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language