idcf/idcf-ilb-ruby

View on GitHub

Showing 11 of 11 total issues

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

  module Ilb
    module ClientExtensions
      # SDK APIs for sslpolicy resource
      module Sslpolicy
        # Create a new sslpolicy.
Severity: Major
Found in lib/idcf/ilb/client_extensions/sslpolicy.rb and 1 other location - About 1 hr to fix
lib/idcf/ilb/client_extensions/fwgroup.rb on lines 2..51

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

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 Ilb
    module ClientExtensions
      # SDK APIs for fwgroup resource
      module Fwgroup
        # Create a new fwgroup.
Severity: Major
Found in lib/idcf/ilb/client_extensions/fwgroup.rb and 1 other location - About 1 hr to fix
lib/idcf/ilb/client_extensions/sslpolicy.rb on lines 2..52

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

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 check_job has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def check_job(id, headers = {}, callback_and_args = [], specify_res_id = true)
          flag = success?(id, headers)
          return if "DELETE" == @res.body["method"]
          if flag == true
            if specify_res_id == true
Severity: Minor
Found in lib/idcf/ilb/client_extensions/job.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 patch_l7route has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def patch_l7route(lb_id, config_id, id, data, headers = {})
Severity: Minor
Found in lib/idcf/ilb/client_extensions/l7route.rb - About 35 mins to fix

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

          def initialize(client, method, resource, parameters, headers)
    Severity: Minor
    Found in lib/idcf/ilb/request.rb - About 35 mins to fix

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

                def validate_absence!(attributes, action)
                  if action
                    attributes.each do |name, value|
                      next unless !valid_attributes[name] || !valid_attributes[name][action]
                      raise(UnnecessaryAttribute, "`#{name}` is unnecessary in #{action} action")
      Severity: Minor
      Found in lib/idcf/ilb/validators/base.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

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

        module Ilb
          module ClientExtensions
            # SDK APIs for log resource
            module Log
              # Get list of logs
      Severity: Minor
      Found in lib/idcf/ilb/client_extensions/log.rb and 1 other location - About 35 mins to fix
      lib/idcf/ilb/client_extensions/virtualmachine.rb on lines 2..23

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

      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 Ilb
          module ClientExtensions
            # SDK APIs for virtualmachine resource
            module Virtualmachine
              # Get list of virtualmachines
      Severity: Minor
      Found in lib/idcf/ilb/client_extensions/virtualmachine.rb and 1 other location - About 35 mins to fix
      lib/idcf/ilb/client_extensions/log.rb on lines 2..24

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

      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 valid_attribute? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def valid_attribute?(value, valid_type)
                  case valid_type
                  when Array
                    valid_type.any? { |t| valid_attribute?(value, t) }
                  when Regexp
      Severity: Minor
      Found in lib/idcf/ilb/validators/base.rb - About 25 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

              def upload_sslcert(attributes, headers = {})
                fixed_attributes = { type: "self" }
                attributes.merge!(fixed_attributes)
                Validators::Sslcert.validate_attributes!(attributes, :upload)
                res = post!("sslcerts", attributes, headers)
      Severity: Minor
      Found in lib/idcf/ilb/client_extensions/sslcert.rb and 1 other location - About 25 mins to fix
      lib/idcf/ilb/client_extensions/sslcert.rb on lines 12..17

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

      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 create_sslcert(attributes, headers = {})
                fixed_attributes = { type: "system" }
                attributes.merge!(fixed_attributes)
                Validators::Sslcert.validate_attributes!(attributes, :create)
                res = post!("sslcerts", attributes, headers)
      Severity: Minor
      Found in lib/idcf/ilb/client_extensions/sslcert.rb and 1 other location - About 25 mins to fix
      lib/idcf/ilb/client_extensions/sslcert.rb on lines 29..34

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

      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