Applicat/rails_info

View on GitHub

Showing 50 of 52 total issues

Method table has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def table
    outer_html = ''
    
    unless @line_numbers.include?(@line_number)
      outer_html = content_tag(:p) do 
Severity: Minor
Found in app/presenters/rails_info/code_presenter.rb - About 3 hrs 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 nested_resource_presenter_renderer has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def nested_resource_presenter_renderer(presenter, parent_id = '')
    tabs_for do |tab|
      presenter.each do |title,resource_presenter|  
        id = parent_id.blank? ? title.parameterize : "#{parent_id}-#{title.parameterize}"
        tab_title = resource_presenter[:group_by] ? "#{title} (Group by: #{resource_presenter[:group_by]})" : title    
Severity: Minor
Found in app/helpers/rails_info/resources_helper.rb - About 3 hrs 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 code_with_line_numbers has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

 def code_with_line_numbers(options = {})
    options.assert_valid_keys(:file, :number)
    
    middle_number = options[:number]
    
Severity: Minor
Found in lib/rails_info/stack_trace.rb - About 2 hrs 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 key_constant has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def key_constant(key, parent = '')
    key_was = key
    key_constant = nil
        
    begin
Severity: Minor
Found in lib/rails_info/model.rb - About 2 hrs 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 rails_info_field has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def rails_info_field(name, options = {})
    error = @filter.errors[name]
    hint = options.delete(:hint)
    
    content_tag :div, class: 'control-group' + (error ? ' error' : '') do
Severity: Minor
Found in app/helpers/rails_info/form_helper.rb - About 2 hrs 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 files_by_category has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def files_by_category
    return {} unless valid?
    
    return @files_by_category if @files_by_category
    
Severity: Minor
Found in app/models/version_control/filter.rb - About 2 hrs 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 accordion has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def accordion(type = 'full')
    content_tag :div, class: 'accordions' do
      html = ''
      
      hash = if type == 'application' 
Severity: Minor
Found in app/presenters/rails_info/stack_trace_presenter.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 resource_columns has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def resource_columns(collection, group_by = nil)
    collection_columns = []
    
    if collection.first.is_a?(Array)
      raise "Please wrap the :collection by help.collection_map: #{collection.inspect}"
Severity: Minor
Found in app/helpers/rails_info/resources_helper.rb - About 1 hr to fix

    Method key_constant has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def key_constant(key, parent = '')
        key_was = key
        key_constant = nil
            
        begin
    Severity: Minor
    Found in lib/rails_info/model.rb - About 1 hr to fix

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

        def resource_columns(collection, group_by = nil)
          collection_columns = []
          
          if collection.first.is_a?(Array)
            raise "Please wrap the :collection by help.collection_map: #{collection.inspect}"
      Severity: Minor
      Found in app/helpers/rails_info/resources_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 process_line has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def process_line(line)
          return if line.blank?
          
          reset_log and return if line.match('Ctrl-C to shutdown server') && @start_after_last_shutdown
          
      Severity: Minor
      Found in lib/rails_info/logs/server.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 code_with_line_numbers has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

       def code_with_line_numbers(options = {})
          options.assert_valid_keys(:file, :number)
          
          middle_number = options[:number]
          
      Severity: Minor
      Found in lib/rails_info/stack_trace.rb - About 1 hr to fix

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

          def add_commit_to_files(commit)
            @previous_revision = nil
            
            return if filter_merges && commit.message.match(/^Merge branch /)
            
        Severity: Minor
        Found in app/models/version_control/filter.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 list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def list
            models = {}
            
            classes.each do |klass| 
              ar_ancestors = active_record_ancestors(klass)
        Severity: Minor
        Found in lib/rails_info/model.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 path.blank? && author.blank? && id.blank? && message.blank? && story.blank? && tasks.blank? && from.blank? && to.blank?
              @errors['base'] = 'set at least one of these: path, author, id, message, story, tasks, from, to'
            end
        Severity: Critical
        Found in app/models/version_control/filter.rb - About 1 hr to fix

          Method table has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def table
              outer_html = ''
              
              unless @line_numbers.include?(@line_number)
                outer_html = content_tag(:p) do 
          Severity: Minor
          Found in app/presenters/rails_info/code_presenter.rb - About 1 hr to fix

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

              def resource_cell(row, column)
                if row.is_a?(Hash)
                  return "" unless row.has_key?(column)
                  
                  content = row[column].to_s
            Severity: Minor
            Found in app/helpers/rails_info/resources_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 associations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def associations(key_constant, options = { parent: ''})
                options.assert_valid_keys(:parent)
                
                key_constant = key_constant(key_constant, options[:parent]) if key_constant.is_a?(String)
                 
            Severity: Minor
            Found in lib/rails_info/model.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 accordion has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def accordion
                routes = request.env['action_dispatch.routes'].routes.map do |route|
                  {
                    source: (route.verb.respond_to?(:source) ? route.verb.source : route.verb).gsub(/[$^]/, ''),
                    spec: route.path.respond_to?(:spec) ? route.path.spec.to_s : route.path,
            Severity: Minor
            Found in app/presenters/rails_info/routes_presenter.rb - About 1 hr to fix

              Method files_by_category has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def files_by_category
                  return {} unless valid?
                  
                  return @files_by_category if @files_by_category
                  
              Severity: Minor
              Found in app/models/version_control/filter.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language