padrino/padrino-framework

View on GitHub

Showing 157 of 211 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 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

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

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

                    def number_to_human_size(number, *args)
                      return nil if number.nil?
              
                      options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}
              
              
              Severity: Minor
              Found in padrino-helpers/lib/padrino-helpers/number_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 require_dependencies has a Cognitive Complexity of 14 (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 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 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

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

                  def convert_ids(obj)
                    if obj.is_a?(String) && obj =~ /^[a-f0-9]{24}$/
                      defined?(Moped) ? Moped::BSON::ObjectId.from_string(obj) : BSON::ObjectId(obj)
                    elsif obj.is_a?(Array)
                      obj.map do |v|
              Severity: Minor
              Found in padrino-gen/lib/padrino-gen/padrino-tasks/mongoid.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