melvinsembrano/cms-fortress

View on GitHub

Showing 16 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

                  Severity
                  Category
                  Status
                  Source
                  Language