antulik/pagelet_rails

View on GitHub

Showing 12 of 12 total issues

Method pagelet has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def pagelet path, p_options = {}
    Rails.logger.info "Rendering pagelet #{path}"

    p_params = p_options.delete(:params) { {} }.with_indifferent_access

Severity: Major
Found in app/helpers/pagelets_helper.rb - About 2 hrs to fix

    Method pagelet has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def pagelet path, p_options = {}
        Rails.logger.info "Rendering pagelet #{path}"
    
        p_params = p_options.delete(:params) { {} }.with_indifferent_access
    
    
    Severity: Minor
    Found in app/helpers/pagelets_helper.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 pagelet_cache has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def pagelet_cache &block
        # puts 'pagelet_cache'.blue
        cache_enabled = pagelet_options.cache || pagelet_options.cache_path || pagelet_options.expires_in
    
        if !cache_enabled
    Severity: Minor
    Found in lib/pagelet_rails/concerns/cache.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 around has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def around(controller)
              cache_layout = @cache_layout.respond_to?(:call) ? @cache_layout.call(controller) : @cache_layout
    
              path_options = if @cache_path.is_a?(Proc)
                controller.instance_exec(controller, &@cache_path)
    Severity: Minor
    Found in lib/action_controller/caching/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

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

      root.processDataRemoteTags = function() {
        $('form[data-remote]').each(function(index, elem){
          var $el = $(elem);
          var container = $el.closest('[data-pagelet-container]');
    
    
    Severity: Minor
    Found in app/assets/javascripts/pagelet_rails.js - About 1 hr to fix

      Method pagelet_cache has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def pagelet_cache &block
          # puts 'pagelet_cache'.blue
          cache_enabled = pagelet_options.cache || pagelet_options.cache_path || pagelet_options.expires_in
      
          if !cache_enabled
      Severity: Minor
      Found in lib/pagelet_rails/concerns/cache.rb - About 1 hr to fix

        Function loadPagelets has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          root.loadPagelets = function(selector) {
            selector = selector || '[data-pagelet-load]';
            var groups = {};
        
            $(selector).each(function(index, elem) {
        Severity: Minor
        Found in app/assets/javascripts/pagelet_rails.js - About 1 hr to fix

          Method render_remote_load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def render_remote_load
              # puts 'render_remote_load'.blue
              render_remotely = pagelet_render_remotely?
              if render_remotely && pagelet_options.has_cache
                render_remotely = false
          Severity: Minor
          Found in lib/pagelet_rails/concerns/placeholder.rb - About 55 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

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

                if (!hidden_field) {
                  $("<input/>", {
                    name: "target_container",
                    type: "hidden",
                    value: container.attr('id')
          Severity: Minor
          Found in app/assets/javascripts/pagelet_rails.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/pagelet_rails.js on lines 156..162

          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

                if (!hidden_field) {
                  $("<input/>", {
                    name: "original_pagelet_options",
                    type: "hidden",
                    value: container.data('pagelet-options')
          Severity: Minor
          Found in app/assets/javascripts/pagelet_rails.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/pagelet_rails.js on lines 147..153

          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

          Method process_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def process_action *args
              super.tap do
                if params[:target_container] &&
                  action_has_layout? &&
                  request.format.js? # wrap to js only if requested js
          Severity: Minor
          Found in lib/pagelet_rails/concerns/response_wrapper.rb - About 25 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 expire_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def expire_action(options = {})
                  return unless cache_configured?
          
                  if options.is_a?(Hash) && options[:action].is_a?(Array)
                    options[:action].each { |action| expire_action(options.merge(action: action)) }
          Severity: Minor
          Found in lib/action_controller/caching/actions.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language