ManageIQ/manageiq-ui-classic

View on GitHub

Showing 18,390 of 18,390 total issues

Method add_interface has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_interface
    assert_privileges("network_router_add_interface")
    @router = find_record_with_rbac(NetworkRouter, params[:id])

    case params[:button]
Severity: Minor
Found in app/controllers/network_router_controller.rb - About 1 hr to fix

Method widget_validate_entries has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def widget_validate_entries
    if %w[r c].include?(@sb[:wtype]) && (!@edit[:new][:repfilter] || @edit[:new][:repfilter] == "")
      add_flash(_("A Report must be selected"), :error)
    end
    if %w[role group].include?(@edit[:new][:visibility_typ])
Severity: Minor
Found in app/controllers/report_controller/widgets.rb - About 1 hr to fix

Method heatmaps has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def heatmaps
    # Get latest hourly rollup for each node.
    cluster_ids = @ems.ems_clusters if @ems.present?
    metrics = MetricRollup.latest_rollups(EmsCluster.name, cluster_ids)
    metrics = metrics.where('timestamp > ?', 30.days.ago.utc).includes(:resource)
Severity: Minor
Found in app/services/ems_infra_dashboard_service.rb - About 1 hr to fix

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

    if record.current_group
      row = row_data_for_group_and_role(_('Current Group'), record.current_group.description, "ff ff-group")
      if role_allows?(:feature => "rbac_group_show")
        row[:cells][:link] = record.current_group.description
        row[:cells][:onclick] = settings_user_onclick("g-#{record.current_group.id}")
Severity: Major
Found in app/helpers/settings_users_helper.rb and 1 other location - About 1 hr to fix
app/helpers/ops_helper/group_rbac_details_helper.rb on lines 48..59

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

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 group.miq_user_role
      row = row_data_for_role(_('Role'), group.miq_user_role.name, "ff ff-user-role")
      if role_allows?(:feature => "rbac_group_show")
        row[:cells][:link] = group.miq_user_role.name
        row[:cells][:onclick] = select_tree_node_onclick("ur-#{group.miq_user_role.id}")
Severity: Major
Found in app/helpers/ops_helper/group_rbac_details_helper.rb and 1 other location - About 1 hr to fix
app/helpers/settings_users_helper.rb on lines 37..48

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

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

    when "reset", nil # Reset or first time in
      @in_a_form = true
      params[:id] ||= find_checked_items[0]
      @policy = MiqPolicy.find_by(:id => params[:id]) # Get existing record

Severity: Major
Found in app/controllers/miq_policy_controller/policies.rb and 1 other location - About 1 hr to fix
app/controllers/miq_policy_controller/policies.rb on lines 166..181

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

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

    when "reset", nil # Reset or first time in
      @in_a_form = true
      params[:id] ||= find_checked_items[0]
      @policy = MiqPolicy.find_by(:id => params[:id]) # Get existing record

Severity: Major
Found in app/controllers/miq_policy_controller/policies.rb and 1 other location - About 1 hr to fix
app/controllers/miq_policy_controller/policies.rb on lines 201..216

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

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

  renderGitImport: function(branches, tags, gitRepoId, messages) {
    clearMessages();

    var message = messages.message;
    var messageLevel = messages.level;
Severity: Minor
Found in app/javascript/oldjs/automate_import_export.js - About 1 hr to fix

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

    link: function(scope, elem, attr, ctrl) {
      scope['form_' + ctrl.$name] = elem[0];
      scope['form_' + ctrl.$name + '_timerHide'] = attr.timerHide;

      scope.$watch(attr.ngModel, function() {
Severity: Minor
Found in app/javascript/oldjs/directives/scheduler/updateDropdownForTimer.js - About 1 hr to fix

Function render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const validation = (values) => {
      const errors = {};
      if (values.ems_id === '-1') {
        errors.ems_id = __('Required');
Severity: Minor
Found in app/javascript/components/cloud-network-form/cloud-network-form.jsx - About 1 hr to fix

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

  const onSubmit = (values) => {
    const submitValues = prepareSubmitData(values, recId, appliesToClass, appliesToId, initialValues, buttonIcon);
    let saveMessage = sprintf(__(`Custom Button %s has been successfully saved.`), submitValues.name);
    if (recId) {
      API.put(`/api/custom_buttons/${recId}`, submitValues, { skipErrors: [400] })

Function buildDataTableObject has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const buildDataTableObject = (pointChoice) => {
  const tableData = [];
  pointChoice.eventsObj.forEach((event) => {
    // TODO: Different timeline show different data, ensure all necessary data is included
    const emsUrl = event.ext_management_system.type.includes('StorageManager') ? 'ems_storage' : 'ems_infra/show';
Severity: Minor
Found in app/javascript/components/timeline-options/timeline-helper.js - About 1 hr to fix

Function modal has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function modal(title, Inner, closed, removeId) {
  const overrides = {
    addClicked: (orig) => Promise.resolve(orig()).then(closed),
    saveClicked: (orig) => Promise.resolve(orig()).then(closed),
    cancelClicked: (orig) => Promise.resolve(orig()).then(closed),
Severity: Minor
Found in app/javascript/provider-dialogs/modal.js - About 1 hr to fix

Function getPodsTrendChart has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getPodsTrendChart = (isLoading, dashboardData) => {
  if (isLoading !== true) {
    if (dashboardData.data.pod_metrics.dataAvailable) {
      const tooltipType = dashboardData.data.pod_metrics.interval_name;
      let config = 'hourlyPodUsageConfig';
Severity: Minor
Found in app/javascript/components/container-projects/helper.jsx - About 1 hr to fix

Function removeCatalogItems has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const removeCatalogItems = (catalogItems) => {
  const apiPromises = [];

  miqSparkleOn();
  catalogItems.forEach((item) => {
Severity: Minor
Found in app/javascript/components/remove-catalog-item-modal.jsx - About 1 hr to fix

Function GetCompliantResources has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const GetCompliantResources = ({ ...props }) => {
  const buttonLabel = __('Check Compliant Resources');
  const progressMsg = __('Checking');
  const defaultText = __(' ');
  const helperText = 'Check which currently attached resources comply with the selected capabilities:';

Function componentDidMount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  componentDidMount() {
    miqSparkleOn();
    const { catalogId } = this.props;
    if (catalogId) {
      Promise.all([
Severity: Minor
Found in app/javascript/components/catalog-form/catalog-form.jsx - About 1 hr to fix

Function toolbarReducer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const toolbarReducer = (state, action) => {
  switch (action.type) {
    case 'INCREMENT':
      return {
        ...state,
Severity: Minor
Found in app/javascript/components/miq-toolbar.jsx - About 1 hr to fix

Function getOverflowButtons has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getOverflowButtons = (widgetButtons, widgetId, widgetType, widgetTitle, setState, widgetModel, lastRun, nextRun) => {
  const menuItems = [];
  const parsedButtons = JSON.parse(widgetButtons);
  parsedButtons.forEach((button) => {
    menuItems.push(<OverflowMenuItem

Method get_custom_buttons has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_custom_buttons(model, record, toolbar_result)
    cbses = CustomButtonSet.find_all_by_class_name(button_class_name(model), service_template_id(record))
    cbses = CustomButtonSet.filter_with_visibility_expression(cbses, record)

    cbses.sort_by { |cbs| cbs.set_data[:group_index] }.collect do |cbs|
Severity: Minor
Found in app/helpers/application_helper/toolbar_builder.rb - About 1 hr to fix
Severity
Category
Status
Source
Language