antulik/pagelet_rails

View on GitHub

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

          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