MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method adhoc_text_field_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def adhoc_text_field_query(qwords, model, fields, nest = true, op = :default)
    model_string_fields = {}
    Sunspot::Setup.for(model).fields.each do |sunspot_field|
      next unless sunspot_field.type.is_a?(Sunspot::Type::StringType)
      model_string_fields[sunspot_field.name] = sunspot_field.indexed_name
Severity: Minor
Found in app/controllers/form_input_utils.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 get_user_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def get_user_info
    return nil unless request.xhr?
    unless params[:user_number].blank?
      @user = User.get_user(params[:user_number])
      if @user
Severity: Minor
Found in app/controllers/users_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 set_exclude_agents has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def set_exclude_agents(old_exclude_agents, new_exclude_agents)
    old_exclude_agents.each do |p|
      next if new_exclude_agents.include?(p)
      agent = Agent.where(:full_name => p).first
      if agent
Severity: Minor
Found in app/controllers/system_configurations_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 monthly_report has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def monthly_report
    yyyymm = params[:library_report][:yyyymm]
    library_ids = params[:library]
    begin
      report = EnjuTrunk.new_report('monthly_library_report.tlf')
Severity: Minor
Found in app/controllers/library_reports_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 select_output_column_spec has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def select_output_column_spec(field, spec_hash = OUTPUT_COLUMN_SPEC)
        separation = separate_output_columns?
        if field == :all
          regexp = nil
        else
Severity: Minor
Found in lib/enju_trunk/output_columns.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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(params)
    raise QueryArgumentError, 'sru :query is required item.' unless params.has_key?(:query)

    @cql = Cql.new(params[:query])
    @version = params.has_key?(:version) ? params[:version] : '1.2'
Severity: Minor
Found in lib/enju_leaf/sru.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 tab_menu_width has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def tab_menu_width
      # ライブラリアン権限時未満のとき、タブメニューの表示内容に伴いタブのサイズも変更する
      if user_signed_in?
        unless current_user.has_role?('Librarian')
          # ゲスト権限以上ユーザ権限未満でログイン時
Severity: Minor
Found in lib/enju_trunk/enju_trunk_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 make_export_series_statements_latest_list_tsv has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.make_export_series_statements_latest_list_tsv(items)
    data = String.new
    data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"

    columns = [
Severity: Minor
Found in app/models/item.rb - About 1 hr to fix

    Method get_list_size has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_list_size
        unless request.xhr? && params[:list_type].present?
          render :nothing => true, :status => :not_found
          return
        end
    Severity: Minor
    Found in app/controllers/export_item_lists_controller.rb - About 1 hr to fix

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

        def show
          unless @agent.user.blank?
            access_denied; return
          end
      
      
      Severity: Minor
      Found in app/controllers/agents_controller.rb - About 1 hr to fix

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

          def update
            if @item and params[:position]
              @own.insert_at(params[:position])
              redirect_to item_owns_url(@item)
              return
        Severity: Major
        Found in app/controllers/owns_controller.rb and 3 other locations - About 1 hr to fix
        app/controllers/creates_controller.rb on lines 68..82
        app/controllers/produces_controller.rb on lines 73..86
        app/controllers/realizes_controller.rb on lines 68..82

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

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

          def update
            # 並べ替え
            if @expression and params[:position]
              @realize.insert_at(params[:position])
              redirect_to expression_realizes_url(@expression)
        Severity: Major
        Found in app/controllers/realizes_controller.rb and 3 other locations - About 1 hr to fix
        app/controllers/creates_controller.rb on lines 68..82
        app/controllers/owns_controller.rb on lines 69..82
        app/controllers/produces_controller.rb on lines 73..86

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

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

          def update
            # 並べ替え
            if @work and params[:position]
              @create.insert_at(params[:position])
              redirect_to work_creates_url(@work)
        Severity: Major
        Found in app/controllers/creates_controller.rb and 3 other locations - About 1 hr to fix
        app/controllers/owns_controller.rb on lines 69..82
        app/controllers/produces_controller.rb on lines 73..86
        app/controllers/realizes_controller.rb on lines 68..82

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

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

          def update
            if @manifestation and params[:position]
              @produce.insert_at(params[:position])
              redirect_to manifestation_produces_url(@manifestation)
              return
        Severity: Major
        Found in app/controllers/produces_controller.rb and 3 other locations - About 1 hr to fix
        app/controllers/creates_controller.rb on lines 68..82
        app/controllers/owns_controller.rb on lines 69..82
        app/controllers/realizes_controller.rb on lines 68..82

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

        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 get_manifestation_list_pdf has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.get_manifestation_list_pdf(manifestation_ids, current_user, summary = nil, type = :book)
            report = EnjuTrunk.new_report('searchlist.tlf')
        
            # set page_num
            report.events.on :page_create do |e|
        Severity: Minor
        Found in app/models/manifestation.rb - About 1 hr to fix

          Function upload has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              $.fn.upload = function(url, data, callback, type) {
                  var self = this, inputs, checkbox, checked,
                      iframeName = 'jquery_upload' + ++uuid,
                      iframe = $('<iframe name="' + iframeName + '" style="position:absolute;top:-9999px" />').appendTo('body'),
                      form = '<form target="' + iframeName + '" method="post" enctype="multipart/form-data" />';
          Severity: Minor
          Found in app/assets/javascripts/jquery.upload-1.0.2.js - About 1 hr to fix

            Method get_unable_list_tsv has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.get_unable_list_tsv(users)
                data = String.new
                data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
                columns = [
            #      [:library, 'activerecord.attributes.user.library'],
            Severity: Minor
            Found in app/models/unablelist.rb - About 1 hr to fix

              Method get_agent_import_results_tsv has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.get_agent_import_results_tsv(agent_import_results)
                  data = String.new
                  data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
                  columns = [
                    [:agent, 'activerecord.models.agent'],
              Severity: Minor
              Found in app/models/agent_import_result.rb - About 1 hr to fix

                Method delete_record has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def delete_record(error_msgs, item, manifestation, series_statement)
                      deleted_item =
                        deleted_item_identifier =
                        deleted_manifestation =
                        deleted_manifestation_title =
                Severity: Minor
                Found in lib/enju_trunk/resourceadapter/import_book.rb - About 1 hr to fix

                  Method update_manifestation_agents has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def update_manifestation_agents(sheet, datas, field, manifestation, error_msgs)
                        create_new = SystemConfiguration.get("add_only_exist_agent") == true
                  
                        [
                          ["#{field}.creator", :creates=, :creates],
                  Severity: Minor
                  Found in lib/enju_trunk/resourceadapter/import_book.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language