padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

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 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 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

Avoid deeply nested control flow statements.
Open

            $stderr.puts "(if you set the charset manually, make sure you have a matching collation)" if config[:charset]
Severity: Major
Found in padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb - About 45 mins to fix

    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 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 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

    Consider simplifying this complex logical expression.
    Open

          if (autoPlace) {
            var $parent = this.$element.parent()
    
            var orgPlacement = placement
            var docScroll    = document.documentElement.scrollTop || document.body.scrollTop

      Consider simplifying this complex logical expression.
      Open

      if PadrinoTasks.load?(:sequel, defined?(Sequel))
        namespace :sq do
          namespace :migrate do
            desc "Perform automigration (reset your db data)"
            task :auto => :skeleton do
      Severity: Major
      Found in padrino-gen/lib/padrino-gen/padrino-tasks/sequel.rb - About 40 mins to fix

        Method render has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def render(engine, data=nil, options={}, locals={}, &block)
        Severity: Minor
        Found in padrino-helpers/lib/padrino/rendering.rb - About 35 mins to fix

          Method render_like_sinatra has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def render_like_sinatra(engine, data, options={}, locals={}, &block)
          Severity: Minor
          Found in padrino-helpers/lib/padrino/rendering.rb - About 35 mins to fix

            Method bench has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def bench(action, began_at, message, level=:debug, color=:yellow)
            Severity: Minor
            Found in padrino-core/lib/padrino-core/logger.rb - About 35 mins to fix

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def initialize(mode, scoped_controller, options, args, &block)
              Severity: Minor
              Found in padrino-core/lib/padrino-core/filter.rb - About 35 mins to fix

                Method render has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def render(engine=nil, data=nil, options={}, locals={}, &block)
                Severity: Minor
                Found in padrino-mailer/lib/padrino-mailer/ext.rb - About 35 mins to fix

                  Method drop_db has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def self.drop_db(adapter, user, password, host, database)
                  Severity: Minor
                  Found in padrino-gen/lib/padrino-gen/padrino-tasks/sql-helpers.rb - About 35 mins to fix

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

                        def singularize(s)
                          s = s.to_s
                          return s.singularize if s.respond_to?(:singularize)
                          result = s.dup
                          Inflections.singulars.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 move_as has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def move_as(type)
                        step = ENV['STEP'] ? ENV['STEP'].to_i : 1
                    
                        if less_than_active_record_5_2?
                          ActiveRecord::Migrator.send(type, 'db/migrate/', step)
                    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 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 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 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

                    Severity
                    Category
                    Status
                    Source
                    Language