SpeciesFileGroup/taxonworks

View on GitHub
app/helpers/tasks/gis/report_helper.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method has too many lines. [59/25]
Open

  def all_sub_headers(filtered = false)
    unless filtered
      ce_headers # generate the header structure (see CollectionObject.selected_column_names)
      co_headers
      bc_headers

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method all_sub_headers has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def all_sub_headers(filtered = false)
    unless filtered
      ce_headers # generate the header structure (see CollectionObject.selected_column_names)
      co_headers
      bc_headers
Severity: Minor
Found in app/helpers/tasks/gis/report_helper.rb - About 4 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 all_sub_headers has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def all_sub_headers(filtered = false)
    unless filtered
      ce_headers # generate the header structure (see CollectionObject.selected_column_names)
      co_headers
      bc_headers
Severity: Major
Found in app/helpers/tasks/gis/report_helper.rb - About 2 hrs to fix

    Method selected_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def selected_headers
        retval = []
        %w(ce co bc).each { |column|
          group = @selected_column_names[column.to_sym]
          group.each_key { |type|
    Severity: Minor
    Found in app/helpers/tasks/gis/report_helper.rb - About 35 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 count_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def count_info(count)
        term = 'Collection object'
        if count < 25
          if count == 0
            retval = "No #{term}s"
    Severity: Minor
    Found in app/helpers/tasks/gis/report_helper.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

    Do not use instance variables in helpers.
    Open

          unless @selected_column_names[column_type.to_sym][:im].nil?

    Do not use instance variables in helpers.
    Open

        CollectionObject.ce_attributes(collection_object, @selected_column_names)

    Do not use instance variables in helpers.
    Open

          @c_o_table_store.set(table_string, @c_o_table_data.to_json)

    Do not use instance variables in helpers.
    Open

        if @list_collection_objects.any?

    Do not use instance variables in helpers.
    Open

          page_entries_info(@list_collection_objects)

    Do not use instance variables in helpers.
    Open

        @c_o_table_store = Redis.new

    Do not use instance variables in helpers.
    Open

          group = @selected_column_names[column.to_sym]

    Do not use instance variables in helpers.
    Open

            unless @selected_column_names[column_type.to_sym][:im].keys.empty?

    Do not use instance variables in helpers.
    Open

          @c_o_table_store = nil

    Do not use instance variables in helpers.
    Open

                stage       = @selected_column_names[col_type.to_sym][sub_type.to_sym][item]

    Do not use instance variables in helpers.
    Open

        @c_o_table_data.count

    Do not use instance variables in helpers.
    Open

            items.push(@selected_column_names[column_type.to_sym][:in].keys)

    Do not use instance variables in helpers.
    Open

        if @list_collection_objects.any?

    Do not use instance variables in helpers.
    Open

          paginate(@list_collection_objects, remote: true)

    Do not use instance variables in helpers.
    Open

        CollectionObject.bc_attributes(collection_object, @selected_column_names)

    Do not use instance variables in helpers.
    Open

              items.push(@selected_column_names[column_type.to_sym][:im].keys) # stuff the headers for the import

    Do not use instance variables in helpers.
    Open

        @c_o_table_data  = {}

    Do not use instance variables in helpers.
    Open

        } unless @selected_column_names.nil?

    Do not use instance variables in helpers.
    Open

          @c_o_table_store.ping

    Do not use instance variables in helpers.
    Open

        @c_o_table_data[c_o.id.to_s] = retval

    Do not use instance variables in helpers.
    Open

          unless @selected_column_names[column_type.to_sym][:in].nil?

    Do not use instance variables in helpers.
    Open

        @selected_column_names = CollectionObject.ce_headers(sessions_current_project_id)

    Do not use instance variables in helpers.
    Open

        @c_o_table_store

    Do not use instance variables in helpers.
    Open

        unless @c_o_table_store.nil?

    Do not use instance variables in helpers.
    Open

          @c_o_table_store.set(table_string, @c_o_table_data.to_json)

    Do not use instance variables in helpers.
    Open

        @selected_column_names = CollectionObject.co_headers(sessions_current_project_id)

    Do not use instance variables in helpers.
    Open

        CollectionObject.co_attributes(collection_object, @selected_column_names)

    Do not use instance variables in helpers.
    Open

        @selected_column_names = CollectionObject.bc_headers(sessions_current_project_id)

    There are no issues that match your filters.

    Category
    Status