melvinsembrano/cms-fortress

View on GitHub

Showing 18 of 18 total issues

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

    def import!(path = self.path, parent = nil)
      Dir["#{path}*/"].each do |path|
        slug = path.split('/').last
        
        page = if parent
Severity: Minor
Found in lib/comfortable_mexican_sofa/fixture/page.rb - About 7 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 initialize has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(user)

    if user
      if user.type.eql?(:super_user)
        can :manage, :all
Severity: Minor
Found in app/models/cms_ability.rb - About 4 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 included has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def self.included(base)
        base.class_eval do

          before_action :configure_permitted_parameters, if: :devise_controller?

Severity: Minor
Found in lib/cms/fortress/application_controller_methods.rb - About 2 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 import! has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def import!(path = self.path, parent = nil)
      Dir["#{path}*/"].each do |path|
        slug = path.split('/').last
        
        page = if parent
Severity: Major
Found in lib/comfortable_mexican_sofa/fixture/page.rb - About 2 hrs to fix

    Method render_page has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

              def render_page(status = 200)
                cached_timeout = @cms_page.cached_timeout.to_i
    
                if cached_timeout > 0
                  fresh_when etag: @cms_page, last_modified: @cms_page.updated_at.utc, public: true
    Severity: Minor
    Found in lib/cms/fortress/content_renderer.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 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.included(base)
    
            base.extend ClassMethods
    
            base.class_eval do
    Severity: Minor
    Found in lib/cms/fortress/page_methods.rb - About 1 hr to fix

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

        def update
          user = user_params
      
          raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if user[:type_id].eql?(1) && !current_cms_fortress_user.type.eql?(:super_user)
      
      
      Severity: Minor
      Found in app/controllers/cms/fortress/users_controller.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 initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(user)
      
          if user
            if user.type.eql?(:super_user)
              can :manage, :all
      Severity: Minor
      Found in app/models/cms_ability.rb - About 1 hr to fix

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

            def export!
              prepare_folder!(self.path)
              
              self.site.pages.each do |page|
                page.slug = 'index' if page.slug.blank?
        Severity: Minor
        Found in lib/comfortable_mexican_sofa/fixture/page.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 initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize
                self.class.send(:include, Rails.application.routes.url_helpers)
                @theme = :default
                @enable_page_workflow = true
                @enable_page_caching = true
        Severity: Minor
        Found in lib/cms-fortress.rb - About 1 hr to fix

          Method included has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.included(base)
                  base.class_eval do
          
                    before_action :configure_permitted_parameters, if: :devise_controller?
          
          
          Severity: Minor
          Found in lib/cms/fortress/application_controller_methods.rb - About 1 hr to fix

            Method cms_fortress_routes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def cms_fortress_routes(options = {})
                path = options[:path] || "cms-admin"
            
                devise_for "cms/fortress/users",
                  :path => path,
            Severity: Minor
            Found in lib/cms/fortress/routes/admin.rb - About 1 hr to fix

              Method create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  @cms_fortress_user = @site.users.build(user_params)
                  raise CanCan::AccessDenied.new("Your are not allowed to create a super user.") if @cms_fortress_user.type.eql?(:super_user) && !current_cms_fortress_user.type.eql?(:super_user)
                  @cms_fortress_user.site_id = nil if @cms_fortress_user.type.eql?(:super_user)
              
              
              Severity: Minor
              Found in app/controllers/cms/fortress/users_controller.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! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def export!
                    prepare_folder!(self.path)
                    
                    self.site.pages.each do |page|
                      page.slug = 'index' if page.slug.blank?
              Severity: Minor
              Found in lib/comfortable_mexican_sofa/fixture/page.rb - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                  setup_role(role_detail, user) if defined?(setup_role)
                Severity: Major
                Found in app/models/cms_ability.rb - About 45 mins to fix

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

                    def topnav_resource_item(key, resource)
                      if ["divider", "dropdown-header"].include?(resource[:name])
                        title = resource[:title].nil? ? "" : t(resource[:title], site_name: @site.label)
                        content_tag(:li, title, class: resource[:name], role: "presentation")
                      else
                  Severity: Minor
                  Found in app/helpers/cms/fortress/application_helper.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

                    def images
                      @files = Comfy::Cms::File.images
                      respond_to do |format|
                        format.html { render partial: 'cms/fortress/shared/media_items', locals: {media: @files, type: :image} }
                        format.json { render json: @files }
                  Severity: Minor
                  Found in app/controllers/cms/fortress/admin_controller.rb and 1 other location - About 25 mins to fix
                  app/controllers/cms/fortress/admin_controller.rb on lines 19..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 31.

                  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 videos
                      @files = Comfy::Cms::File.videos
                      respond_to do |format|
                        format.html { render partial: 'cms/fortress/shared/media_items', locals: {media: @files, type: :video} }
                        format.json { render json: @files }
                  Severity: Minor
                  Found in app/controllers/cms/fortress/admin_controller.rb and 1 other location - About 25 mins to fix
                  app/controllers/cms/fortress/admin_controller.rb on lines 11..15

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

                  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