padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

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

      def self.drop_db(adapter, user, password, host, database)
        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 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 invoke_route has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def invoke_route(route, params, first_time)
        @_response_buffer = nil
        @route = request.route_obj = route
        captured_params = captures_from_params(params)

Severity: Minor
Found in padrino-core/lib/padrino-core/application/routing.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 dispatch! has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def dispatch!
        @params = defined?(Sinatra::IndifferentHash) ? Sinatra::IndifferentHash[@request.params] : indifferent_params(@request.params)
        force_encoding(@params)
        invoke do
          static! if settings.static? && (request.get? || request.head?)
Severity: Minor
Found in padrino-core/lib/padrino-core/application/routing.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 render_like_sinatra has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def render_like_sinatra(engine, data, options={}, locals={}, &block)
        # merge app-level options
        engine_options = settings.respond_to?(engine) ? settings.send(engine) : {}
        options = engine_options.merge(options)

Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.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

File rendering.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'padrino/core_ext/output_safety'
require 'padrino-support'
require 'pathname'

module Padrino
Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.rb - About 2 hrs to fix

    Class Logger has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Logger
        ##
        # Ruby (standard) logger levels:
        #
        # :fatal:: An not handleable error that results in a program crash
    Severity: Minor
    Found in padrino-core/lib/padrino-core/logger.rb - About 2 hrs to fix

      Method parse_route has 54 lines of code (exceeds 25 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: Major
      Found in padrino-core/lib/padrino-core/application/routing.rb - About 2 hrs to fix

        Method render has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

                    def render(engine, file=nil, options={}, locals=nil, &block)
                      options.delete(:layout)
                      engine, file = file, engine if file.nil?
                      template_engine = engine ? ::Tilt[engine] : ::Tilt.default_mapping[file]
                      fail "Engine #{engine.inspect} is not registered with Tilt" unless template_engine
        Severity: Minor
        Found in padrino-helpers/lib/padrino-helpers/render_helpers.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 filter_params! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def filter_params!(params, allowed_params)
                params.each do |key,value|
                  type = allowed_params[key]
                  next if value.kind_of?(Array) && type
                  case
        Severity: Minor
        Found in padrino-core/lib/padrino-core/application/params_protection.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 require_dependencies has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def require_dependencies(*paths)
              options = { :cyclic => true }.update(paths.last.is_a?(Hash) ? paths.pop : {})
        
              files = paths.flatten.flat_map{ |path| Dir.glob(path).sort_by{ |filename| filename.count('/') } }.uniq
        
        
        Severity: Minor
        Found in padrino-core/lib/padrino-core/loader.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 create_app has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_app
                self.destination_root = options[:root]
                underscore_name = name.gsub(/\W/, '_')
                @app_folder = underscore_name.underscore
                @app_name   = underscore_name.camelize
        Severity: Minor
        Found in padrino-gen/lib/padrino-gen/generators/app.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

        Function show has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Tooltip.prototype.show = function () {
            var e = $.Event('show.bs.' + this.type)
        
            if (this.hasContent() && this.enabled) {
              this.$element.trigger(e)

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

                def provides_format(*types)
                  mime_types = types.map{ |type| mime_type(CONTENT_TYPE_ALIASES[type] || type) }
                  condition do
                    return provides_format?(types, params[:format].to_sym) if params[:format]
          
          
          Severity: Minor
          Found in padrino-core/lib/padrino-core/application/routing.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 server_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def server_options(options)
                  
                    info = []
                    server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
                    if server && server.respond_to?(:valid_options)
          Severity: Minor
          Found in padrino-core/lib/padrino-core/cli/launcher.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 render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def render(engine=nil, data=nil, options={}, locals={}, &block)
                locals = @_locals || {} if !options[:locals] && locals.empty?
                @template_cache.clear if settings.reload_templates?
          
                engine ||= message_name
          Severity: Minor
          Found in padrino-mailer/lib/padrino-mailer/ext.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 route! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def route!(base = settings, pass_block = nil)
                  Thread.current['padrino.instance'] = self
                  first_time = true
          
                  routes = base.compiled_router.call(@request) do |route, params|
          Severity: Minor
          Found in padrino-core/lib/padrino-core/application/routing.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 create_database has 47 lines of code (exceeds 25 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 1 hr to fix

            Function slide has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Carousel.prototype.slide = function (type, next) {
                var $active   = this.$element.find('.item.active')
                var $next     = next || $active[type]()
                var isCycling = this.interval
                var direction = type == 'next' ? 'left' : 'right'

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

                    def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
                      from_time = from_time.to_time if from_time.respond_to?(:to_time)
                      to_time = to_time.to_time if to_time.respond_to?(:to_time)
                      distance_in_minutes = (((to_time.to_i - from_time.to_i).abs)/60).round
                      distance_in_seconds = ((to_time.to_i - from_time.to_i).abs).round
              Severity: Minor
              Found in padrino-helpers/lib/padrino-helpers/format_helpers.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 partial has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                    def partial(template, options={}, &block)
                      options = { :layout => false }.update(options)
                      explicit_engine = options.delete(:engine)
              
                      path, _, name = template.to_s.rpartition(File::SEPARATOR)
              Severity: Minor
              Found in padrino-helpers/lib/padrino-helpers/render_helpers.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

              Severity
              Category
              Status
              Source
              Language