padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

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

        def error_html_attributes(options)
          [:id, :class, :style].each_with_object({}) do |key,all|
            if options.include?(key)
              value = options[key]
              all[key] = value if value
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/form_helpers/errors.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 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 registered has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def registered(app)
        app.helpers Padrino::Cache::Helpers::ObjectCache
        app.helpers Padrino::Cache::Helpers::CacheStore
        app.helpers Padrino::Cache::Helpers::Fragment
        app.helpers Padrino::Cache::Helpers::Page
Severity: Minor
Found in padrino-cache/lib/padrino-cache.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 allowed? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def allowed?(account=nil, path=nil)
          path = "/" if path.nil? || path.empty?
          role = account.role.to_sym rescue nil
          authorizations = @authorizations.find_all { |auth| auth.roles.include?(:any) }
          allowed_paths  = authorizations.map(&:allowed).flatten.uniq
Severity: Minor
Found in padrino-admin/lib/padrino-admin/access_control.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 pluralize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def pluralize(s)
      s = s.to_s
      return s.pluralize if s.respond_to?(:pluralize)
      result = s.dup
      Inflections.plurals.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
Severity: Minor
Found in padrino-support/lib/padrino-support/inflections.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 migrate_as has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def migrate_as(type)
    version = env_migration_version
    fail "MIGRATION_VERSION is required" unless version

    if less_than_active_record_5_2?
Severity: Minor
Found in padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.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 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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def render(engine, data=nil, options={}, locals={}, &block)
        # If engine is nil, ignore engine parameter and shift up all arguments
        # render nil, "index", { :layout => true }, { :localvar => "foo" }
        engine, data, options = data, options, locals if engine.nil? && data

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

      def process_path_for_parent_params(path, parent_params)
        parent_prefix = parent_params.flatten.compact.uniq.map do |param|
          map  = (param.respond_to?(:map) && param.map ? param.map : param.to_s)
          part = "#{map}/:#{Inflections.singularize(param)}_id/"
          part = "(#{part})?" if param.respond_to?(:optional) && param.optional?
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 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 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 map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def map(options={})
      path = options[:path] || "/"
      host = options[:host]
      app  = options[:to]

Severity: Minor
Found in padrino-core/lib/padrino-core/router.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 grouped_options_for_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def grouped_options_for_select(collection, state = {})
          collection.map do |item|
            caption = item.shift
            attributes = item.last.kind_of?(Hash) ? item.pop : {}
            value = item.flatten(1)
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/form_helpers/options.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 to_proc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def to_proc
      if @args.empty? && @options.empty?
        block
      else
        filter = self
Severity: Minor
Found in padrino-core/lib/padrino-core/filter.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 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 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 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 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

Severity
Category
Status
Source
Language