crowbar/crowbar-openstack

View on GitHub
chef/cookbooks/monasca/libraries/helper.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method set_retention_policy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.set_retention_policy(db_name, policy_name, duration, replicas,
    shard_group_duration: nil, default: nil,
    **options)
    rps_available = InfluxDBHelper.get_retention_policies(db_name, **options)
    rp = rps_available.find { |rp| rp['name'] == policy_name }
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method set_retention_policy has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.set_retention_policy(db_name, policy_name, duration, replicas,
    shard_group_duration: nil, default: nil,
    **options)
    rps_available = InfluxDBHelper.get_retention_policies(db_name, **options)
    rp = rps_available.find { |rp| rp['name'] == policy_name }
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb - About 1 hr to fix

Method create_retention_policy has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.create_retention_policy(db_name, policy_name, duration, replicas,
    shard_group_duration: nil, default: nil, **options)
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb - About 35 mins to fix

Method set_retention_policy has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.set_retention_policy(db_name, policy_name, duration, replicas,
    shard_group_duration: nil, default: nil,
    **options)
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb - About 35 mins to fix

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

  def self.log_api_network_url(node)
    monasca_log_api_url = if node[:monasca][:log_api][:url].nil? ||
        node[:monasca][:log_api][:url].empty?
      log_api_public_url(node)
    else
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 1 other location - About 30 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 60..67

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

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 self.api_network_url(node)
    monasca_api_url = if node[:monasca][:api][:url].nil? ||
        node[:monasca][:api][:url].empty?
      api_public_url(node)
    else
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 1 other location - About 30 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 123..130

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

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

  def self.log_api_public_url(node, version = "v3.0")
    host = monasca_public_host(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:log_api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 2 other locations - About 25 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 79..85
chef/cookbooks/monasca/libraries/helper.rb on lines 88..94

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

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

  def self.log_api_internal_url(node, version = "v3.0")
    host = get_host_for_monitoring_url(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:log_api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 2 other locations - About 25 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 70..76
chef/cookbooks/monasca/libraries/helper.rb on lines 79..85

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

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

  def self.log_api_admin_url(node, version = "v3.0")
    host = monasca_admin_host(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:log_api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 2 other locations - About 25 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 70..76
chef/cookbooks/monasca/libraries/helper.rb on lines 88..94

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

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

  def self.api_admin_url(node)
    host = monasca_admin_host(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 31..37
chef/cookbooks/monasca/libraries/helper.rb on lines 49..55
chef/cookbooks/monasca/libraries/helper.rb on lines 97..102
chef/cookbooks/monasca/libraries/helper.rb on lines 105..110
chef/cookbooks/monasca/libraries/helper.rb on lines 113..118

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

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

  def self.logs_search_admin_url(node)
    host = monasca_admin_host(node)
    # SSL is not supported at this moment
    protocol = "http"
    port = node[:monasca][:kibana][:bind_port]
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 31..37
chef/cookbooks/monasca/libraries/helper.rb on lines 40..46
chef/cookbooks/monasca/libraries/helper.rb on lines 49..55
chef/cookbooks/monasca/libraries/helper.rb on lines 97..102
chef/cookbooks/monasca/libraries/helper.rb on lines 113..118

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

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

  def self.api_public_url(node)
    host = monasca_public_host(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 40..46
chef/cookbooks/monasca/libraries/helper.rb on lines 49..55
chef/cookbooks/monasca/libraries/helper.rb on lines 97..102
chef/cookbooks/monasca/libraries/helper.rb on lines 105..110
chef/cookbooks/monasca/libraries/helper.rb on lines 113..118

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

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

  def self.api_internal_url(node)
    host = get_host_for_monitoring_url(node)
    # SSL is not supported at this moment
    # protocol = node[:monasca][:api][:ssl] ? "https" : "http"
    protocol = "http"
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 31..37
chef/cookbooks/monasca/libraries/helper.rb on lines 40..46
chef/cookbooks/monasca/libraries/helper.rb on lines 97..102
chef/cookbooks/monasca/libraries/helper.rb on lines 105..110
chef/cookbooks/monasca/libraries/helper.rb on lines 113..118

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

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

  def self.logs_search_public_url(node)
    host = monasca_public_host(node)
    # SSL is not supported at this moment
    protocol = "http"
    port = node[:monasca][:kibana][:bind_port]
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 31..37
chef/cookbooks/monasca/libraries/helper.rb on lines 40..46
chef/cookbooks/monasca/libraries/helper.rb on lines 49..55
chef/cookbooks/monasca/libraries/helper.rb on lines 105..110
chef/cookbooks/monasca/libraries/helper.rb on lines 113..118

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

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

  def self.logs_search_internal_url(node)
    host = get_host_for_monitoring_url(node)
    # SSL is not supported at this moment
    protocol = "http"
    port = node[:monasca][:kibana][:bind_port]
Severity: Minor
Found in chef/cookbooks/monasca/libraries/helper.rb and 5 other locations - About 15 mins to fix
chef/cookbooks/monasca/libraries/helper.rb on lines 31..37
chef/cookbooks/monasca/libraries/helper.rb on lines 40..46
chef/cookbooks/monasca/libraries/helper.rb on lines 49..55
chef/cookbooks/monasca/libraries/helper.rb on lines 97..102
chef/cookbooks/monasca/libraries/helper.rb on lines 105..110

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

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

There are no issues that match your filters.

Category
Status