padrino/padrino-framework

View on GitHub

Showing 157 of 211 total issues

Method resolve_checked_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def resolve_checked_values(field, options)
          selected_values = Array(options[:selected] || field_value(field))
          if options[:collection]
            _, id_method = *field_methods(options)
            selected_values.map do |value|

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

      def rebase_url(url)
        if url.start_with?('/')
          new_url = ''
          new_url << conform_uri(ENV['RACK_BASE_URI']) if ENV['RACK_BASE_URI']
          new_url << conform_uri(uri_root) if defined?(uri_root)
Severity: Minor
Found in padrino-core/lib/padrino-core/application/routing.rb - About 35 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 button_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def button_to(*args, &block)
        options = args.last.is_a?(Hash) ? args.pop : {}
        name, url = *args
        options['data-remote'] = 'true' if options.delete(:remote)
        submit_options = options.delete(:submit_options) || {}
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/form_helpers.rb - About 35 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_migration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def create_migration
        validate_namespace name
        self.destination_root = options[:root]
        if in_app_root?
          self.behavior = :revoke if options[:destroy]
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/migration.rb - About 35 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 load_boot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def load_boot
        begin
          ENV['PADRINO_LOG_LEVEL'] ||= 'test'
          ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root]
          boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/cli.rb - About 35 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 execute_runner has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def execute_runner(kind, template_file)
        # Determine resolved template path
        template_file = template_file.to_s
        template_path = case
          when template_file =~ %r{^https?://} && template_file !~ /gist/
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/runner.rb - About 35 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 expand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def expand(params)
        params = @default_values.merge(params) if @default_values.is_a?(Hash)
        params, query = params.each_with_object([{}, {}]) do |(key, val), parts|
          parts[handler.names.include?(key.to_s) ? 0 : 1][key] = val
        end
Severity: Minor
Found in padrino-core/lib/padrino-core/path_router/matcher.rb - About 25 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 provides_format? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def provides_format?(types, format)
        if ([:any, format] & types).empty?
          # Per rfc2616-sec14:
          # Answer with 406 if accept is given but types to not match any provided type.
          halt 406 if settings.respond_to?(:treat_format_as_accept) && settings.treat_format_as_accept
Severity: Minor
Found in padrino-core/lib/padrino-core/application/routing.rb - About 25 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 already_exists? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def already_exists?(name, project_name = nil)
        project_name = project_name ? (Object.const_get(project_name) rescue nil) : nil
        Object.const_defined?(name) || (project_name && project_name.const_defined?(name))
      end
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/actions.rb - About 25 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_mailer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def create_mailer
        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/mailer.rb - About 25 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 prepare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def prepare(task)
        if options.help?
          help(task.to_s)
          exit
        end
Severity: Minor
Found in padrino-core/lib/padrino-core/cli/launcher.rb - About 25 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_delimiter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def number_with_delimiter(number, *args)
        options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}

        defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}

Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/number_helpers.rb - About 25 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 ensure_rendering_engine has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def ensure_rendering_engine(engine)
        return true if settings.respond_to?(engine)
        return nil unless engine == :erb
        require 'erb'
      rescue LoadError
Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.rb - About 25 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 list_app_routes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def list_app_routes(app, args)
  app_routes = app.named_routes
  app_routes.reject! { |r| r.identifier.to_s !~ /#{args.query}/ } if args.query && !args.query.empty?
  app_routes.map! { |r| [r.verb, r.name, r.path] }
  return if app_routes.empty?
Severity: Minor
Found in padrino-core/lib/padrino-core/cli/rake_tasks.rb - About 25 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 deep_dup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def deep_dup(object)
      case object
      when Array
        object.map{ |value| deep_dup(value) }
      when Hash
Severity: Minor
Found in padrino-support/lib/padrino-support/utils.rb - About 25 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_to_currency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def number_to_currency(number, options = {})
        options = Utils.symbolize_keys(options)

        defaults  = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
        currency  = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {}
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/number_helpers.rb - About 25 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 registered has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def registered(app)
          app.register Padrino::Admin unless app.extensions.include?(Padrino::Admin)
          app.set :session_id, "_padrino_#{Padrino.env}_#{app.app_name}" unless app.respond_to?(:session_id)
          app.set :admin_model, 'Account' unless app.respond_to?(:admin_model)
          app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
Severity: Minor
Found in padrino-admin/lib/padrino-admin/access_control.rb - About 25 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 included has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.included(base)
        unless base.instance_methods.include?(:render) || base.private_instance_methods.include?(:render)
          base.class_eval do
            fail "gem 'tilt' is required" unless defined?(::Tilt)

Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/render_helpers.rb - About 25 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 fetch_layout_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def fetch_layout_path(given_layout, layouts_path=views)
        layout_name = (given_layout || @layout || :application).to_s
        cache_layout_path(layout_name) do
          if Pathname.new(layout_name).absolute? && Dir["#{layout_name}.*"].any? || Dir["#{layouts_path}/#{layout_name}.*"].any?
            layout_name
Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.rb - About 25 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 glob_templates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def glob_templates(views_path, template_path)
        parts = []
        parts << views_path if views_path
        if respond_to?(:request) && request.respond_to?(:controller) && request.controller && Pathname.new(template_path).relative?
          parts << "{,#{request.controller}}"
Severity: Minor
Found in padrino-helpers/lib/padrino/rendering.rb - About 25 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