fog/fog-profitbricks

View on GitHub

Showing 140 of 140 total issues

Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def update
          requires :datacenter_id, :server_id, :nic_id, :id

          properties = {}
          properties[:name]           = name if name
Severity: Minor
Found in lib/fog/profitbricks/models/compute/firewall_rule.rb - About 45 mins 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 attach_cdrom has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def attach_cdrom(datacenter_id, server_id, cdrom_image_id)
          if cdrom = data[:images]['items'].find do |cd|
            cd["id"] == cdrom_image_id
          end
          else
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/attach_cdrom.rb - About 45 mins 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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def save
          requires :datacenter_id, :size, :type

          options = {}
          options[:name]              = name if name
Severity: Minor
Found in lib/fog/profitbricks/models/compute/volume.rb - About 45 mins 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 attach_volume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def attach_volume(datacenter_id, server_id, storage_id)
          if volume = data[:volumes]['items'].find do |vlm|
            vlm["id"] == storage_id && vlm["datacenter_id"] == datacenter_id
          end
          else
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/attach_volume.rb - About 45 mins 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

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

                  {
                    'id'        => dc1_id,
                    'type'      => 'datacenter',
                    'href'      => "https://api.profitbricks.com/cloudapi/v4/um/resources/datacenter/#{dc1_id}",
                    'metadata'  => {
Severity: Minor
Found in lib/fog/profitbricks/compute.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/compute.rb on lines 1239..1256

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

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 firewall_rule = data[:firewall_rules]['items'].find do |fwr|
            fwr["datacenter_id"] == datacenter_id && fwr["server_id"] == server_id && fwr["nic_id"] == nic_id && fwr["id"] == firewall_rule_id
          end
          else
            raise Excon::Error::HTTPStatus, "Resource does not exist"
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/get_firewall_rule.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb on lines 32..36

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

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

                  {
                    'id' => ipb1_id,
                    'type' => 'ipblock',
                    'href' => "https://api.profitbricks.com/cloudapi/v4/um/resources/ipblock/#{ipb1_id}",
                    'metadata' => {
Severity: Minor
Found in lib/fog/profitbricks/compute.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/compute.rb on lines 1176..1193

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

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 firewall_rule = data[:firewall_rules]["items"].find do |attribute|
            attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
          end
          else
            raise Fog::Errors::NotFound, "The requested firewall rule resource could not be found"
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/requests/compute/get_firewall_rule.rb on lines 53..57

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

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

                  {
                    'id'        => dc2_id,
                    'type'      => 'datacenter',
                    'href'      => "https://api.profitbricks.com/rest/v2/datacenters/#{dc2_id}",
                    'metadata'  => {
Severity: Minor
Found in lib/fog/profitbricks/compute.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/compute.rb on lines 247..264

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

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

      class Mock
        def remove_nic_association(datacenter_id, load_balancer_id, _nic_id)
          if load_balancer = data[:load_balancers]['items'].find do |lb|
            lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
          end
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/remove_nic_association.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/requests/compute/reboot_server.rb on lines 27..38

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

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

                  {
                    'id'        => dc1_id,
                    'type'      => 'datacenter',
                    'href'      => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}",
                    'metadata'  => {
Severity: Minor
Found in lib/fog/profitbricks/compute.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/compute.rb on lines 267..284

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

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

      class Mock
        def reboot_server(datacenter_id, server_id)
          if server = data[:servers]['items'].find do |attrib|
            attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
          end
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/reboot_server.rb and 1 other location - About 40 mins to fix
lib/fog/profitbricks/requests/compute/remove_nic_association.rb on lines 26..37

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

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

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

        def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
Severity: Minor
Found in lib/fog/profitbricks/requests/compute/update_firewall_rule.rb - About 35 mins to fix

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

            def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
    Severity: Minor
    Found in lib/fog/profitbricks/requests/compute/update_firewall_rule.rb - About 35 mins to fix

      Method collect_entities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def collect_entities(entities)
                if entities.is_a?(Array) && entities.length > 0
                  items = []
                  entities.each do |entity|
                    if entity.key?(:volumes)
      Severity: Minor
      Found in lib/fog/profitbricks/models/compute/datacenter.rb - About 35 mins 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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def save
                requires :datacenter_id, :server_id, :lan
      
                properties = {}
                properties[:name]           = name if name
      Severity: Minor
      Found in lib/fog/profitbricks/models/compute/nic.rb - About 35 mins 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

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

                                  'properties' => {
                                    'name'                => 'Docker Registry Volume',
                                    'type'                => 'HDD',
                                    'size'                => 50,
                                    'bus'                 => 'VIRTIO',
      Severity: Minor
      Found in lib/fog/profitbricks/compute.rb and 1 other location - About 30 mins to fix
      lib/fog/profitbricks/compute.rb on lines 674..690

      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

        module Compute
          class ProfitBricks
            class Real
              # Retrieves the status of the request
              #
      Severity: Minor
      Found in lib/fog/profitbricks/requests/compute/get_request_status.rb and 1 other location - About 30 mins to fix
      lib/fog/profitbricks/requests/compute/get_all_shares.rb on lines 2..41

      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

        module Compute
          class ProfitBricks
            class Real
              # Retrieve a full list of all the resources that are shared through this group
              # and lists the permissions granted to the group members for each shared resource.
      Severity: Minor
      Found in lib/fog/profitbricks/requests/compute/get_all_shares.rb and 1 other location - About 30 mins to fix
      lib/fog/profitbricks/requests/compute/get_request_status.rb on lines 2..43

      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

                        {
                          'id'              => 'dfcb40db-28b5-11e6-9336-52540005ab80',
                          'type'            => 'image',
                          'href'            => 'https://api.profitbricks.com/cloudapi/v4/um/resources/image/dfcb40db-28b5-11e6-9336-52540005ab80',
                          'metadata'        => {
      Severity: Minor
      Found in lib/fog/profitbricks/compute.rb and 1 other location - About 30 mins to fix
      lib/fog/profitbricks/compute.rb on lines 1218..1235

      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

      Severity
      Category
      Status
      Source
      Language