padrino/padrino-framework

View on GitHub

Showing 214 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 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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(options={})
      @buffer           = []
      @auto_flush       = options.has_key?(:auto_flush) ? options[:auto_flush] : true
      @level            = options[:log_level] ? Padrino::Logger::Levels[options[:log_level]] : Padrino::Logger::Levels[:debug]
      @log              = options[:stream]  || $stdout
Severity: Minor
Found in padrino-core/lib/padrino-core/logger.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 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 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 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

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

          def create_model_file(name, options={})
            model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
            field_tuples = options[:fields].map { |value| value.split(":") }
            column_declarations = field_tuples.map { |field, kind| "field :#{field}, :as => :#{kind}" }.join("\n  ")
            model_contents = MR_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
          padrino-gen/lib/padrino-gen/generators/components/orms/dynamoid.rb on lines 52..58

          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

          def create_model_file(name, options={})
            model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
            field_tuples = options[:fields].map { |value| value.split(":") }
            column_declarations = field_tuples.map { |field, kind| "field :#{field}, :#{kind}" }.join("\n  ")
            model_contents = DYNAMOID_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
          padrino-gen/lib/padrino-gen/generators/components/orms/minirecord.rb on lines 160..166

          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

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

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

              module Padrino
                module Rendering
                  class SlimOutputBuffer < Temple::Generators::StringBuffer
                    define_options :buffer_class => 'SafeBuffer'
              
              
              Severity: Major
              Found in padrino-helpers/lib/padrino/rendering/slim_template.rb and 1 other location - About 1 hr to fix
              padrino-helpers/lib/padrino/rendering/hamlit_template.rb on lines 1..24

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

              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

              module Padrino
                module Rendering
                  class HamlitOutputBuffer < Temple::Generators::StringBuffer
                    define_options :buffer_class => 'SafeBuffer'
              
              
              Severity: Major
              Found in padrino-helpers/lib/padrino/rendering/hamlit_template.rb and 1 other location - About 1 hr to fix
              padrino-helpers/lib/padrino/rendering/slim_template.rb on lines 1..24

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

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

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

                def create_model_file(name, options={})
                  model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
                  field_tuples = options[:fields].map { |value| value.split(":") }
                  column_declarations = field_tuples.map { |field, kind| "property :#{field}" }.join("\n  ")
                  model_contents = CR_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
                padrino-gen/lib/padrino-gen/generators/components/orms/ohm.rb on lines 50..56

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

                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

                def create_model_file(name, options={})
                    model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
                    field_tuples = options[:fields].map { |value| value.split(":") }
                    column_declarations = field_tuples.map { |field, kind| "attribute :#{field}" }.join("\n  ")
                    model_contents = OHM_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
                padrino-gen/lib/padrino-gen/generators/components/orms/couchrest.rb on lines 40..46

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

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

                Severity
                Category
                Status
                Source
                Language