redmine/redmine

View on GitHub
app/helpers/search_helper.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

  def highlight_tokens(text, tokens)
    return text unless text && tokens && !tokens.empty?

    re_tokens = tokens.collect {|t| Regexp.escape(t)}
    regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
Severity: Minor
Found in app/helpers/search_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 issues_filter_path has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def issues_filter_path(question, options)
    projects_scope = options[:projects_scope]
    titles_only = options[:titles_only]
    all_words = options[:all_words]
    open_issues = options[:open_issues]
Severity: Minor
Found in app/helpers/search_helper.rb - About 1 hr to fix

    Method project_select_tag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def project_select_tag
        options = [[l(:label_project_all), 'all']]
        options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty?
        options << [l(:label_my_bookmarks), 'bookmarks'] unless User.current.bookmarked_project_ids.empty?
        options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.descendants.active.empty?
    Severity: Minor
    Found in app/helpers/search_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 issues_filter_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def issues_filter_path(question, options)
        projects_scope = options[:projects_scope]
        titles_only = options[:titles_only]
        all_words = options[:all_words]
        open_issues = options[:open_issues]
    Severity: Minor
    Found in app/helpers/search_helper.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

    There are no issues that match your filters.

    Category
    Status