redmine/redmine

View on GitHub
app/helpers/application_helper.rb

Summary

Maintainability
F
2 wks
Test Coverage

Method parse_redmine_links has a Cognitive Complexity of 225 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
    text.gsub!(LINKS_RE) do |_|
      tag_content = $~[:tag_content]
      leading = $~[:leading]
      esc = $~[:esc]
Severity: Minor
Found in app/helpers/application_helper.rb - About 4 days 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

File application_helper.rb has 1549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'forwardable'
require 'cgi'

module ApplicationHelper
  include Redmine::WikiFormatting::Macros::Definitions
Severity: Major
Found in app/helpers/application_helper.rb - About 4 days to fix

    Method parse_wiki_links has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_wiki_links(text, project, obj, attr, only_path, options)
        text.gsub!(/(!)?(\[\[([^\n\|]+?)(\|([^\n\|]+?))?\]\])/) do |m|
          link_project = project
          esc, all, page, title = $1, $2, $3, $5
          if esc.nil?
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 1 day 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 parse_redmine_links has 193 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_redmine_links(text, default_project, obj, attr, only_path, options)
        text.gsub!(LINKS_RE) do |_|
          tag_content = $~[:tag_content]
          leading = $~[:leading]
          esc = $~[:esc]
    Severity: Major
    Found in app/helpers/application_helper.rb - About 7 hrs to fix

      Method format_object has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

        def format_object(object, html=true, &block)
          if block
            object = yield object
          end
          case object
      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 render_project_nested_lists has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def render_project_nested_lists(projects, &block)
          s = +''
          if projects.any?
            ancestors = []
            original_project = @project
      Severity: Minor
      Found in app/helpers/application_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 parse_non_pre_blocks has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_non_pre_blocks(text, obj, macros, options={})
          s = StringScanner.new(text)
          tags = []
          parsed = +''
          while !s.eos?
      Severity: Minor
      Found in app/helpers/application_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 parse_wiki_links has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def parse_wiki_links(text, project, obj, attr, only_path, options)
          text.gsub!(/(!)?(\[\[([^\n\|]+?)(\|([^\n\|]+?))?\]\])/) do |m|
            link_project = project
            esc, all, page, title = $1, $2, $3, $5
            if esc.nil?
      Severity: Major
      Found in app/helpers/application_helper.rb - About 2 hrs to fix

        Method format_object has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def format_object(object, html=true, &block)
            if block
              object = yield object
            end
            case object
        Severity: Major
        Found in app/helpers/application_helper.rb - About 2 hrs to fix

          Method parse_inline_attachments has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_inline_attachments(text, project, obj, attr, only_path, options)
              return if options[:inline_attachments] == false
          
              # when using an image link, try to use an attachment, if possible
              attachments = options[:attachments] || []
          Severity: Minor
          Found in app/helpers/application_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 replace_toc has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def replace_toc(text, headings)
              text.gsub!(TOC_RE) do
                left_align, right_align = $2, $3
                # Keep only the 4 first levels
                headings = headings.select{|level, anchor, item| level <= 4}
          Severity: Minor
          Found in app/helpers/application_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 render_page_hierarchy has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def render_page_hierarchy(pages, node=nil, options={})
              content = +''
              if pages[node]
                content << "<ul class=\"pages-hierarchy\">\n"
                pages[node].each do |page|
          Severity: Minor
          Found in app/helpers/application_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 textilizable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def textilizable(*args)
              options = args.last.is_a?(Hash) ? args.pop : {}
              case args.size
              when 1
                obj = options[:object]
          Severity: Minor
          Found in app/helpers/application_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 project_tree_options_for_select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def project_tree_options_for_select(projects, options = {})
              s = ''.html_safe
              if blank_text = options[:include_blank]
                if blank_text == true
                  blank_text = '&nbsp;'.html_safe
          Severity: Minor
          Found in app/helpers/application_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 page_header_title has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def page_header_title
              if @project.nil? || @project.new_record?
                h(Setting.app_title)
              else
                b = []
          Severity: Minor
          Found in app/helpers/application_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 textilizable has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def textilizable(*args)
              options = args.last.is_a?(Hash) ? args.pop : {}
              case args.size
              when 1
                obj = options[:object]
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 1 hr to fix

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

              def link_to_principal(principal, options={})
                only_path = options[:only_path].nil? ? true : options[:only_path]
                case principal
                when User
                  name = h(principal.name(options[:format]))
            Severity: Minor
            Found in app/helpers/application_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 render_projects_for_jump_box has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def render_projects_for_jump_box(projects, selected: nil, query: nil)
                if query.blank?
                  jump_box = Redmine::ProjectJumpBox.new User.current
                  bookmarked = jump_box.bookmarked_projects
                  recents = jump_box.recently_used_projects
            Severity: Minor
            Found in app/helpers/application_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 render_projects_for_jump_box has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def render_projects_for_jump_box(projects, selected: nil, query: nil)
                if query.blank?
                  jump_box = Redmine::ProjectJumpBox.new User.current
                  bookmarked = jump_box.bookmarked_projects
                  recents = jump_box.recently_used_projects
            Severity: Minor
            Found in app/helpers/application_helper.rb - About 1 hr to fix

              Method progress_bar has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def progress_bar(pcts, options={})
                  pcts = [pcts, pcts] unless pcts.is_a?(Array)
                  pcts = pcts.collect(&:floor)
                  pcts[1] = pcts[1] - pcts[0]
                  pcts << (100 - pcts[1] - pcts[0])
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 1 hr to fix

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

                  def replace_toc(text, headings)
                    text.gsub!(TOC_RE) do
                      left_align, right_align = $2, $3
                      # Keep only the 4 first levels
                      headings = headings.select{|level, anchor, item| level <= 4}
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 1 hr to fix

                  Method parse_non_pre_blocks has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def parse_non_pre_blocks(text, obj, macros, options={})
                      s = StringScanner.new(text)
                      tags = []
                      parsed = +''
                      while !s.eos?
                  Severity: Minor
                  Found in app/helpers/application_helper.rb - About 1 hr to fix

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

                      def link_to_issue(issue, options={})
                        title = nil
                        subject = nil
                        text = options[:tracker] == false ? "##{issue.id}" : "#{issue.tracker} ##{issue.id}"
                        if options[:subject] == false
                    Severity: Minor
                    Found in app/helpers/application_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 progress_bar has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def progress_bar(pcts, options={})
                        pcts = [pcts, pcts] unless pcts.is_a?(Array)
                        pcts = pcts.collect(&:floor)
                        pcts[1] = pcts[1] - pcts[0]
                        pcts << (100 - pcts[1] - pcts[0])
                    Severity: Minor
                    Found in app/helpers/application_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 inject_macros has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def inject_macros(text, obj, macros, execute=true, options={})
                        text.gsub!(MACRO_SUB_RE) do
                          all, index = $1, $2.to_i
                          orig = macros.delete(index)
                          if execute && orig && orig =~ MACROS_RE
                    Severity: Minor
                    Found in app/helpers/application_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 render_project_nested_lists has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def render_project_nested_lists(projects, &block)
                        s = +''
                        if projects.any?
                          ancestors = []
                          original_project = @project
                    Severity: Minor
                    Found in app/helpers/application_helper.rb - About 1 hr to fix

                      Method render_page_hierarchy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def render_page_hierarchy(pages, node=nil, options={})
                          content = +''
                          if pages[node]
                            content << "<ul class=\"pages-hierarchy\">\n"
                            pages[node].each do |page|
                      Severity: Minor
                      Found in app/helpers/application_helper.rb - About 1 hr to fix

                        Method include_calendar_headers_tags has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def include_calendar_headers_tags
                            unless @calendar_headers_tags_included
                              tags = ''.html_safe
                              @calendar_headers_tags_included = true
                              content_for :header_tags do
                        Severity: Minor
                        Found in app/helpers/application_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

                        Method html_title has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def html_title(*args)
                            if args.empty?
                              title = @html_title || []
                              title << @project.name if @project
                              title << Setting.app_title unless Setting.app_title == title.last
                        Severity: Minor
                        Found in app/helpers/application_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

                        Method principals_options_for_select has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def principals_options_for_select(collection, selected=nil)
                            s = +''
                            if collection.include?(User.current)
                              s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
                            end
                        Severity: Minor
                        Found in app/helpers/application_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

                        Avoid deeply nested control flow statements.
                        Open

                                        wiki_page_id = page.present? ? Wiki.titleize(page) : nil
                        Severity: Major
                        Found in app/helpers/application_helper.rb - About 45 mins to fix

                          Method parse_wiki_links has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def parse_wiki_links(text, project, obj, attr, only_path, options)
                          Severity: Minor
                          Found in app/helpers/application_helper.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
                            Severity: Major
                            Found in app/helpers/application_helper.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                              "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '')
                              Severity: Major
                              Found in app/helpers/application_helper.rb - About 45 mins to fix

                                Method parse_redmine_links has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
                                Severity: Minor
                                Found in app/helpers/application_helper.rb - About 45 mins to fix

                                  Method parse_headings has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                    def parse_headings(text, project, obj, attr, only_path, options)
                                  Severity: Minor
                                  Found in app/helpers/application_helper.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                    "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '')
                                    Severity: Major
                                    Found in app/helpers/application_helper.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                      "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
                                      Severity: Major
                                      Found in app/helpers/application_helper.rb - About 45 mins to fix

                                        Method parse_hires_images has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          def parse_hires_images(text, project, obj, attr, only_path, options)
                                        Severity: Minor
                                        Found in app/helpers/application_helper.rb - About 45 mins to fix

                                          Method parse_inline_attachments has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                            def parse_inline_attachments(text, project, obj, attr, only_path, options)
                                          Severity: Minor
                                          Found in app/helpers/application_helper.rb - About 45 mins to fix

                                            Method parse_headings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                              def parse_headings(text, project, obj, attr, only_path, options)
                                                return if options[:headings] == false
                                            
                                                text.gsub!(HEADING_RE) do
                                                  level, attrs, content = $2.to_i, $3, $4
                                            Severity: Minor
                                            Found in app/helpers/application_helper.rb - About 45 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 parse_sections has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                              def parse_sections(text, project, obj, attr, only_path, options)
                                            Severity: Minor
                                            Found in app/helpers/application_helper.rb - About 45 mins to fix

                                              Method link_to_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                def link_to_group(group, options={})
                                                  if group.is_a?(Group)
                                                    name = h(group.name)
                                                    if User.current.admin?
                                                      only_path = options[:only_path].nil? ? true : options[:only_path]
                                              Severity: Minor
                                              Found in app/helpers/application_helper.rb - About 45 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

                                              Avoid deeply nested control flow statements.
                                              Open

                                                            if repo_identifier
                                                              repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
                                                            else
                                                              repository = project.repository
                                                            end
                                              Severity: Major
                                              Found in app/helpers/application_helper.rb - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                          elsif sep == ':'
                                                            name = remove_double_quotes(identifier)
                                                            case prefix
                                                            when 'document'
                                                              if project && document = project.documents.visible.find_by_title(name)
                                                Severity: Major
                                                Found in app/helpers/application_helper.rb - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                    if wiki_page.nil? && obj.is_a?(WikiContent) &&
                                                                         obj.page && project == link_project
                                                                      obj.page.title
                                                                    else
                                                                      nil
                                                  Severity: Major
                                                  Found in app/helpers/application_helper.rb - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                  if repository &&
                                                                       (changeset = Changeset.visible.
                                                                                        find_by_repository_id_and_revision(repository.id, identifier))
                                                                    link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"),
                                                                                   {:only_path => only_path, :controller => 'repositories',
                                                    Severity: Major
                                                    Found in app/helpers/application_helper.rb - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                  case prefix
                                                                  when nil
                                                                    if oid.to_s == identifier &&
                                                                      issue = Issue.visible.find_by_id(oid)
                                                                      anchor = comment_id ? "note-#{comment_id}" : nil
                                                      Severity: Major
                                                      Found in app/helpers/application_helper.rb - About 45 mins to fix

                                                        Method inject_macros has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                        Open

                                                          def inject_macros(text, obj, macros, execute=true, options={})
                                                        Severity: Minor
                                                        Found in app/helpers/application_helper.rb - About 35 mins to fix

                                                          Method option_tag has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                            def option_tag(name, text, value, selected=nil, options={})
                                                          Severity: Minor
                                                          Found in app/helpers/application_helper.rb - About 35 mins to fix

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

                                                              def title(*args)
                                                                strings = args.map do |arg|
                                                                  if arg.is_a?(Array) && arg.size >= 2
                                                                    link_to(*arg)
                                                                  else
                                                            Severity: Minor
                                                            Found in app/helpers/application_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 stylesheet_link_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def stylesheet_link_tag(*sources)
                                                                options = sources.last.is_a?(Hash) ? sources.pop : {}
                                                                plugin = options.delete(:plugin)
                                                                sources = sources.map do |source|
                                                                  if plugin
                                                            Severity: Minor
                                                            Found in app/helpers/application_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 body_css_classes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def body_css_classes
                                                                css = []
                                                                if theme = Redmine::Themes.theme(Setting.ui_theme)
                                                                  css << 'theme-' + theme.name
                                                                end
                                                            Severity: Minor
                                                            Found in app/helpers/application_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 javascript_include_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def javascript_include_tag(*sources)
                                                                options = sources.last.is_a?(Hash) ? sources.pop : {}
                                                                if plugin = options.delete(:plugin)
                                                                  sources = sources.map do |source|
                                                                    if plugin
                                                            Severity: Minor
                                                            Found in app/helpers/application_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 render_tabs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              def render_tabs(tabs, selected=params[:tab])
                                                                if tabs.any?
                                                                  unless tabs.detect {|tab| tab[:name] == selected}
                                                                    selected = nil
                                                                  end
                                                            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

                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                    (if pcts[1] > 0
                                                                       content_tag('td', '', :style => "width: #{pcts[1]}%;",
                                                                                  :class => 'done', :title => titles[1])
                                                                     else
                                                                       ''.html_safe
                                                            Severity: Minor
                                                            Found in app/helpers/application_helper.rb and 2 other locations - About 15 mins to fix
                                                            app/helpers/application_helper.rb on lines 1582..1586
                                                            app/helpers/application_helper.rb on lines 1594..1598

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 25.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                    (if pcts[0] > 0
                                                                       content_tag('td', '', :style => "width: #{pcts[0]}%;",
                                                                                   :class => 'closed', :title => titles[0])
                                                                     else
                                                                       ''.html_safe
                                                            Severity: Minor
                                                            Found in app/helpers/application_helper.rb and 2 other locations - About 15 mins to fix
                                                            app/helpers/application_helper.rb on lines 1588..1592
                                                            app/helpers/application_helper.rb on lines 1594..1598

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 25.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                                            Open

                                                                    (if pcts[2] > 0
                                                                       content_tag('td', '', :style => "width: #{pcts[2]}%;",
                                                                                               :class => 'todo', :title => titles[2])
                                                                     else
                                                                       ''.html_safe
                                                            Severity: Minor
                                                            Found in app/helpers/application_helper.rb and 2 other locations - About 15 mins to fix
                                                            app/helpers/application_helper.rb on lines 1582..1586
                                                            app/helpers/application_helper.rb on lines 1588..1592

                                                            Duplicated Code

                                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                            Tuning

                                                            This issue has a mass of 25.

                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                            Refactorings

                                                            Further Reading

                                                            There are no issues that match your filters.

                                                            Category
                                                            Status