MiraitSystems/enju_trunk

View on GitHub
app/controllers/manifestations_controller.rb

Summary

Maintainability
F
3 wks
Test Coverage

File manifestations_controller.rb has 1611 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ManifestationsController < ApplicationController
  authorize_function
  add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path', :only => [:index] #, :unless => proc{params}
#  add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path(params)', :only => [:index], :if => proc{params}
  add_breadcrumb "I18n.t('page.showing', :model => I18n.t('activerecord.models.manifestation'))", 'manifestation_path(params[:id])', :only => [:show]
Severity: Major
Found in app/controllers/manifestations_controller.rb - About 4 days to fix

    Method make_query_string_and_hl_pattern has a Cognitive Complexity of 138 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_query_string_and_hl_pattern
        qwords = []
        highlight = []
    
        #
    Severity: Minor
    Found in app/controllers/manifestations_controller.rb - About 2 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

    Method index has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        set_reserve_user
        search_opts = make_index_plan # 検索動作の方針を抽出する
    
        @seconds = Benchmark.realtime do
    Severity: Minor
    Found in app/controllers/manifestations_controller.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 new has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
    Open

      def new
        @select_theme_tags = Manifestation.struct_theme_selects if defined?(EnjuTrunkTheme)
        original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
        if original_manifestation # GET /manifestations/new?manifestation_id=1
          @manifestation = original_manifestation.dup
    Severity: Minor
    Found in app/controllers/manifestations_controller.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 make_query_string_and_hl_pattern has 212 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def make_query_string_and_hl_pattern
        qwords = []
        highlight = []
    
        #
    Severity: Major
    Found in app/controllers/manifestations_controller.rb - About 1 day to fix

      Method make_index_plan has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
      Open

        def make_index_plan
          search_opts = {
            :index => :local,
          }
      
      
      Severity: Minor
      Found in app/controllers/manifestations_controller.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 index has 182 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
          set_reserve_user
          search_opts = make_index_plan # 検索動作の方針を抽出する
      
          @seconds = Benchmark.realtime do
      Severity: Major
      Found in app/controllers/manifestations_controller.rb - About 7 hrs to fix

        Method show has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

          def show
            @location_symbol_size = Keycode.where(:name => 'item.location_symbol')
        
            if params[:isbn].present?
              if @manifestation_redirect = Manifestation.find_by_isbn(params[:isbn])
        Severity: Minor
        Found in app/controllers/manifestations_controller.rb - About 6 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 edit has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

          def edit
            unless current_user.has_role?('Librarian')
              unless params[:mode] == 'tag_edit'
                access_denied
              end
        Severity: Minor
        Found in app/controllers/manifestations_controller.rb - About 6 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 make_query_filter has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

          def make_query_filter(options)
            with = []
            without = []
        
            #
        Severity: Minor
        Found in app/controllers/manifestations_controller.rb - About 6 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 prepare_options has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

          def prepare_options
            @subject_types = SubjectType.all
            @carrier_types = CarrierType.all
            @sub_carrier_types = SubCarrierType.all
            @manifestation_types = ManifestationType.all
        Severity: Minor
        Found in app/controllers/manifestations_controller.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 create has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @manifestation = Manifestation.new(params[:manifestation])
            @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
            if @manifestation.respond_to?(:post_to_scribd)
              @manifestation.post_to_scribd = true if params[:manifestation][:post_to_scribd] == "1"
        Severity: Minor
        Found in app/controllers/manifestations_controller.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

        Class ManifestationsController has 38 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class ManifestationsController < ApplicationController
          authorize_function
          add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path', :only => [:index] #, :unless => proc{params}
        #  add_breadcrumb "I18n.t('breadcrumb.search_manifestations')", 'manifestations_path(params)', :only => [:index], :if => proc{params}
          add_breadcrumb "I18n.t('page.showing', :model => I18n.t('activerecord.models.manifestation'))", 'manifestation_path(params[:id])', :only => [:show]
        Severity: Minor
        Found in app/controllers/manifestations_controller.rb - About 5 hrs to fix

          Method update has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              if params[:manifestation][:identifiers_attributes]
                params[:manifestation][:identifiers_attributes].each do |key, identifier_attributes|
                  if identifier_attributes[:body].blank?
                    params[:manifestation][:identifiers_attributes]["#{key}"][:_destroy] = 1
          Severity: Minor
          Found in app/controllers/manifestations_controller.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 make_index_plan has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def make_index_plan
              search_opts = {
                :index => :local,
              }
          
          
          Severity: Major
          Found in app/controllers/manifestations_controller.rb - About 3 hrs to fix

            Method show has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def show
                @location_symbol_size = Keycode.where(:name => 'item.location_symbol')
            
                if params[:isbn].present?
                  if @manifestation_redirect = Manifestation.find_by_isbn(params[:isbn])
            Severity: Major
            Found in app/controllers/manifestations_controller.rb - About 3 hrs to fix

              Method make_query_filter has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def make_query_filter(options)
                  with = []
                  without = []
              
                  #
              Severity: Major
              Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

                Method prepare_options has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def prepare_options
                    @subject_types = SubjectType.all
                    @carrier_types = CarrierType.all
                    @sub_carrier_types = SubCarrierType.all
                    @manifestation_types = ManifestationType.all
                Severity: Major
                Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

                  Class NacsisCatSearch has 23 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class NacsisCatSearch
                      # sunspot_solrのSearchオブジェクトとの互換層
                  
                      include FormInputUtils
                  
                  
                  Severity: Minor
                  Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

                    Method update has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def update
                        if params[:manifestation][:identifiers_attributes]
                          params[:manifestation][:identifiers_attributes].each do |key, identifier_attributes|
                            if identifier_attributes[:body].blank?
                              params[:manifestation][:identifiers_attributes]["#{key}"][:_destroy] = 1
                    Severity: Major
                    Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

                      Method new has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def new
                          @select_theme_tags = Manifestation.struct_theme_selects if defined?(EnjuTrunkTheme)
                          original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
                          if original_manifestation # GET /manifestations/new?manifestation_id=1
                            @manifestation = original_manifestation.dup
                      Severity: Minor
                      Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

                        Method create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def create
                            @manifestation = Manifestation.new(params[:manifestation])
                            @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
                            if @manifestation.respond_to?(:post_to_scribd)
                              @manifestation.post_to_scribd = true if params[:manifestation][:post_to_scribd] == "1"
                        Severity: Minor
                        Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

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

                            def do_direct_mode_process(search_opts)
                              return false unless search_opts[:direct_mode]
                          
                              manifestation = nil
                          
                          
                          Severity: Minor
                          Found in app/controllers/manifestations_controller.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 new_search_internal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def new_search_internal(manifestation_type = :all)
                                search = Sunspot.new_search(Manifestation)
                          
                                Manifestation.build_search_for_manifestations_list(search, @query, @with_filter, @without_filter)
                          
                          
                          Severity: Minor
                          Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

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

                              def create_from_nacsis
                                ncid = params['ncid']
                                type = params['manifestation_type'] || 'book'
                            
                                if type == 'book'
                            Severity: Minor
                            Found in app/controllers/manifestations_controller.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 update_search_sessions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def update_search_sessions(search_opts, search_container)
                                return unless search_opts[:index] == :local # FIXME: 非local検索のときにも動作するようにする
                            
                                search = search_container[:session]
                            
                            
                            Severity: Minor
                            Found in app/controllers/manifestations_controller.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 new_search_internal has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def new_search_internal(manifestation_type = :all)
                                  search = Sunspot.new_search(Manifestation)
                            
                                  Manifestation.build_search_for_manifestations_list(search, @query, @with_filter, @without_filter)
                            
                            
                            Severity: Minor
                            Found in app/controllers/manifestations_controller.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 num_range_query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def num_range_query(field_base, num_from, num_to)
                                n1 = n2 = nil
                                num_regex = /\A0*[1-9]\d*/
                            
                                n1 = $&.to_i if num_regex =~ num_from
                            Severity: Minor
                            Found in app/controllers/manifestations_controller.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 upload_to_nacsis has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def upload_to_nacsis
                                result = NacsisCat.upload_info_to_nacsis(params[:work_id], params[:db_type], params[:command])
                            
                                case params[:db_type]
                                when 'BOOK'
                            Severity: Minor
                            Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

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

                                  def execute
                                    return nil unless valid?
                              
                                    if @dbs.blank?
                                      @results = {}
                              Severity: Minor
                              Found in app/controllers/manifestations_controller.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_mode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def render_mode(mode)
                                  case mode
                                  when 'barcode'
                                    barcode = Barby::QrCode.new(@manifestation.id)
                                    send_data(barcode.to_svg, :disposition => 'inline', :type => 'image/svg+xml')
                              Severity: Minor
                              Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

                                Method edit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def edit
                                    unless current_user.has_role?('Librarian')
                                      unless params[:mode] == 'tag_edit'
                                        access_denied
                                      end
                                Severity: Minor
                                Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                        if params[:item_identifier].present? &&
                                              params[:item_identifier] !~ /\*/ ||
                                            (SystemConfiguration.get('manifestation.isbn_unique') &&
                                              params[:isbn].present? && params[:isbn] !~ /\*/) ||
                                                (params[:identifier].present? && params[:identifier] !~ /\*/)
                                  Severity: Major
                                  Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

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

                                      def do_file_output_proccess(search_opts, search)
                                        return false unless search_opts[:index] == :local
                                        return false unless search_opts[:output_mode]
                                    
                                        # TODO: 第一引数にparamsまたは生成した検索語、フィルタ指定を渡すようにして、バックグラウンドファイル生成で一時ファイルを作らなくて済むようにする
                                    Severity: Minor
                                    Found in app/controllers/manifestations_controller.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def initialize(options, params, query, with_filter, without_filter, sort)
                                    Severity: Minor
                                    Found in app/controllers/manifestations_controller.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                              search_opts[:direct_mode] = true unless params[:binding_items_flg]
                                      Severity: Major
                                      Found in app/controllers/manifestations_controller.rb - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                if params[:without_article]
                                                  search_opts[:with_article] = false
                                                else
                                                  search_opts[:with_article] = !SystemConfiguration.isWebOPAC || clinet_is_special_ip?
                                                end
                                        Severity: Major
                                        Found in app/controllers/manifestations_controller.rb - About 45 mins to fix

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

                                            def upload_to_nacsis
                                              result = NacsisCat.upload_info_to_nacsis(params[:work_id], params[:db_type], params[:command])
                                          
                                              case params[:db_type]
                                              when 'BOOK'
                                          Severity: Minor
                                          Found in app/controllers/manifestations_controller.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 show_nacsis has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def show_nacsis
                                              case normalize_query_string(params[:manifestation_type])
                                              when 'book'
                                                db = :book
                                              when 'serial'
                                          Severity: Minor
                                          Found in app/controllers/manifestations_controller.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

                                          Avoid too many return statements within this method.
                                          Open

                                                do_tag_cloud_process(search_opts) and return
                                          Severity: Major
                                          Found in app/controllers/manifestations_controller.rb - About 30 mins to fix

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

                                                def new_search
                                                  dbs = []
                                                  if @options[:nacsis_search_each]
                                                    dbs << :book
                                                    if @options[:with_article]
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.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 create_classification_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                              def create_classification_values(add_classifications)
                                                classifications = []
                                                (add_classifications || []).each do |add_classification|
                                                  next if add_classification[:classification_id].blank?
                                                  classification = Classification.where(:id => add_classification[:classification_id]).first
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.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 search_manifestation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                              def search_manifestation
                                                unless request.xhr? or params[:original_title].blank?
                                                  Rails.logger.info "not ajax request on search_manifestation"
                                                  render text: "" # TODO
                                                  return
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.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

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

                                              def get_classification_values(manifestation)
                                                classifications = []
                                                manifestation_has_classifications = manifestation.manifestation_has_classifications.order(:position)
                                                if manifestation_has_classifications.present?
                                                  manifestation_has_classifications.each do |manifestation_has_classification|
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.rb and 1 other location - About 25 mins to fix
                                            app/controllers/series_statements_controller.rb on lines 263..274

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

                                            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

                                                    prepare_options
                                            
                                                    format.html { render :action => "edit" }
                                                    format.json { render :json => @manifestation.errors, :status => :unprocessable_entity }
                                                    if defined?(EnjuTrunkTheme)
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.rb and 1 other location - About 20 mins to fix
                                            app/controllers/manifestations_controller.rb on lines 960..966

                                            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

                                                    prepare_options
                                            
                                                    format.html { render :action => "new" }
                                                    format.json { render :json => @manifestation.errors, :status => :unprocessable_entity }
                                                    if defined?(EnjuTrunkTheme)
                                            Severity: Minor
                                            Found in app/controllers/manifestations_controller.rb and 1 other location - About 20 mins to fix
                                            app/controllers/manifestations_controller.rb on lines 1040..1046

                                            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

                                            There are no issues that match your filters.

                                            Category
                                            Status