aeolus-incubator/tim

View on GitHub

Showing 17 of 17 total issues

Method handle_factory_callback has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_factory_callback(pi)
      case pi.status.upcase
        when "COMPLETE"
          pi.fsm_create_start    if pi.fsm_create_state == "queued"
          pi.fsm_create_complete unless pi.fsm_create_state == "complete"
Severity: Minor
Found in app/models/tim/provider_image_observer.rb - About 3 hrs 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_factory_callback has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_factory_callback(ti)
      case ti.status.upcase
        when "COMPLETE"
          ti.fsm_create_start    if ti.fsm_create_state == "queued"
          ti.fsm_create_complete unless ti.fsm_create_state == "complete"
Severity: Minor
Found in app/models/tim/target_image_observer.rb - About 3 hrs 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

  class TargetImageObserver < ActiveRecord::Observer
    observe ::Tim::TargetImage
    include ::Tim::StateMachine::TargetImage::FSMCreate
    include ::Tim::StateMachine::TargetImage::FSMDelete

Severity: Major
Found in app/models/tim/target_image_observer.rb and 1 other location - About 3 hrs to fix
app/models/tim/provider_image_observer.rb on lines 2..31

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

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 ProviderImageObserver < ActiveRecord::Observer
    observe ::Tim::ProviderImage
    include ::Tim::StateMachine::ProviderImage::FSMCreate
    include ::Tim::StateMachine::ProviderImage::FSMDelete

Severity: Major
Found in app/models/tim/provider_image_observer.rb and 1 other location - About 3 hrs to fix
app/models/tim/target_image_observer.rb on lines 2..31

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

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

    def request_with_oauth(method, path, *arguments)
      @oauth_config = Tim::ImageFactory::Base.config || {}
      # Take care to fall back to the standard request method if we don't have full OAuth credentials
      unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
        return request_without_oauth(method, path, *arguments)
Severity: Minor
Found in lib/image_factory/oauth/active_resource_oauth_client.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 included has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included base
        base.state_machine :fsm_create_state, :initial => :new do
          event :fsm_create_request do
            transition :new => :pending
          end
Severity: Minor
Found in app/state_machine/tim/state_machine/fsm.rb - About 1 hr to fix

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

        def self.replace_user_keys(map, user_keys)
          modified_map = map.clone
          map.each_pair do |key, value|
            # Sets the full template XML in the template.xml attribute
            if key == "template" || key == :template
    Severity: Minor
    Found in app/filters/tim/user_keys_filter.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 request_with_oauth has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def request_with_oauth(method, path, *arguments)
          @oauth_config = Tim::ImageFactory::Base.config || {}
          # Take care to fall back to the standard request method if we don't have full OAuth credentials
          unless use_oauth_for_url?("#{site.scheme}://#{site.host}:#{site.port}#{path}")
            return request_without_oauth(method, path, *arguments)
    Severity: Minor
    Found in lib/image_factory/oauth/active_resource_oauth_client.rb - About 1 hr to fix

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

              def after_fsm_create_request(pi, transition)
                if pi.imported?
                  if pi.send(:create_import)
                    pi.fsm_create_accept
                    pi.fsm_create_start
      Severity: Minor
      Found in app/state_machine/tim/state_machine/provider_image/fsm_create.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 transform_resource_links_recursively has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def transform_resource_links_recursively(subparams, sublinks)
          return if subparams == nil
      
          case sublinks
          when Symbol # then transform the link (last level of recursion)
      Severity: Minor
      Found in app/filters/tim/resource_link_filter.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 api_behavior has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def api_behavior(error)
            raise error unless resourceful?
      
            status = :ok
            begin
      Severity: Minor
      Found in app/responders/tim/custom_responder.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 request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def request(method, path, *arguments)
            result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
              payload[:method]      = method
              payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
              if method == :delete && arguments.size > 1
      Severity: Minor
      Found in app/patches/rails/active_resource/delete_with_content_body.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 5 locations. Consider refactoring.
      Open

          def update
            @template = Tim::Template.find(params[:id]) unless defined? @template
            if @template.update_attributes(params[:template])
              flash[:notice] = 'Template was successfully updated.'
            end
      Severity: Minor
      Found in app/controllers/tim/templates_controller.rb and 4 other locations - About 15 mins to fix
      app/controllers/tim/base_images_controller.rb on lines 36..41
      app/controllers/tim/image_versions_controller.rb on lines 34..39
      app/controllers/tim/provider_images_controller.rb on lines 37..42
      app/controllers/tim/target_images_controller.rb on lines 37..42

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

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

          def update
            @base_image = Tim::BaseImage.find(params[:id]) unless defined? @base_image
            if @base_image.update_attributes(params[:base_image])
              flash[:notice] = "Successfully updated Base Image"
            end
      Severity: Minor
      Found in app/controllers/tim/base_images_controller.rb and 4 other locations - About 15 mins to fix
      app/controllers/tim/image_versions_controller.rb on lines 34..39
      app/controllers/tim/provider_images_controller.rb on lines 37..42
      app/controllers/tim/target_images_controller.rb on lines 37..42
      app/controllers/tim/templates_controller.rb on lines 32..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 25.

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

          def update
            @image_version = Tim::ImageVersion.find(params[:id]) unless defined? @image_version
            if @image_version.update_attributes(params[:image_version])
              flash[:notice] = 'Image version was successfully updated.'
            end
      Severity: Minor
      Found in app/controllers/tim/image_versions_controller.rb and 4 other locations - About 15 mins to fix
      app/controllers/tim/base_images_controller.rb on lines 36..41
      app/controllers/tim/provider_images_controller.rb on lines 37..42
      app/controllers/tim/target_images_controller.rb on lines 37..42
      app/controllers/tim/templates_controller.rb on lines 32..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 25.

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

          def update
            @target_image = Tim::TargetImage.find(params[:id]) unless defined? @target_image
            if @target_image.update_attributes(params[:target_image])
              flash[:notice] = 'Target image was successfully updated.'
            end
      Severity: Minor
      Found in app/controllers/tim/target_images_controller.rb and 4 other locations - About 15 mins to fix
      app/controllers/tim/base_images_controller.rb on lines 36..41
      app/controllers/tim/image_versions_controller.rb on lines 34..39
      app/controllers/tim/provider_images_controller.rb on lines 37..42
      app/controllers/tim/templates_controller.rb on lines 32..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 25.

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

          def update
            @provider_image = Tim::ProviderImage.find(params[:id]) unless defined? @provider_image
            if @provider_image.update_attributes(params[:provider_image])
              flash[:notice] = 'Provider image was successfully updated.'
            end
      Severity: Minor
      Found in app/controllers/tim/provider_images_controller.rb and 4 other locations - About 15 mins to fix
      app/controllers/tim/base_images_controller.rb on lines 36..41
      app/controllers/tim/image_versions_controller.rb on lines 34..39
      app/controllers/tim/target_images_controller.rb on lines 37..42
      app/controllers/tim/templates_controller.rb on lines 32..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 25.

      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