padrino/padrino-framework

View on GitHub

Showing 170 of 214 total issues

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

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

            Method distance_of_time_in_words has 41 lines of code (exceeds 25 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

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

                    def setup_test_files
                      if options[:tiny] && @_components[:test] != :none
                        test_component = @_components[:test]
                        test_component = "rspec" if test_component == "cucumber"
                        uppercase_test_component = test_component.upcase
              Severity: Minor
              Found in padrino-gen/lib/padrino-gen/generators/project.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 setup_orm has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def setup_orm
                dm = DM
                db = @project_name.underscore
                %w(
                  dm-core
                Severity
                Category
                Status
                Source
                Language