crowbar/crowbar-hadoop

View on GitHub
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Assignment Branch Condition size for nodes is too high. [79.06/30] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricsabcsize, http://c2.com/cgi/wiki?AbcMetric)
Open

  def nodes
    @hadoop_config = @service_object.get_hadoop_config

    respond_to do |format|
      format.html { render template: "barclamp/hadoop_infrastructure/nodes" }

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

  def nodes
    @hadoop_config = @service_object.get_hadoop_config

    respond_to do |format|
      format.html { render template: "barclamp/hadoop_infrastructure/nodes" }

Block has too many lines. [27/25]
Open

    respond_to do |format|
      format.html { render template: "barclamp/hadoop_infrastructure/nodes" }
      format.text {
        export = ["role, ip, name, cpu, ram, drives"]
        @hadoop_config[:adminnodes].each do |node|

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

        @hadoop_config[:adminnodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.adminnodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:datanodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.datanodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:namenodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.namenodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:hafilernodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.hafilernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:edgenodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.edgenodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:hajournalingnodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.hajournalingnodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 47..48
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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 7 locations. Consider refactoring.
Open

        @hadoop_config[:servernodes].each do |node|
          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.servernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 44..45
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 50..51
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 53..54
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 56..57
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 59..60
crowbar_framework/app/controllers/hadoop_infrastructure_controller.rb on lines 62..63

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

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

Line is too long. [163/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.datanodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Line is too long. [154/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

        headers["Content-Disposition"] = "attachment; filename=\"#{I18n.t('nodes.dell.nodes.filename', default: 'hadoop_infrastructure_inventory.txt')}\""

Line is too long. [171/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.hajournalingnodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)
Open

        headers["Content-Disposition"] = "attachment; filename=\"#{I18n.t('nodes.dell.nodes.filename', default: 'hadoop_infrastructure_inventory.txt')}\""

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

Line is too long. [166/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.hafilernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Line is too long. [163/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.edgenodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Avoid using {...} for multi-line blocks. (https://github.com/bbatsov/ruby-style-guide#single-line-blocks)
Open

      format.text {

Check for uses of braces or do/end around single line or multi-line blocks.

Example: EnforcedStyle: linecountbased (default)

# bad - single line block
items.each do |item| item / 5 end

# good - single line block
items.each { |item| item / 5 }

# bad - multi-line block
things.map { |thing|
  something = thing.some_method
  process(something)
}

# good - multi-line block
things.map do |thing|
  something = thing.some_method
  process(something)
end

Example: EnforcedStyle: semantic

# Prefer `do...end` over `{...}` for procedural blocks.

# return value is used/assigned
# bad
foo = map do |x|
  x
end
puts (map do |x|
  x
end)

# return value is not used out of scope
# good
map do |x|
  x
end

# Prefer `{...}` over `do...end` for functional blocks.

# return value is not used out of scope
# bad
each { |x|
  x
}

# return value is used/assigned
# good
foo = map { |x|
  x
}
map { |x|
  x
}.inspect

Example: EnforcedStyle: bracesforchaining

# bad
words.each do |word|
  word.flip.flop
end.join("-")

# good
words.each { |word|
  word.flip.flop
}.join("-")

Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)
Open

        headers["Content-Disposition"] = "attachment; filename=\"#{I18n.t('nodes.dell.nodes.filename', default: 'hadoop_infrastructure_inventory.txt')}\""

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

Line is too long. [164/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.adminnodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Line is too long. [163/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.namenodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

Line is too long. [165/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

          export << I18n.t(".barclamp.hadoop_infrastructure.nodes.servernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"

There are no issues that match your filters.

Category
Status