padrino/padrino-framework

View on GitHub

Showing 170 of 214 total issues

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

      def content_tag(name, content = nil, options = nil, &block)
        if block_given?
          options = content if content.is_a?(Hash)
          content = capture_html(&block)
        end
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/tag_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 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 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

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

      def cache_template_path(options)
        began_at = Time.now
        @_cached_templates ||= {}
        logging = defined?(settings) && settings.logging? && defined?(logger)
        if !reload_templates? && path = @_cached_templates[options]
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 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 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 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 path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def path(name, *args)
        params = args.last.is_a?(Hash) ? args.pop : {}
        candidates = @routes.select { |route| route.name == name }
        fail InvalidRouteException if candidates.empty?
        i = 0
Severity: Minor
Found in padrino-core/lib/padrino-core/path_router.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 detect_application has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.detect_application(options)
    default_config_file = 'config.ru'
    if (config_file = options.delete(:config)) || File.file?(default_config_file)
      config_file ||= default_config_file
      fail "Rack config file `#{config_file}` must have `.ru` extension" unless config_file =~ /\.ru$/
Severity: Minor
Found in padrino-core/lib/padrino-core/server.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 valid_model_for? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def valid_model_for?(app)
        self.destination_root = options[:root]
        return false unless correct_path?

        check_app_existence(app)
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/model.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