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}');"
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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}');"
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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__}:/ }
- Create a ticketCreate a ticket
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),
- Create a ticketCreate a ticket
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]
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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"
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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")
- Create a ticketCreate a ticket
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"
- Create a ticketCreate a ticket
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")
- Create a ticketCreate a ticket
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])
- Create a ticketCreate a ticket
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"))
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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])
- Create a ticketCreate a ticket
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)
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76