padrino/padrino-framework

View on GitHub

Showing 214 of 214 total issues

Method except? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def except?(env)
      return false unless @except
      path_info = env['PATH_INFO']
      @except.is_a?(Proc) ? @except.call(env) : @except.any?{|path|
        path.is_a?(Regexp) ? path.match(path_info) : path == path_info }
Severity: Minor
Found in padrino-core/lib/padrino-core/application/authenticity_token.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 setup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def setup
        Padrino::Generators.load_components!

        generator_kind  = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0] && !ARGV[0].empty?
        generator_class = Padrino::Generators.mappings[generator_kind]
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/cli.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 with_layout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def with_layout(options)
        options = options.dup
        layout = options[:layout]
        return options if layout == false

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

Method map_onto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def map_onto(router)
      app_data = self
      app_obj = @app_obj

      uri_root             = app_data.uri_root
Severity: Minor
Found in padrino-core/lib/padrino-core/mounter.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 word_wrap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def word_wrap(text, *args)
        options = args.last.is_a?(Hash) ? args.pop : {}
        unless args.empty?
          options[:line_width] = args[0] || 80
        end
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/format_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 output_model_migration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def output_model_migration(filename, name, columns, options={})
          if behavior == :revoke
            remove_migration(filename)
          else
            return if migration_exist?(filename)
Severity: Minor
Found in padrino-gen/lib/padrino-gen/generators/components/actions.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 number_with_precision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def number_with_precision(number, *args)
        options = args.last.is_a?(Hash) ? Utils.symbolize_keys(args.pop) : {}

        defaults           = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
        precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale],
Severity: Minor
Found in padrino-helpers/lib/padrino-helpers/number_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 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

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

              this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 57..57

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

      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

              this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 58..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 50.

      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

          return $e.attr('data-content')
            || (typeof o.content == 'function' ?
                  o.content.call($e[0]) :
                  o.content)
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js on lines 326..327

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

      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

          title = $e.attr('data-original-title')
            || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
      padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/popover.js on lines 66..69

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

      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

      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

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

            $.fn.tab.noConflict = function () {
              $.fn.tab = old
              return this
            }
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/affix.js on lines 114..117
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/alert.js on lines 77..80
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/button.js on lines 91..94
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/carousel.js on lines 173..176
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/collapse.js on lines 142..145
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/dropdown.js on lines 132..135
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/modal.js on lines 215..218
          padrino-admin/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/scrollspy.js on lines 137..140

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

          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

          Severity
          Category
          Status
          Source
          Language