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

          <div className="col-xs-12 col-sm-12 col-md-12 col-lg-6 example-trend-container">
            {processData.cpu.dataAvailable
              ? (
                <UtilizationDonutChart
                  data={data.metricsData}
app/javascript/components/provider-dashboard-charts/provider-dashboard-utilization-chart/index.js on lines 69..79

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

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 (props.roleAllows) {
    return (
      <div>
        <label htmlFor={propsData.input.name} className="bx--label">{propsData.label}</label>
        <br />
app/javascript/components/ansible-playbook-edit-catalog-form/helper.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 76.

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 (props.roleAllows) {
    return (
      <div>
        <label htmlFor={propsData.input.name} className="bx--label">{propsData.label}</label>
        <br />
app/javascript/components/terraform-template-catalog-form/helper.js on lines 141..149

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

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

function ErrorModalController($timeout) {
  var $ctrl = this;
  $ctrl.data = null;
  $ctrl.error = null;
  $ctrl.isHtml = false;
Severity: Major
Found in app/javascript/oldjs/controllers/error_modal_controller.js - About 2 hrs to fix

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

export const createSchema = (data) => {
  const fields = [
    {
      component: componentTypes.SUB_FORM,
      name: 'EvacuateInstance',
Severity: Major
Found in app/javascript/components/evacuate-form/evacuate-form.schema.js - About 2 hrs to fix

Function MultiSelectWithSelectAll has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MultiSelectWithSelectAll = (props) => {
  const {
    initialValues, options, id, titleText, label, placeholder,
    ...rest
  } = useFieldApi(prepareProps(props));
Severity: Major
Found in app/javascript/components/multiselect-with-selectall/index.js - About 2 hrs to fix

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

function createSchema(routerId, providerFields = [], subnets, loadSchema, emptySchema) {
  if (subnets) showSubnets = true;
  const fields = [{
    component: componentTypes.SUB_FORM,
    title: __('Network Management Provider'),
Severity: Major
Found in app/javascript/components/routers-form/RoutersForm.schema.js - About 2 hrs to fix

Function DiagnosticsCURepairForm has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DiagnosticsCURepairForm = () => {
  const [data, setData] = useState({
    isLoading: true,
    timezones: undefined,
    response: undefined,
Severity: Major
Found in app/javascript/components/c-and-u-collections-form/index.jsx - About 2 hrs to fix

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

  render() {
    const {
      selectedTagCategory, tags, assignedTags,
      onTagDeleteClick, onTagCategoryChange,
      onTagValueChange, onSingleTagValueChange, showReset,

Method edit_reports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def edit_reports
    @edit[:selected_reports] = []
    current_group_id = current_user.current_group.try(:id).to_i
    id = session[:node_selected].split('__')
    @selected = id[1].split(':')
Severity: Major
Found in app/controllers/report_controller/menus.rb - About 2 hrs to fix

Method db_edit has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def db_edit
    assert_privileges("db_edit")

    case params[:button]
    when "cancel"
Severity: Major
Found in app/controllers/report_controller/dashboards.rb - About 2 hrs to fix

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

  def comp_add_record(view, section, record, ridx)
    @same = true
    section_class = "#{section[:name]}_#{ridx}".to_s.gsub(/[\.]/, '_')
    row = {
      :col0           => @rows.blank? ? record : "<div> <a  class=\"exp-link #{section_class}\"  tabindex=\"0\" ><i class=\"fa fa-fw fa-angle-right exp-icon\"></i></a>#{record}</div>",
Severity: Major
Found in app/controllers/application_controller/compare.rb and 1 other location - About 2 hrs to fix
app/controllers/application_controller/compare.rb on lines 883..900

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

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

  def drift_add_record(view, section, record, ridx)
    @same = true
    section_class = "#{section[:name]}_#{ridx}".to_s.gsub(/[\.]/, '_')
    row = {
      :col0           => @rows.blank? ? record : "<div> <a  class=\"exp-link #{section_class}\"  tabindex=\"0\" ><i class=\"fa fa-fw fa-angle-right exp-icon \"></i></a>#{record}</div>",
Severity: Major
Found in app/controllers/application_controller/compare.rb and 1 other location - About 2 hrs to fix
app/controllers/application_controller/compare.rb on lines 1418..1435

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

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

  def remove_interface_finished
    task_id = session[:async][:params][:task_id]
    router_id = session[:async][:params][:id]
    router_name = session[:async][:params][:name]
    cloud_subnet_id = session[:async][:params][:cloud_subnet_id]
Severity: Major
Found in app/controllers/network_router_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/network_router_controller.rb on lines 131..154

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

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

  def add_interface_finished
    task_id = session[:async][:params][:task_id]
    router_id = session[:async][:params][:id]
    router_name = session[:async][:params][:name]
    cloud_subnet_id = session[:async][:params][:cloud_subnet_id]
Severity: Major
Found in app/controllers/network_router_controller.rb and 1 other location - About 2 hrs to fix
app/controllers/network_router_controller.rb on lines 224..247

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

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

Cyclomatic complexity for dialog_form_button_pressed is too high. [14/11]
Open

  def dialog_form_button_pressed
    case params[:button]
    when "cancel"
      return unless load_edit("dialog_edit__#{params[:id]}", "replace_cell__explorer")

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for exp_add_joiner is too high. [14/11]
Open

  def exp_add_joiner(exp, token, joiner)
    if exp[:token] && exp[:token] == token                # If the token matches
      exp.keys.each do |key|                              # Find the key
        if key == :token
          exp.delete(key)                                 # Remove the :token key

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for st_set_form_vars is too high. [14/11]
Open

  def st_set_form_vars
    @edit = {}
    @edit[:rec_id] = @record.id
    @edit[:key] = "st_edit__#{@record.id || "new"}"
    @edit[:url] = "servicetemplate_edit"

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for timeprofile_set_days_hours is too high. [14/11]
Open

  def timeprofile_set_days_hours(_timeprofile = @timeprofile)
    @timeprofile_details = {}
    @timeprofiles.each do |timeprofile|
      @timeprofile_details[timeprofile.description] = {}
      profile_key = timeprofile.profile[:days].nil? ? "days" : :days

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for set_active_tab is too high. [14/11]
Open

  def set_active_tab(nodetype)
    node = nodetype.downcase.split("-")
    case x_active_tree
    when :settings_tree
      case node[0]
Severity: Minor
Found in app/controllers/ops_controller.rb by rubocop

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6
Severity
Category
Status
Source
Language