Undev/redmine_xapian

View on GitHub

Showing 19 of 19 total issues

Method index_with_xapian has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

      def index_with_xapian
        @question = params[:q] || ""
        @question.strip!
        @all_words = params[:all_words] ? params[:all_words].present? : true
        @titles_only = params[:titles_only] ? params[:titles_only].present? : false
Severity: Minor
Found in lib/redmine_xapian/search_controller_patch.rb - About 7 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 index_with_xapian has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def index_with_xapian
        @question = params[:q] || ""
        @question.strip!
        @all_words = params[:all_words] ? params[:all_words].present? : true
        @titles_only = params[:titles_only] ? params[:titles_only].present? : false
Severity: Major
Found in lib/redmine_xapian/search_controller_patch.rb - About 3 hrs to fix

    Method xapian_search has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

          def xapian_search(tokens, limit_options, offset, projects_to_search, all_words, user_stem_lang, user_stem_strategy, xapian_file )
            xpattachments = []
            return [xpattachments,0] unless Setting.plugin_redmine_xapian['enable'] == "true"
            Rails.logger.debug "DEBUG: global settings dump" + Setting.plugin_redmine_xapian.inspect
            Rails.logger.debug "DEBUG: user_stem_lang: " + user_stem_lang.inspect
    Severity: Minor
    Found in lib/redmine_xapian/search_strategies/xapian_search.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 xapian_search has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def xapian_search(tokens, limit_options, offset, projects_to_search, all_words, user_stem_lang, user_stem_strategy, xapian_file )
            xpattachments = []
            return [xpattachments,0] unless Setting.plugin_redmine_xapian['enable'] == "true"
            Rails.logger.debug "DEBUG: global settings dump" + Setting.plugin_redmine_xapian.inspect
            Rails.logger.debug "DEBUG: user_stem_lang: " + user_stem_lang.inspect
    Severity: Major
    Found in lib/redmine_xapian/search_strategies/xapian_search.rb - About 2 hrs to fix

      Method search_with_attachments has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def search_with_attachments(tokens, projects = nil, options = {})
                  unless name == "Attachment" || name == "Repofile"
                    return search_without_attachments(tokens, projects, options)
                  end
                  search_data = RedmineXapian::SearchStrategies::SearchData.new(
      Severity: Minor
      Found in lib/redmine_xapian/acts_as_searchable_patch.rb - About 1 hr to fix

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

              def process_attachment(projects_to_search, dochash)
                docattach = Attachment.where( :disk_filename => dochash.fetch('url') ).first
                if docattach
                  Rails.logger.debug "DEBUG: attach event_datetime" + docattach.event_datetime.inspect
                  Rails.logger.debug "DEBUG: attach project" + docattach.project.inspect
        Severity: Minor
        Found in lib/redmine_xapian/search_strategies/xapian_search.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_attachment has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def process_attachment(projects_to_search, dochash)
                docattach = Attachment.where( :disk_filename => dochash.fetch('url') ).first
                if docattach
                  Rails.logger.debug "DEBUG: attach event_datetime" + docattach.event_datetime.inspect
                  Rails.logger.debug "DEBUG: attach project" + docattach.project.inspect
        Severity: Minor
        Found in lib/redmine_xapian/search_strategies/xapian_search.rb - About 1 hr to fix

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

                def process_repo_file(projects_to_search, dochash)
                  Rails.logger.debug "DEBUG: repo file: " + dochash.fetch('url').inspect
                  dochash2=Hash[ [:project_identifier, :repo_identifier, :file ].zip(dochash.fetch('url').split('/',4).drop(1)) ]
                  project=Project.where(:identifier => dochash2[:project_identifier]).first
                  repository=Repository.where( :project_id=>project.id, :identifier=>dochash2[:repo_identifier] ).first unless project.nil?
          Severity: Minor
          Found in lib/redmine_xapian/search_strategies/xapian_search.rb - About 1 hr to fix

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

                def highlight_tokens2(text, tokens)
                  Rails.logger.debug "DEBUG: highlight_tokens2 "
                  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 lib/redmine_xapian/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 xapian_search has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def xapian_search(tokens, limit_options, offset, projects_to_search, all_words, user_stem_lang, user_stem_strategy, xapian_file )
            Severity: Major
            Found in lib/redmine_xapian/search_strategies/xapian_search.rb - About 1 hr to fix

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

                          def search_for_message_attachments(search_data)
                            query = <<-sql
                              INNER JOIN #{Message.table_name}
                                ON #{Message.table_name}.id=container_id
                              INNER JOIN #{Board.table_name}
              Severity: Minor
              Found in lib/redmine_xapian/acts_as_searchable_patch.rb and 1 other location - About 45 mins to fix
              lib/redmine_xapian/acts_as_searchable_patch.rb on lines 110..119

              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 40.

              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

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

                    def container_url
                      if container.is_a?(Issue)
                        container_url = {:controller=>"issues", :id=>container[:id], :action=>"show"}
                      elsif container.is_a?(WikiPage)
                        container_url = {:controller=>"wiki", :project_id=>container.project.identifier, :id=>container[:title], :action=>"show"}
              Severity: Minor
              Found in lib/redmine_xapian/attachment_patch.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

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

                          def search_for_wiki_page_attachments(search_data)
                            query = <<-sql
                              INNER JOIN #{WikiPage.table_name}
                                ON #{WikiPage.table_name}.id=container_id
                              INNER JOIN #{Wiki.table_name}
              Severity: Minor
              Found in lib/redmine_xapian/acts_as_searchable_patch.rb and 1 other location - About 45 mins to fix
              lib/redmine_xapian/acts_as_searchable_patch.rb on lines 98..107

              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 40.

              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

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

                    def initialize(context, tokens, projects, options, element)
              Severity: Minor
              Found in lib/redmine_xapian/search_strategies/search_data.rb - About 35 mins to fix

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

                          def search_with_attachments(tokens, projects = nil, options = {})
                            unless name == "Attachment" || name == "Repofile"
                              return search_without_attachments(tokens, projects, options)
                            end
                            search_data = RedmineXapian::SearchStrategies::SearchData.new(
                Severity: Minor
                Found in lib/redmine_xapian/acts_as_searchable_patch.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 container_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def container_name
                        container_name = ": "
                
                        if container.is_a?(Issue)
                          container_name += container[:subject].to_s
                Severity: Minor
                Found in lib/redmine_xapian/attachment_patch.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 process_repo_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def process_repo_file(projects_to_search, dochash)
                        Rails.logger.debug "DEBUG: repo file: " + dochash.fetch('url').inspect
                        dochash2=Hash[ [:project_identifier, :repo_identifier, :file ].zip(dochash.fetch('url').split('/',4).drop(1)) ]
                        project=Project.where(:identifier => dochash2[:project_identifier]).first
                        repository=Repository.where( :project_id=>project.id, :identifier=>dochash2[:repo_identifier] ).first unless project.nil?
                Severity: Minor
                Found in lib/redmine_xapian/search_strategies/xapian_search.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

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

                            def search_for_documents_attachments(search_data)
                              query = <<-sql
                                INNER JOIN #{Document.table_name}
                                  ON #{Document.table_name}.id=container_id
                                INNER JOIN #{Project.table_name}
                Severity: Minor
                Found in lib/redmine_xapian/acts_as_searchable_patch.rb and 1 other location - About 20 mins to fix
                lib/redmine_xapian/acts_as_searchable_patch.rb on lines 122..129

                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 28.

                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 2 locations. Consider refactoring.
                Open

                            def search_for_project_files(search_data)
                              query = <<-sql
                                INNER JOIN #{Version.table_name}
                                  ON #{Version.table_name}.id=container_id
                                INNER JOIN #{Project.table_name}
                Severity: Minor
                Found in lib/redmine_xapian/acts_as_searchable_patch.rb and 1 other location - About 20 mins to fix
                lib/redmine_xapian/acts_as_searchable_patch.rb on lines 71..78

                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 28.

                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

                Severity
                Category
                Status
                Source
                Language