padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

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

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

    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 padrino_route_added has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def padrino_route_added(route, verb, path, args, options, block)
    Severity: Minor
    Found in padrino-cache/lib/padrino-cache.rb - About 45 mins to fix

      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=nil, data=nil, options={}, locals={}, &block)
          Severity: Minor
          Found in padrino-mailer/lib/padrino-mailer/ext.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 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 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 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 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 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 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 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 detect_application has a Cognitive Complexity of 7 (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 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 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

                      Severity
                      Category
                      Status
                      Source
                      Language