padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

Method prepare_allowed_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def prepare_allowed_params(allowed_params)
        param_filter = {}
        allowed_params.each do |key,value|
          case
          when key.kind_of?(Hash) && !value
Severity: Minor
Found in padrino-core/lib/padrino-core/application/params_protection.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

Function activate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Tab.prototype.activate = function (element, container, callback) {
    var $active    = container.find('> .active')
    var transition = callback
      && $.support.transition
      && $active.hasClass('fade')

    Method create_db has 26 lines of code (exceeds 25 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 1 hr to fix

      Method setup_plugin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def setup_plugin
              if options[:list] || plugin_file.nil?
                list_plugins
              else # executing the plugin instructions
                self.destination_root = options[:root]
      Severity: Minor
      Found in padrino-gen/lib/padrino-gen/generators/plugin.rb - About 55 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

      Method asset_timestamp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def asset_timestamp(file_path)
              return nil if file_path =~ /\?/ || (self.class.respond_to?(:asset_stamp) && !self.class.asset_stamp)
              public_path = self.class.public_folder if self.class.respond_to?(:public_folder)
              public_path ||= Padrino.root("public") if Padrino.respond_to?(:root)
              public_file_path = File.join(public_path, file_path) if public_path
      Severity: Minor
      Found in padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb - About 55 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

      Method parse_data_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_data_options(tag, options)
              return unless options
              parsed_options = options.dup
              options.each do |key, value|
                next if !DATA_ATTRIBUTES.include?(key) || (tag.to_s == 'form' && key == :method)
      Severity: Minor
      Found in padrino-helpers/lib/padrino-helpers/tag_helpers.rb - About 55 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

      Method parse_conditions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_conditions(url, options)
              if options.has_key?(:if)
                condition = options.delete(:if)
                condition == :current ? url == request.path_info : condition
              elsif condition = options.delete(:unless)
      Severity: Minor
      Found in padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb - About 55 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

      Method flash_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def flash_tag(*args)
              options = args.last.is_a?(Hash) ? args.pop : {}
              bootstrap = options.delete(:bootstrap) if options[:bootstrap]
              args.inject(SafeBuffer.new) do |html,kind|
                next html unless flash[kind]
      Severity: Minor
      Found in padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb - About 55 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

      Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def initialize(template, object, options={})
                @template = template
                fail "FormBuilder template must be initialized" unless template
                @object = object.kind_of?(Symbol) ? build_object(object) : object
                fail "FormBuilder object must be present. If there's no object, use a symbol instead (i.e. :user)" unless object

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

          def match_with_arguments?(request)
            route = request.route_obj
            path = request.path_info
            @args.any? do |argument|
              if argument.instance_of?(Symbol)
      Severity: Minor
      Found in padrino-core/lib/padrino-core/filter.rb - About 55 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

      Method resolve_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def resolve_template(template_path, options={})
              template_path = template_path.to_s
              controller_key = respond_to?(:request) && request.respond_to?(:controller) && request.controller
              rendering_options = [template_path, content_type || :html, locale]
      
      
      Severity: Minor
      Found in padrino-helpers/lib/padrino/rendering.rb - About 55 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

      Method get_mongoid_models has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_mongoid_models
            documents = []
            Dir['{app,.}/models/**/*.rb'].sort.each do |file|
              model_path = file[0..-4].split('/')[2..-1]
      
      
      Severity: Minor
      Found in padrino-gen/lib/padrino-gen/padrino-tasks/mongoid.rb - About 55 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

      Method create_db has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def self.create_db(adapter, user, password, host, database, charset, collation)
      Severity: Major
      Found in padrino-gen/lib/padrino-gen/padrino-tasks/sql-helpers.rb - About 50 mins to fix

        Method except? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def except?(env)
              return false unless @except
              path_info = env['PATH_INFO']
              @except.is_a?(Proc) ? @except.call(env) : @except.any?{|path|
                path.is_a?(Regexp) ? path.match(path_info) : path == path_info }
        Severity: Minor
        Found in padrino-core/lib/padrino-core/application/authenticity_token.rb - About 45 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

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

              def setup
                Padrino::Generators.load_components!
        
                generator_kind  = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0] && !ARGV[0].empty?
                generator_class = Padrino::Generators.mappings[generator_kind]
        Severity: Minor
        Found in padrino-gen/lib/padrino-gen/generators/cli.rb - About 45 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

        Method with_layout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def with_layout(options)
                options = options.dup
                layout = options[:layout]
                return options if layout == false
        
        
        Severity: Minor
        Found in padrino-helpers/lib/padrino/rendering.rb - About 45 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

        Method map_onto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def map_onto(router)
              app_data = self
              app_obj = @app_obj
        
              uri_root             = app_data.uri_root
        Severity: Minor
        Found in padrino-core/lib/padrino-core/mounter.rb - About 45 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

        Method word_wrap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def word_wrap(text, *args)
                options = args.last.is_a?(Hash) ? args.pop : {}
                unless args.empty?
                  options[:line_width] = args[0] || 80
                end
        Severity: Minor
        Found in padrino-helpers/lib/padrino-helpers/format_helpers.rb - About 45 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

        Method output_model_migration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def output_model_migration(filename, name, columns, options={})
                  if behavior == :revoke
                    remove_migration(filename)
                  else
                    return if migration_exist?(filename)
        Severity: Minor
        Found in padrino-gen/lib/padrino-gen/generators/components/actions.rb - About 45 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

        Method number_with_precision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def number_with_precision(number, *args)
                options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}
        
                defaults           = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
                precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale],
        Severity: Minor
        Found in padrino-helpers/lib/padrino-helpers/number_helpers.rb - About 45 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