ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

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

  button_group('container_monitoring', [
    select(
      :container_monitoring_choice,
      nil,
      t = N_('Monitoring'),
Severity: Major
Found in app/helpers/application_helper/toolbar/container_center.rb and 2 other locations - About 1 hr to fix
app/helpers/application_helper/toolbar/container_group_center.rb on lines 2..30
app/helpers/application_helper/toolbar/container_project_center.rb on lines 2..30

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

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

    10.times do |i|
      @edit[:new][:options][:variables][i] ||= {}
      @edit[:new][:options][:variables][i][:oid] ||= ""
      @edit[:new][:options][:variables][i][:var_type] ||= "<None>"
      @edit[:new][:options][:variables][i][:value] ||= ""
Severity: Major
Found in app/controllers/miq_action_controller.rb and 1 other location - About 1 hr to fix
app/controllers/miq_alert_controller.rb on lines 428..433

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

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

    10.times do |i|
      @edit[:new][:snmp][:variables][i] ||= {}
      @edit[:new][:snmp][:variables][i][:oid] ||= ""
      @edit[:new][:snmp][:variables][i][:var_type] ||= "<None>"
      @edit[:new][:snmp][:variables][i][:value] ||= ""
Severity: Major
Found in app/controllers/miq_alert_controller.rb and 1 other location - About 1 hr to fix
app/controllers/miq_action_controller.rb on lines 181..186

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

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

window.load_c3_chart = function(data, chart_id, height) {
  if (typeof (data.miqChart) === 'undefined') {
    data.miqChart = 'Line';
  }

Severity: Minor
Found in app/javascript/oldjs/miq_c3.js - About 1 hr to fix

Function recalculateChartYAxisLabels has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.recalculateChartYAxisLabels = function(id) {
  // hide/show chart with id
  this.api.toggle(id);

  var minMax = getMinMaxFromChart(this);
Severity: Minor
Found in app/javascript/oldjs/miq_c3.js - About 1 hr to fix

Function setConfigInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var setConfigInfo = function(configData) {
    var method = {
      name: configData.name,
      display_name: configData.display_name,
      class_id: configData.class_id,
Severity: Minor
Found in app/javascript/angular/miq_ae_class/ae_method_form_controller.js - About 1 hr to fix

Function miqHttpInject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function miqHttpInject(angular_app) {
  angular_app.config(['$locationProvider', function($locationProvider) {
    /**
     * hashPrefix must be empty othervise it will conflict with HashRouter and create infinite loop
     * React HashRouter can be configured to have hashbang prefix,
Severity: Minor
Found in app/javascript/oldjs/miq_angular_application.js - About 1 hr to fix

Function number_with_delimiter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function number_with_delimiter(val, options) {
    options = _.extend({ delimiter: ',', separator: '.' }, options || {});
    var intpart;
    var floatpart;
    var minus;
Severity: Minor
Found in app/javascript/oldjs/miq_formatters.js - About 1 hr to fix

Function convertMultParamsToRailsMultParams has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function convertMultParamsToRailsMultParams(fullParamString) {
  const keyValuePairsArr = [];
  if (fullParamString) {
    fullParamString.split('&').forEach((element) => {
      if (element) {
Severity: Minor
Found in app/javascript/toolbar-actions/util.js - About 1 hr to fix

Function setupForm has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const setupForm = (initialValues, resources, name) => {
  const modifiedInitialValues = {
    name, values: [], enforced: [], invalid: [], ...initialValues,
  };

Severity: Minor
Found in app/javascript/components/tenant-quota-form/helper.js - About 1 hr to fix

Function loadvalues has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const loadvalues = (values) => {
    let stop = false;
    if (!allitems && values.selectedItems.length === options.length - 1) {
      setAllItems(true);
      values.selectedItems.push({ value: 'all', label: 'SELECT ALL' });
Severity: Minor
Found in app/javascript/components/multiselect-with-selectall/index.js - About 1 hr to fix

Function KebabListItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const KebabListItem = (item, props) => {
  if (item.type === 'separator') {
    return <SideNavDivider key={item.id} />;
  }

Severity: Minor
Found in app/javascript/components/toolbar/ToolbarKebab.jsx - About 1 hr to fix

Function onSubmit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const onSubmit = (values) => {
    miqSparkleOn();
    if (appliesToId) {
      values.owner_id = appliesToId;
    }
Severity: Minor
Found in app/javascript/components/button-group/index.jsx - About 1 hr to fix

Method li_link has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def li_link(args)
      args[:if] = (args[:count] != 0) if args[:count]
      args[:if] = true unless args.key?(:if)

      link_text, title = build_link_text(args)
Severity: Minor
Found in app/helpers/application_helper/listnav.rb - About 1 hr to fix

Method shared_button_basic_info has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def shared_button_basic_info(record, sb_items, custom_button)
    style = record&.options&.[](:button_color)&.to_s
    display_for = record&.options&.[](:display_for)
    display_how_map = {'single' => _('Single entity'), 'list' => _('List'), 'both' => _('Single and list')}
    display_for_value = display_how_map[display_for] if display_for.present?
Severity: Minor
Found in app/helpers/shared_helper/ab_show_helper.rb - About 1 hr to fix

Method center_toolbar_filename_services has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def center_toolbar_filename_services
    if x_active_tree == :sandt_tree
      if TreeBuilder.get_model_for_prefix(@nodetype) == "ServiceTemplate"
        "servicetemplate_center_tb"
      elsif @sb[:buttons_node]
Severity: Minor
Found in app/helpers/application_helper/toolbar_chooser.rb - About 1 hr to fix

Method edit_record has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def edit_record
    assert_privileges(params[:pressed])
    obj = find_checked_items
    db = params[:db] if params[:db]

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

Method build_automate_tree has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_automate_tree(type)
    tree_name = "#{type}_tree".to_sym

    # build the ae tree to show the tree select box for entry point
    if x_active_tree == tree_name && @edit && @edit[:new][:fqname]
Severity: Minor
Found in app/helpers/automate_tree_helper.rb - About 1 hr to fix

Method group_reorder_set_form_vars has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def group_reorder_set_form_vars
    @edit = {}
    @edit[:new] = {}
    @edit[:current] = {}
    @edit[:key] = "group_reorder"
Severity: Minor
Found in app/controllers/application_controller/buttons.rb - About 1 hr to fix

Method show_details has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show_details(db, options = {})
    association = options[:association]
    conditions  = options[:conditions]
    clickable   = options[:clickable].nil?
    @showtype = "details"
Severity: Minor
Found in app/controllers/infra_networking_controller.rb - About 1 hr to fix
Severity
Category
Status
Source
Language