aeolusproject/conductor

View on GitHub
src/app/decorators/controllers/tim/base_images_controller_decorator.rb

Summary

Maintainability
C
1 day
Test Coverage

Method get_target_image_info has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def get_target_image_info(target_images, provider_type)
    target_image = target_images.last
    info = {}
    # If there's no target image, or it's failed, show a build URL:
    if (target_image.nil? || target_image.status == Tim::TargetImage::STATUS_FAILED) &&

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

File base_images_controller_decorator.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

Tim::BaseImagesController.class_eval do
  before_filter :require_user

  before_filter :load_permissioned_images, :only => :index
  before_filter :check_view_permission, :only => [:show]

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

      def edit_xml
        @base_image = Tim::BaseImage.new(params[:base_image])
        if params[:template_source]
          @base_image.template = set_template(params[:template_source],
                                              @base_image.pool_family_id)

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

      def set_new_form_variables
        @base_image ||= Tim::BaseImage.new(params[:base_image])
        # FIXME: remove this:
        @base_image.template ||= Tim::Template.new
    
    

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

      def get_provider_image_data(provider_image, provider_account, target_image)
        info = {}
        # Show push URL if pimg is missing of failed
        if (provider_image.nil? || provider_image.status == Tim::ProviderImage::STATUS_FAILED) &&
          check_privilege(Alberich::Privilege::MODIFY, @base_image) && target_image && target_image.built?
    Severity: Minor
    Found in src/app/decorators/controllers/tim/base_images_controller_decorator.rb - About 55 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 set_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_template(source, pool_family_id)
        xml = nil
        xml = case source.class.name
              when 'String'
                downloader = DownloadService.new(source)
    Severity: Minor
    Found in src/app/decorators/controllers/tim/base_images_controller_decorator.rb - About 55 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        @base_image = Tim::BaseImage.new(params[:base_image]) unless defined? @base_image
    
        if params[:back]
          render :edit_xml
    Severity: Minor
    Found in src/app/decorators/controllers/tim/base_images_controller_decorator.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 build_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_all
        raise _('The Image you tried to access cannot be found. It may have been deleted.') unless @base_image
        if @base_image.imported?
          flash[:error] = _('Imported image can\'t be built or pushed')
          redirect_to @base_image and return
    Severity: Minor
    Found in src/app/decorators/controllers/tim/base_images_controller_decorator.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

    There are no issues that match your filters.

    Category
    Status