ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

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

      if params[:time_zone]
        page << "ManageIQ.calendar.calDateFrom = new Date(#{(Time.zone.now - 1.month).in_time_zone(@edit[:tz]).strftime("%Y,%m,%d")});"
        page << "miqBuildCalendar();"
        page << "$('#miq_date_1').val('#{@edit[:new][:timer].start_date}');"
        page << "$('#start_hour').val('#{@edit[:new][:timer].start_hour.to_i}');"
Severity: Major
Found in app/controllers/report_controller/schedules.rb and 1 other location - About 1 hr to fix
app/controllers/report_controller/widgets.rb on lines 162..168

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

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

      if params[:time_zone]
        page << "ManageIQ.calendar.calDateFrom = new Date(#{(Time.zone.now - 1.month).in_time_zone(@edit[:tz]).strftime("%Y, %m, %d")});"
        page << "miqBuildCalendar();"
        page << "$('#miq_date_1').val('#{@edit[:new][:timer].start_date}');"
        page << "$('#start_hour').val('#{@edit[:new][:timer].start_hour.to_i}');"
Severity: Major
Found in app/controllers/report_controller/widgets.rb and 1 other location - About 1 hr to fix
app/controllers/report_controller/schedules.rb on lines 155..161

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

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

  def textual_collection_link(collection, as: nil, controller_collection: nil, explorer: false, feature: nil, label: nil, link: nil)
    if collection.kind_of?(Array)
      unless as && link
        raise ArgumentError, ":as and :link are both required when linking to an array",
              caller.reject { |x| x =~ /^#{__FILE__}:/ }
Severity: Minor
Found in app/helpers/textual_summary_helper.rb - About 1 hr to fix

Method group_information_summary has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def group_information_summary(group)
    rows = [
      row_data(_('ID'), group.id),
      row_data(_('Description'), group.description),
      row_data(_('Detailed Description'), group.detailed_description),
Severity: Minor
Found in app/helpers/ops_helper/group_rbac_details_helper.rb - About 1 hr to fix

Method save_default_search has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def save_default_search
    @edit = session[:edit]
    @view = session[:view]
    cols_key = @view.scoped_association.nil? ? @view.db.to_sym : (@view.db + "-" + @view.scoped_association).to_sym
    if params[:id]
Severity: Minor
Found in app/controllers/application_controller/filter.rb - About 1 hr to fix

Method compare_miq has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def compare_miq(_db = nil)
    @compressed = session[:miq_compressed]
    @exists_mode = session[:miq_exists_mode]
    if @compare.nil? # == nil
      compare_init("compare") # Init compare screen variables
Severity: Minor
Found in app/controllers/application_controller/compare.rb - About 1 hr to fix

Method index has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    case params[:model]
    when 'ExtManagementSystem'
      record = ExtManagementSystem.find_by(:id => params[:id])
      if record
Severity: Minor
Found in app/controllers/restful_redirect_controller.rb - About 1 hr to fix

Method import_automate_datastore has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def import_automate_datastore
    assert_privileges('miq_ae_class_import_export')
    if params[:selected_namespaces].present?
      selected_namespaces = determine_all_included_namespaces(params[:selected_namespaces])
      import_file_upload = ImportFileUpload.where(:id => params[:import_file_upload_id]).first
Severity: Minor
Found in app/controllers/miq_ae_tools_controller.rb - About 1 hr to fix

Method button has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def button
    @edit = session[:edit] # Restore @edit for adv search box
    params[:display] = @display if display_methods.include?(@display) # Were we displaying nested list

    # Handle Toolbar Policy Tag Button
Severity: Minor
Found in app/controllers/ems_configuration_controller.rb - About 1 hr to fix

Method create_method has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_method
    assert_privileges("miq_ae_method_new")
    @in_a_form = true
    case params[:button]
    when "cancel"
Severity: Minor
Found in app/controllers/miq_ae_class_controller.rb - About 1 hr to fix

Method build_details_grid has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_details_grid(view, mode = true)
    xml = REXML::Document.load("")
    xml << REXML::XMLDecl.new(1.0, "UTF-8")

    # Create root element
Severity: Minor
Found in app/controllers/miq_ae_class_controller.rb - About 1 hr to fix

Method set_right_cell_text has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def set_right_cell_text(id, rec = nil)
    nodes = id.split('-')
    case nodes[0]
    when "root"
      txt = _("Datastore")
Severity: Minor
Found in app/controllers/miq_ae_class_controller.rb - About 1 hr to fix

Method schedule_set_record_vars has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def schedule_set_record_vars(schedule)
    schedule.resource_type = schedule_resource_type_from_params_action
    schedule.sched_action = {:method => schedule_method_from_params_action}

    if params[:action_typ] == "automation_request"
Severity: Minor
Found in app/controllers/ops_controller/settings/schedules.rb - About 1 hr to fix

Method rbac_field_changed has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def rbac_field_changed(rec_type)
    id = params[:id].split('__').first || 'new' # Get the record id
    id = id unless %w[new seq].include?(id)
    return unless load_edit("rbac_#{rec_type}_edit__#{id}", "replace_cell__explorer")

Severity: Minor
Found in app/controllers/ops_controller/ops_rbac.rb - About 1 hr to fix

Method refresh_screen has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def refresh_screen
    @explorer = true
    if params[:pressed] == "delete_server" || params[:pressed] == "zone_delete_server"
      @sb[:diag_selected_id] = nil
      build_replaced_trees(%i[settings diagnostics], %i[settings diagnostics])
Severity: Minor
Found in app/controllers/ops_controller/diagnostics.rb - About 1 hr to fix

Method live_migrate_vm has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def live_migrate_vm
          assert_privileges("instance_live_migrate")
          case params[:button]
          when "cancel"
            add_flash(_("Live migration of Instances was cancelled by the user"))
Severity: Minor
Found in app/controllers/mixins/actions/vm_actions/live_migrate.rb - About 1 hr to fix

Method get_view_process_search_text has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_view_process_search_text(view)
    # Check for new search by name text entered
    if params[:search]
      @search_text = params[:search][:text].blank? ? nil : params[:search][:text].strip
    elsif params[:search_text] && @explorer
Severity: Minor
Found in app/controllers/application_controller.rb - About 1 hr to fix

Method fetch_playbook_details has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def fetch_playbook_details
    playbook_details = {}
    provision = @record.config_info[:provision]
    provisioning_details = {}
    provisioning_details[:repository] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource, provision[:repository_id])
Severity: Minor
Found in app/controllers/catalog_controller.rb - About 1 hr to fix

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

      exp.delete(@edit[@expkey][:exp_orig_key])                           # Remove the old exp fields
      exp[@edit[@expkey][:exp_key]] = {}                                  # Add in the new key
      exp[@edit[@expkey][:exp_key]]["count"] = @edit[@expkey][:exp_count] # Set the count table
      exp[@edit[@expkey][:exp_key]]["value"] = @edit[@expkey][:exp_value] # Set the value
      exp[@edit[@expkey][:exp_key]]["alias"] = @edit[@expkey][:alias] if @edit.fetch_path(@expkey, :alias)
Severity: Major
Found in app/controllers/application_controller/filter.rb and 1 other location - About 1 hr to fix
app/controllers/application_controller/filter.rb on lines 594..598

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

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

      exp.delete(@edit[@expkey][:exp_orig_key])                           # Remove the old exp fields
      exp[@edit[@expkey][:exp_key]] = {}                                  # Add in the new key
      exp[@edit[@expkey][:exp_key]]["tag"] = @edit[@expkey][:exp_tag]     # Set the tag
      exp[@edit[@expkey][:exp_key]]["value"] = @edit[@expkey][:exp_value] # Set the value
      exp[@edit[@expkey][:exp_key]]["alias"] = @edit[@expkey][:alias] if @edit.fetch_path(@expkey, :alias)
Severity: Major
Found in app/controllers/application_controller/filter.rb and 1 other location - About 1 hr to fix
app/controllers/application_controller/filter.rb on lines 580..584

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

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

Severity
Category
Status
Source
Language