padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

Method cache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def cache(key, opts = {}, &block)
          if settings.caching?
            began_at = Time.now
            if settings.cache.key?(key.to_s)
              value = settings.cache[key.to_s]
Severity: Minor
Found in padrino-cache/lib/padrino-cache/helpers/fragment.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 padrino_route_added has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def self.padrino_route_added(route, verb, *)
          return unless route.cache && CACHED_VERBS[verb]

          route.before_filters do
            next unless settings.caching?
Severity: Minor
Found in padrino-cache/lib/padrino-cache/helpers/page.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(name, options={})
      @name      = name.to_s
      @app_class = options[:app_class] || Inflections.camelize(@name)
      @gem       = options[:gem]       || Inflections.underscore(@app_class.split("::").first)
      @app_file  = options[:app_file]  || locate_app_file
Severity: Minor
Found in padrino-core/lib/padrino-core/mounter.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 cache_object has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def cache_object(key, opts = {})
          if settings.caching?
            began_at = Time.now
            if settings.cache.key?(key.to_s)
              value = settings.cache[key.to_s]
Severity: Minor
Found in padrino-cache/lib/padrino-cache/helpers/cache_object.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 show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Modal.prototype.show = function (_relatedTarget) {
    var that = this
    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })

    this.$element.trigger(e)

    Method create_controller has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def create_controller
            validate_namespace name
            self.destination_root = options[:root]
            if in_app_root?
              app = options[:app]
    Severity: Minor
    Found in padrino-gen/lib/padrino-gen/generators/controller.rb - About 1 hr to fix

      Function show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        Collapse.prototype.show = function () {
          if (this.transitioning || this.$element.hasClass('in')) return
      
          var startEvent = $.Event('show.bs.collapse')
          this.$element.trigger(startEvent)

        Method render_like_sinatra has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def render_like_sinatra(engine, data, options={}, locals={}, &block)
                # merge app-level options
                engine_options = settings.respond_to?(engine) ? settings.send(engine) : {}
                options = engine_options.merge(options)
        
        
        Severity: Minor
        Found in padrino-helpers/lib/padrino/rendering.rb - About 1 hr to fix

          Function backdrop has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            Modal.prototype.backdrop = function (callback) {
              var animate = this.$element.hasClass('fade') ? 'fade' : ''
          
              if (this.isShown && this.options.backdrop) {
                var doAnimate = $.support.transition && animate

            Function checkPosition has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              Affix.prototype.checkPosition = function () {
                if (!this.$element.is(':visible')) return
            
                var scrollHeight = $(document).height()
                var scrollTop    = this.$window.scrollTop()

              Method setup! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.setup!
                    config_level = (PADRINO_LOG_LEVEL || Padrino.env || :test).to_sym # need this for PADRINO_LOG_LEVEL
                    config = Config[config_level]
              
                    unless config
              Severity: Minor
              Found in padrino-core/lib/padrino-core/logger.rb - About 1 hr to fix

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

                      def setup_project
                        valid_constant? name
                        app = (options[:app] || "App")
                
                        @project_name = name.gsub(/\W/, '_').underscore.camelize
                Severity: Minor
                Found in padrino-gen/lib/padrino-gen/generators/project.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 create_controller has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def create_controller
                        self.destination_root = options[:root]
                        if in_app_root?
                          @app_name = fetch_app_name
                          @admin_name = options[:admin_name].classify
                Severity: Minor
                Found in padrino-admin/lib/padrino-admin/generators/admin_page.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 insert_into_gemfile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def insert_into_gemfile(name, options={})
                        after_pattern = options[:group] ? "#{options[:group].to_s.capitalize} requirements\n" : "Component requirements\n"
                        version       = options.delete(:version)
                        gem_options   = options.map { |k, v| k.to_s == 'require' && [true,false].include?(v) ? ":#{k} => #{v}" : ":#{k} => '#{v}'" }.join(", ")
                        write_option  = gem_options.empty? ? '' : ", #{gem_options}"
                Severity: Minor
                Found in padrino-gen/lib/padrino-gen/generators/actions.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 link_to has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def link_to(*args, &block)
                        options = args.last.is_a?(Hash) ? args.pop : {}
                        name = block_given? ? '' : args.shift
                        href = args.first
                        options = { :href => href ? escape_link(href) : '#' }.update(options)
                Severity: Minor
                Found in padrino-helpers/lib/padrino-helpers/asset_tag_helpers.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 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

                Severity
                Category
                Status
                Source
                Language