padrino/padrino-framework

View on GitHub

Showing 214 of 214 total issues

Function applyPlacement has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Tooltip.prototype.applyPlacement = function (offset, placement) {
    var replace
    var $tip   = this.tip()
    var width  = $tip[0].offsetWidth
    var height = $tip[0].offsetHeight

    Method setup_components has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def setup_components
            self.destination_root = options[:root]
            if in_app_root?
              @_components = options.class.new options.select{ |key,_| self.class.component_types.include?(key.to_sym) }
              @app_name = (options[:app] || "App").gsub(/\W/, '_').camelize
    Severity: Minor
    Found in padrino-gen/lib/padrino-gen/generators/component.rb - About 1 hr to fix

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

            $.support.transition && this.$tip.hasClass('fade') ?
              $tip
                .one($.support.transition.end, complete)
                .emulateTransitionEnd(150) :
              complete()
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 284..288

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

      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

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

          $.support.transition && this.$tip.hasClass('fade') ?
            $tip
              .one($.support.transition.end, complete)
              .emulateTransitionEnd(150) :
            complete()
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 188..192

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

      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_orm has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def setup_orm
        ar = MR
        db = @project_name.underscore
      
        begin

        Method params_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def params_for(pattern, others)
                data = match(pattern)
                params = indifferent_hash
                if data.names.empty?
                  params.merge!(:captures => data.captures) unless data.captures.empty?
        Severity: Minor
        Found in padrino-core/lib/padrino-core/path_router/matcher.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 tag_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def tag_attributes(options)
                return '' unless options
                options.inject('') do |all,(key,value)|
                  next all unless value
                  all << ' ' if all.empty?
        Severity: Minor
        Found in padrino-helpers/lib/padrino-helpers/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 object_sources has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def object_sources(target)
              sources = Set.new
              target.methods.each do |method_name|
                next unless method_name.kind_of?(Symbol)
                method_object = target.method(method_name)
        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 named_routes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def named_routes
              return [] unless app_obj.respond_to?(:routes)
        
              app_obj.routes.map { |route|
                request_method = route.request_methods.first
        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 setup_orm has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def setup_orm
          sequel = SEQUEL
          db = @project_name.underscore
          require_dependencies 'sequel'
        
        
        Severity: Minor
        Found in padrino-gen/lib/padrino-gen/generators/components/orms/sequel.rb - About 1 hr to fix

          Method setup_orm has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def setup_orm
            ar = AR
            db = @project_name.underscore
          
            begin

            Method create_app has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def create_app
                    self.destination_root = options[:root]
                    underscore_name = name.gsub(/\W/, '_')
                    @app_folder = underscore_name.underscore
                    @app_name   = underscore_name.camelize
            Severity: Minor
            Found in padrino-gen/lib/padrino-gen/generators/app.rb - About 1 hr to fix

              Method setup_project has 33 lines of code (exceeds 25 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

                Similar blocks of code found in 3 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}, #{kind.underscore.camelize}" }.join("\n  ")
                  model_contents = RIPPLE_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
                padrino-gen/lib/padrino-gen/generators/components/orms/mongoid.rb on lines 79..85
                padrino-gen/lib/padrino-gen/generators/components/orms/mongomapper.rb on lines 29..35

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

                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 3 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}, :type => #{kind.underscore.camelize}" }.join("\n  ")
                  model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
                padrino-gen/lib/padrino-gen/generators/components/orms/mongomapper.rb on lines 29..35
                padrino-gen/lib/padrino-gen/generators/components/orms/ripple.rb on lines 60..66

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

                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 3 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| "key :#{field}, #{kind.underscore.camelize}" }.join("\n  ")
                  model_contents = MM_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
                padrino-gen/lib/padrino-gen/generators/components/orms/mongoid.rb on lines 79..85
                padrino-gen/lib/padrino-gen/generators/components/orms/ripple.rb on lines 60..66

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

                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 number_to_human_size has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def number_to_human_size(number, *args)
                        return nil if number.nil?
                
                        options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}
                
                
                Severity: Minor
                Found in padrino-helpers/lib/padrino-helpers/number_helpers.rb - About 1 hr to fix

                  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

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

                        def construct_filter(*args, &block)
                          options = args.last.is_a?(Hash) ? args.pop : {}
                          if except = options.delete(:except)
                            fail "You cannot use :except with other options specified" unless args.empty? && options.empty?
                            except = Array(except)
                  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 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

                  Severity
                  Category
                  Status
                  Source
                  Language