ucsdlib/damspas

View on GitHub
app/helpers/application_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method field_with_highlighting has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def field_with_highlighting document, field, sep=field_value_separator
  highlighting = blacklight_config.highlighting
  if !(field.is_a? Symbol) && !(field.is_a? String)
    options = field
    field = options[:'field']
Severity: Minor
Found in app/helpers/application_helper.rb - About 5 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 dateHelper has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  def dateHelper dates
    dateRet = ''
    c2 = false
    c3 = false
    c4 = false
Severity: Minor
Found in app/helpers/application_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 field_with_highlighting has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def field_with_highlighting document, field, sep=field_value_separator
  highlighting = blacklight_config.highlighting
  if !(field.is_a? Symbol) && !(field.is_a? String)
    options = field
    field = options[:'field']
Severity: Minor
Found in app/helpers/application_helper.rb - About 1 hr to fix

    Method dateHelper has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def dateHelper dates
        dateRet = ''
        c2 = false
        c3 = false
        c4 = false
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

            elsif !c2 && !c3 && !c4
              if date['value']
                dateRet = date['value']
              else
                dateRet = date['beginDate']
      Severity: Major
      Found in app/helpers/application_helper.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if date['value']
                  dateRet = date['value']
                else
                  dateRet = date['beginDate']
                end
        Severity: Major
        Found in app/helpers/application_helper.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    if values[i].eql? vo
                      values[i] = v
                      break
                    end
          Severity: Major
          Found in app/helpers/application_helper.rb - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                    return highlight_values.join(sep).html_safe
            Severity: Major
            Found in app/helpers/application_helper.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return highlight_values.join(sep).html_safe
              Severity: Major
              Found in app/helpers/application_helper.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return values.map { |v|v }.join(sep).html_safe
                Severity: Major
                Found in app/helpers/application_helper.rb - About 30 mins to fix

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

                    def to_stats_path (path)
                      if !path.blank? && !session[:user_id].blank?
                        path += path.index('?').nil? ? '?' : '&'
                        path + 'access=curator'
                      else
                  Severity: Minor
                  Found in app/helpers/application_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

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

                    def parseJsonDate jsonString, sep
                    datehash = JSON.parse jsonString
                    dates = Array.new
                    dates << datehash['value'] unless datehash['value']==nil?
                    dates << datehash['beginDate'] unless datehash['beginDate']==nil?
                  Severity: Minor
                  Found in app/helpers/application_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

                  There are no issues that match your filters.

                  Category
                  Status