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

      const groupData = groupOptions.resources.map((group, index) => ({ label: group.description, value: group.id, key: `key_${index}` }));
Severity: Major
Found in app/javascript/components/set-ownership-form/index.jsx and 1 other location - About 1 hr to fix
app/javascript/components/set-ownership-form/index.jsx on lines 81..81

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

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

  const donutChartData = [
    {
      group: config.usageDataName,
      value: memoryData.used,
    },
app/javascript/components/provider-dashboard-charts/provider-dashboard-utilization-chart/utilizationDonutChart.js on lines 9..18

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

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

  return {
    is_button: true,
    title: __('Resize'),
    text: __('Resize'),
    alt: __('Resize'),
app/javascript/components/reconfigure-vm-form/helpers/network.js on lines 140..148

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

var selectListElement = function(scope, timeout, ctrl, refresh) {
  timeout(function() {
    if (refresh) {
      if (scope[scope['form_' + ctrl.$name + '_ngHide']] === true) {
        angular.element(scope['form_' + ctrl.$name]).selectpicker('hide');

Function createSchema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createSchema(ems, cloudNetworkId, loadSchema, emptySchema, providerFields = []) {
  const providers = ems.filter((tenant) => tenant.type !== 'ManageIQ::Providers::Nuage::NetworkManager');
  const fields = [{
    component: componentTypes.SUB_FORM,
    title: __('Network Provider'),

Function datetime_range has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    datetime_range: function(val, options) {
      options = options || {};
      if (!options.format) {
        return val;
      }
Severity: Minor
Found in app/javascript/oldjs/miq_formatters.js - About 1 hr to fix

Function link has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    link: function(_scope, _elm, attrs, ctrl) {
      function multipleValidator(modelValue) {
        var memtype = attrs.memtype;
        var multiple = attrs.validateMultiple;
        var minvalue = attrs.miqmin;
Severity: Minor
Found in app/javascript/oldjs/directives/reconfigure/validateMultiple.js - About 1 hr to fix

Function cancelDisconnectDrives has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const cancelDisconnectDrives = (row, data, setData) => {
  const { id } = row;
  const index = id.substring(5);
  const datatableData = data.dataTable.drives;
  datatableData[index].filename = datatableData[index].disconnect_filename;
Severity: Minor
Found in app/javascript/components/reconfigure-vm-form/helpers/drive.js - About 1 hr to fix

Function reducers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const reducers = (oncheck, onclick) => (state = {}, action) => {
  const node = action.nodeId !== undefined ? Tree.nodeSelector(state, action.nodeId) : undefined;

  switch (action.type) {
    case ACTIONS.CHECKED_DIRECTLY:
Severity: Minor
Found in app/javascript/components/tree-view/reducers/index.js - About 1 hr to fix

Function createSchema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const createSchema = (recordId, data, setData, roles, options, memory, onCellClick, buttonClick) => {
  let formFields;

  switch (data.form.type) {
    case TYPES.DISK:

Function getPodsData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getPodsData = (data, createdlabel, deletedLabel) => {
  if (data && data.xData && data.yCreated && data.yDeleted) {
    const columnsData = data.xData;
    const createdData = data.yCreated;
    const deletedData = data.yDeleted;
Severity: Minor
Found in app/javascript/components/provider-dashboard-charts/helpers.js - About 1 hr to fix

Function cancelConnectDrives has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const cancelConnectDrives = (row, data, setData) => {
  const { id } = row;
  const index = id.substring(5);
  const datatableData = data.dataTable.drives;
  datatableData[index].filename = datatableData[index].old_filename;
Severity: Minor
Found in app/javascript/components/reconfigure-vm-form/helpers/drive.js - About 1 hr to fix

Function cancelEditNetwork has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const cancelEditNetwork = (row, data, setData, roles) => {
  const index = row.id.substring(7);
  const networkRows = data.dataTable.networkAdapters;

  if (!roles.isVmwareCloud) {
Severity: Minor
Found in app/javascript/components/reconfigure-vm-form/helpers/network.js - About 1 hr to fix

Function taggingMiddleware has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const taggingMiddleware = (store) => (next) => (action) => {
  let selected;

  const { type, meta, tag } = action;
  if (meta && meta.url) {
Severity: Minor
Found in app/javascript/miq-redux/middleware.js - About 1 hr to fix

Function packagesFromModules has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const packagesFromModules = (modules) => {
  // find the package.json file for each module
  modules = modules.filter(m => m.includes("node_modules"));
  var packagePaths = modules.map(m => {
    var match = m.match(/(.*node_modules\/)([^/]+)(\/[^/]+)?/);
Severity: Minor
Found in config/webpack/production.js - About 1 hr to fix

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

  const onSubmit = (values) => {
    miqSparkleOn();

    var vm_id, volume_id, redirectUrl;
    if (dropdownLabel == "Instance") {

Function setRenderForm has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const setRenderForm = (row, type, action) => {
    if (type === TYPES.DISK && action === 'edit') {
      return true;
    }
    if (type === TYPES.NETWORK || type === TYPES.EDITNETWORK) {
Severity: Minor
Found in app/javascript/components/reconfigure-vm-form/index.jsx - About 1 hr to fix

Function FormButtons has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function FormButtons(props) {
  const primaryTitle = props.customLabel || (props.newRecord ? __('Add') : __('Save'));
  const primaryHandler = (props.newRecord ? props.addClicked : props.saveClicked) || props.addClicked || props.saveClicked;

  // NOTE: These strings will be translated by <MiqButton />
Severity: Minor
Found in app/javascript/forms/form-buttons.jsx - About 1 hr to fix

Method apply_common_props has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_common_props(button, input)
    button.update(
      :color        => input[:color],
      :data         => button.data(input[:data]),
      :hidden       => button[:hidden] || !!input[:hidden],
Severity: Minor
Found in app/helpers/application_helper/toolbar_builder.rb - About 1 hr to fix

Method calculate_disk_name has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def calculate_disk_name(disk)
    case disk.device_type
    when "cdrom-raw"
      "CD-ROM (IDE #{disk.location})"
    when "atapi-cdrom"
Severity: Minor
Found in app/helpers/vm_helper.rb - About 1 hr to fix
Severity
Category
Status
Source
Language