padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

File routing.rb has 514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'padrino-support'
require 'padrino-core/path_router' unless defined?(PathRouter)
require 'padrino-core/ext/sinatra'
require 'padrino-core/filter'

Severity: Major
Found in padrino-core/lib/padrino-core/application/routing.rb - About 1 day to fix

    Method parse_route has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_route(path, options, verb)
            path = path.dup if path.kind_of?(String)
            route_options = {}
    
            if options[:params] == true
    Severity: Minor
    Found in padrino-core/lib/padrino-core/application/routing.rb - About 1 day 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 route has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

          def route(verb, path, *args, &block)
            options = case args.size
              when 2
                args.last.merge(:map => args.first)
              when 1
    Severity: Minor
    Found in padrino-core/lib/padrino-core/application/routing.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 create_database has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_database(config)
          begin
            if config[:adapter] =~ /sqlite/
              if File.exist?(config[:database])
                $stderr.puts "#{config[:database]} already exists."
    Severity: Minor
    Found in padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.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

    Class AbstractFormBuilder has 48 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class AbstractFormBuilder
            attr_accessor :template, :object, :multipart
            attr_reader :namespace, :is_nested, :parent_form, :nested_index, :attributes_name, :model_name
    
            def initialize(template, object, options={})

      Method create_admin has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_admin
              self.destination_root = options[:root]
              if in_app_root?
                unless supported_orm.include?(orm)
                  say "<= At the moment, Padrino only supports #{supported_orm.join(" or ")}. Sorry!", :yellow
      Severity: Minor
      Found in padrino-admin/lib/padrino-admin/generators/admin_app.rb - About 5 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

      File activerecord.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
        # Fixes for Yardoc YRI Building
        begin
          require 'active_record'
          require 'active_record/schema'
      Severity: Minor
      Found in padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb - About 5 hrs to fix

        Method call has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            def call(env)
              began_at = Time.now
              path_info = env["PATH_INFO"].to_s
              script_name = env['SCRIPT_NAME']
              http_host = env['HTTP_HOST']
        Severity: Minor
        Found in padrino-core/lib/padrino-core/router.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 create_controller has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_controller
                validate_namespace name
                self.destination_root = options[:root]
                if in_app_root?
                  app = options[:app]
        Severity: Minor
        Found in padrino-gen/lib/padrino-gen/generators/controller.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 create_admin has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def create_admin
                self.destination_root = options[:root]
                if in_app_root?
                  unless supported_orm.include?(orm)
                    say "<= At the moment, Padrino only supports #{supported_orm.join(" or ")}. Sorry!", :yellow
        Severity: Major
        Found in padrino-admin/lib/padrino-admin/generators/admin_app.rb - About 3 hrs to fix

          Method setup_components has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

                def setup_components
                  self.destination_root = options[:root]
                  if in_app_root?
                    @_components = options.class.new options.select{ |key,_| self.class.component_types.include?(key.to_sym) }
                    @app_name = (options[:app] || "App").gsub(/\W/, '_').camelize
          Severity: Minor
          Found in padrino-gen/lib/padrino-gen/generators/component.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

          Consider simplifying this complex logical expression.
          Open

          if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
            # Fixes for Yardoc YRI Building
            begin
              require 'active_record'
              require 'active_record/schema'
          Severity: Critical
          Found in padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb - About 3 hrs to fix

            Method output_migration_file has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

                    def output_migration_file(filename, name, columns, options={})
                      if behavior == :revoke
                        remove_migration(name)
                      else
                        return if migration_exist?(filename)
            Severity: Minor
            Found in padrino-gen/lib/padrino-gen/generators/components/actions.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 build_uri_query has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_uri_query(object, namespace = nil)
                  case object
                  when Hash
                    object.map do |key, value|
                      next if value == {} || value == []
            Severity: Minor
            Found in padrino-support/lib/padrino-support/utils.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 create_db has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.create_db(adapter, user, password, host, database, charset, collation)
                    case adapter
                      when 'postgres'
                        environment = {}
                        environment['PGPASSWORD'] = password unless password.nil? || password.empty?
            Severity: Minor
            Found in padrino-gen/lib/padrino-gen/padrino-tasks/sql-helpers.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 route has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def route(verb, path, *args, &block)
                    options = case args.size
                      when 2
                        args.last.merge(:map => args.first)
                      when 1
            Severity: Major
            Found in padrino-core/lib/padrino-core/application/routing.rb - About 3 hrs to fix

              Class Message has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Message # @private
                  include Sinatra::Templates
                  include Padrino::Rendering if defined?(Padrino::Rendering)
                  include Padrino::Helpers::RenderHelpers if defined? Padrino::Helpers::RenderHelpers
                  attr_reader :template_cache
              Severity: Minor
              Found in padrino-mailer/lib/padrino-mailer/ext.rb - About 3 hrs to fix

                Class Storage has 25 methods (exceeds 20 allowed). Consider refactoring.
                Open

                    class Storage
                      include Enumerable
                
                      # @private
                      def initialize(session=nil)
                Severity: Minor
                Found in padrino-core/lib/padrino-core/application/flash.rb - About 2 hrs to fix

                  File tooltip.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /* ========================================================================
                   * Bootstrap: tooltip.js v3.1.0
                   * http://getbootstrap.com/javascript/#tooltip
                   * Inspired by the original jQuery.tipsy by Jason Frame
                   * ========================================================================

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

                        def self.setup!
                          config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
                          config = Config[config_level]
                    
                          unless config
                    Severity: Minor
                    Found in padrino-core/lib/padrino-core/logger.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

                    Severity
                    Category
                    Status
                    Source
                    Language