hawkular/hawkular-client-ruby

View on GitHub
lib/hawkular/operations/operations_api.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Client has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Client < Hawkular::BaseClient
    include WebSocket::Client
    include MonitorMixin

    attr_accessor :ws, :logger
Severity: Minor
Found in lib/hawkular/operations/operations_api.rb - About 2 hrs to fix

    Method invoke_operation_helper has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def invoke_operation_helper(operation_payload, operation_name = nil, binary_content = nil, &callback)
          synchronize { connect }
    
          # fallback to generic 'ExecuteOperation' if nothing is specified
          operation_name ||= 'ExecuteOperation'
    Severity: Minor
    Found in lib/hawkular/operations/operations_api.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 check_pre_conditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_pre_conditions(hash = {}, params = [], &callback)
          fail Hawkular::ArgumentError, 'Hash cannot be nil.' if hash.nil?
          fail Hawkular::ArgumentError, 'callback must have the perform method defined. include Hawkular::Operations' unless
              callback.nil? || callback.respond_to?('perform')
    
    
    Severity: Minor
    Found in lib/hawkular/operations/operations_api.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 handle_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_message(operation_name, operation_payload, &callback)
          client = @ws
          # register a callback handler
          @ws.on :message do |msg|
            parsed = msg.data.to_msg_hash
    Severity: Minor
    Found in lib/hawkular/operations/operations_api.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 export_jdr has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def export_jdr(resource_id, feed_id, delete_immediately = false, sender_request_id = nil, &callback)
    Severity: Minor
    Found in lib/hawkular/operations/operations_api.rb - About 35 mins to fix

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

            def to_msg_hash
              operation_name, json = split('=', 2)
      
              # Check if there is a zip file following JSON.
              # This check is done only in the first 100KB, hoping it's unlikely to
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(args)
            args = {
              credentials: {},
              options: {},
              wait_time: 0.5,
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.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 3 locations. Consider refactoring.
      Open

          def disable_deployment(hash, &callback)
            required = %i[resource_id feed_id deployment_name]
            check_pre_conditions hash, required, &callback
      
            hash[:destination_file_name] = hash[:deployment_name]
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.rb and 2 other locations - About 20 mins to fix
      lib/hawkular/operations/operations_api.rb on lines 230..237
      lib/hawkular/operations/operations_api.rb on lines 268..275

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

      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 restart_deployment(hash, &callback)
            required = %i[resource_id feed_id deployment_name]
            check_pre_conditions hash, required, &callback
      
            hash[:destination_file_name] = hash[:deployment_name]
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.rb and 2 other locations - About 20 mins to fix
      lib/hawkular/operations/operations_api.rb on lines 230..237
      lib/hawkular/operations/operations_api.rb on lines 249..256

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

      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 enable_deployment(hash, &callback)
            required = %i[resource_id feed_id deployment_name]
            check_pre_conditions hash, required, &callback
      
            hash[:destination_file_name] = hash[:deployment_name]
      Severity: Minor
      Found in lib/hawkular/operations/operations_api.rb and 2 other locations - About 20 mins to fix
      lib/hawkular/operations/operations_api.rb on lines 249..256
      lib/hawkular/operations/operations_api.rb on lines 268..275

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

      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