padrino/padrino-framework

View on GitHub

Showing 158 of 214 total issues

Method number_to_human_size has a Cognitive Complexity of 14 (exceeds 5 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

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 convert_ids has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_ids(obj)
      if obj.is_a?(String) && obj =~ /^[a-f0-9]{24}$/
        defined?(Moped) ? Moped::BSON::ObjectId.from_string(obj) : BSON::ObjectId(obj)
      elsif obj.is_a?(Array)
        obj.map do |v|
Severity: Minor
Found in padrino-gen/lib/padrino-gen/padrino-tasks/mongoid.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

Consider simplifying this complex logical expression.
Open

if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
  namespace :dm do
    namespace :auto do
      desc "Perform auto migration (reset your db data)"
      task :migrate => :environment do
Severity: Critical
Found in padrino-gen/lib/padrino-gen/padrino-tasks/datamapper.rb - About 1 hr to fix

    Method distance_of_time_in_words has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
            from_time = from_time.to_time if from_time.respond_to?(:to_time)
            to_time = to_time.to_time if to_time.respond_to?(:to_time)
            distance_in_minutes = (((to_time.to_i - from_time.to_i).abs)/60).round
            distance_in_seconds = ((to_time.to_i - from_time.to_i).abs).round
    Severity: Minor
    Found in padrino-helpers/lib/padrino-helpers/format_helpers.rb - About 1 hr to fix

      Method setup_test_files has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def setup_test_files
              if options[:tiny] && @_components[:test] != :none
                test_component = @_components[:test]
                test_component = "rspec" if test_component == "cucumber"
                uppercase_test_component = test_component.upcase
      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 setup_orm has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def setup_orm
        dm = DM
        db = @project_name.underscore
        %w(
          dm-core

        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

            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

                      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

                        Severity
                        Category
                        Status
                        Source
                        Language