padrino/padrino-framework

View on GitHub

Showing 214 of 214 total issues

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

    def safe_load(file, options={})
      began_at = Time.now
      file     = figure_path(file)
      return unless options[:force] || file_changed?(file)
      return require(file) if feature_excluded?(file)
Severity: Minor
Found in padrino-core/lib/padrino-core/reloader.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 value_to_param has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def value_to_param(object)
        case object
        when Array
          object.map { |item| value_to_param(item) }.compact
        when Hash
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 rollback has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def rollback(name)
        new_classes(@old_entries[name][:constants]).each do |klass|
          loaded_in_name = files.each do |file, data|
                             next if file == name
                             break if data[:constants].include?(klass)
Severity: Minor
Found in padrino-core/lib/padrino-core/reloader/storage.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 replace_with_binstub has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def self.replace_with_binstub(executable)
    begin
      return if Bundler.definition.missing_specs.empty?
    rescue NameError, NoMethodError, Bundler::GemfileNotFound
    end
Severity: Minor
Found in padrino-core/lib/padrino-core/cli/binstub.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 env_migration_version has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def env_migration_version
  version = ENV["MIGRATION_VERSION"]
  if version.nil? && ENV["VERSION"]
    deprecated = true
    warn "Environment variable VERSION is deprecated, use MIGRATION_VERSION"
Severity: Minor
Found in padrino-core/lib/padrino-core/cli/rake_tasks.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 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        Popover.prototype.arrow = function () {
          return this.$arrow = this.$arrow || this.tip().find('.arrow')
        }
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 336..338

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 54.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        Tooltip.prototype.arrow = function () {
          return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
        }
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/popover.js on lines 72..74

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 54.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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 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
        Severity
        Category
        Status
        Source
        Language