MiraitSystems/enju_trunk

View on GitHub
app/models/item_statistics.rb

Summary

Maintainability
F
2 wks
Test Coverage

Method output_detail has a Cognitive Complexity of 177 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_detail(wbstyles, sheet, data, conditions, cols, remove = nil)
    default_style = wbstyles.add_style :font_name => Setting.item_statistics_print_excelx.fontname

    if remove.blank?
      book_sym = "book".to_sym
Severity: Minor
Found in app/models/item_statistics.rb - About 3 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 output_columns has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_columns(wbstyles, sheet, conditions, cols)
    merge_style = wbstyles.add_style :font_name => Setting.item_statistics_print_excelx.fontname, :alignment => {:horizontal => :center, :vertical => :center}
    if cols.length > 0
      # 1行目
      if conditions.aggregation_first.present?
Severity: Minor
Found in app/models/item_statistics.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

File item_statistics.rb has 706 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ItemStatistics
  include ActiveModel::Conversion
  include ActiveModel::Validations
  extend ActiveModel::Naming
  extend ActiveModel::Translation
Severity: Major
Found in app/models/item_statistics.rb - About 1 day to fix

    Method make_data has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_data
        items = Item.select("items.id")
        items = items.joins(:manifestation)
        items = items.joins(:budget_category)
        items = items.joins(:shelf)
    Severity: Minor
    Found in app/models/item_statistics.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_detail_data has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_detail_data(item_statistics, second_items)
        detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                  :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                  :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                  :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
    Severity: Minor
    Found in app/models/item_statistics.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_data has 172 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def make_data
        items = Item.select("items.id")
        items = items.joins(:manifestation)
        items = items.joins(:budget_category)
        items = items.joins(:shelf)
    Severity: Major
    Found in app/models/item_statistics.rb - About 6 hrs to fix

      Method output_detail has 170 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.output_detail(wbstyles, sheet, data, conditions, cols, remove = nil)
          default_style = wbstyles.add_style :font_name => Setting.item_statistics_print_excelx.fontname
      
          if remove.blank?
            book_sym = "book".to_sym
      Severity: Major
      Found in app/models/item_statistics.rb - About 6 hrs to fix

        Method output_columns has 146 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.output_columns(wbstyles, sheet, conditions, cols)
            merge_style = wbstyles.add_style :font_name => Setting.item_statistics_print_excelx.fontname, :alignment => {:horizontal => :center, :vertical => :center}
            if cols.length > 0
              # 1行目
              if conditions.aggregation_first.present?
        Severity: Major
        Found in app/models/item_statistics.rb - About 5 hrs to fix

          Method output_excelx has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.output_excelx(output_data, filename = nil)
              require 'axlsx'
          
              # initialize
              if filename.present?
          Severity: Minor
          Found in app/models/item_statistics.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 output_excelx has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.output_excelx(output_data, filename = nil)
              require 'axlsx'
          
              # initialize
              if filename.present?
          Severity: Major
          Found in app/models/item_statistics.rb - About 3 hrs to fix

            Method make_detail_data has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def make_detail_data(item_statistics, second_items)
                detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                          :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                          :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                          :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
            Severity: Major
            Found in app/models/item_statistics.rb - About 2 hrs to fix

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

                def acquired_at_range_valid?
                  if acquired_at_from.present? && acquired_at_to.present?
                    if (/^[0-9]{4}-[0-9]{2}$/ =~ acquired_at_from && /^[0-9]{4}-[0-9]{2}$/ =~ acquired_at_to) || (/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ =~ acquired_at_from && /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ =~ acquired_at_to)
                    
                      if acquired_at_from > acquired_at_to
              Severity: Minor
              Found in app/models/item_statistics.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 output_detail has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def self.output_detail(wbstyles, sheet, data, conditions, cols, remove = nil)
              Severity: Minor
              Found in app/models/item_statistics.rb - About 45 mins to fix

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

                          second_row[:detail].each do |detail|
                            books_row << detail[:jpn_not_donate][book_sym]
                            books_row << detail[:jpn_not_donate][price_sym] if conditions.money_aggregation.present?
                            books_row << detail[:foreign_not_donate][book_sym]
                            books_row << detail[:foreign_not_donate][price_sym] if conditions.money_aggregation.present?
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 2 hrs to fix
                app/models/item_statistics.rb on lines 699..707

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

                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

                          second_row[:detail].each do |detail|
                            books_row << detail[:jpn_donate][book_sym]
                            books_row << detail[:jpn_donate][price_sym] if conditions.money_aggregation.present?
                            books_row << detail[:foreign_donate][book_sym]
                            books_row << detail[:foreign_donate][price_sym] if conditions.money_aggregation.present?
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 2 hrs to fix
                app/models/item_statistics.rb on lines 684..692

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

                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

                        grand_totals.each do |grand_total|
                          books_row << grand_total[:jpn_donate][book_sym]
                          books_row << grand_total[:jpn_donate][price_sym] if conditions.money_aggregation.present?
                          books_row << grand_total[:foreign_donate][book_sym]
                          books_row << grand_total[:foreign_donate][price_sym] if conditions.money_aggregation.present?
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 2 hrs to fix
                app/models/item_statistics.rb on lines 764..772

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

                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

                        grand_totals.each do |grand_total|
                          books_row << grand_total[:jpn_not_donate][book_sym]
                          books_row << grand_total[:jpn_not_donate][price_sym] if conditions.money_aggregation.present?
                          books_row << grand_total[:foreign_not_donate][book_sym]
                          books_row << grand_total[:foreign_not_donate][price_sym] if conditions.money_aggregation.present?
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 2 hrs to fix
                app/models/item_statistics.rb on lines 777..785

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

                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

                        record_count.times do
                          grand_totals << {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                           :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                           :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                           :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 1 hr to fix
                app/models/item_statistics.rb on lines 147..153

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

                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

                        record_count.times do
                          sum_details << {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                          :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                          :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                          :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                Severity: Major
                Found in app/models/item_statistics.rb and 1 other location - About 1 hr to fix
                app/models/item_statistics.rb on lines 654..660

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

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

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

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

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

                Refactorings

                Further Reading

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

                      sum_detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                    :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                    :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                    :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                    :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                Severity: Major
                Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
                app/models/item_statistics.rb on lines 383..388
                app/models/item_statistics.rb on lines 645..650

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

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

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

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

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

                Refactorings

                Further Reading

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

                    detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                Severity: Major
                Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
                app/models/item_statistics.rb on lines 137..142
                app/models/item_statistics.rb on lines 645..650

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

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

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

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

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

                Refactorings

                Further Reading

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

                      grand_total = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                     :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                     :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                     :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                                     :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                Severity: Major
                Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
                app/models/item_statistics.rb on lines 137..142
                app/models/item_statistics.rb on lines 383..388

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

                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

                    if filename.present?
                      # 定期作成
                      out_dir = "#{Rails.root}/private/system/item_statistics"
                      excel_filepath = "#{out_dir}/list#{Time.now.strftime('%s')}#{filename}.xlsx"
                    else
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 55 mins to fix
                app/models/checkout_statistics.rb on lines 214..221

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

                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

                      cols.each_with_index do |col, i|
                        columns << I18n.t('statistical_table.jpn_donate')
                        columns << "" if conditions.money_aggregation.present?
                        columns << I18n.t('statistical_table.foreign_donate')
                        columns << "" if conditions.money_aggregation.present?
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 45 mins to fix
                app/models/item_statistics.rb on lines 533..539

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

                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

                      cols.each_with_index do |col, i|
                        columns << I18n.t('statistical_table.jpn')
                        columns << "" if conditions.money_aggregation.present?
                        columns << I18n.t('statistical_table.foreign')
                        columns << "" if conditions.money_aggregation.present?
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 45 mins to fix
                app/models/item_statistics.rb on lines 543..549

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

                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 acquired_at_range_valid?
                    if acquired_at_from.present? && acquired_at_to.present?
                      if (/^[0-9]{4}-[0-9]{2}$/ =~ acquired_at_from && /^[0-9]{4}-[0-9]{2}$/ =~ acquired_at_to) || (/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ =~ acquired_at_from && /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ =~ acquired_at_to)
                      
                        if acquired_at_from > acquired_at_to
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 35 mins to fix
                app/models/checkout_statistics.rb on lines 313..323

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

                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

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

                      cols.each_with_index do |col, i|
                        from = start_col + (step_col * i)
                        to = start_col + step_col + (step_col * i) - 1
                        sheet.merge_cells sheet.rows.last.cells[from..to]
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 25 mins to fix
                app/models/item_statistics.rb on lines 513..516

                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

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

                      cols.each_with_index do |col, i|
                        from = start_col + (step_col * i)
                        to = start_col + step_col + (step_col * i) - 1
                        sheet.merge_cells sheet.rows.last.cells[from..to]
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 25 mins to fix
                app/models/item_statistics.rb on lines 499..502

                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

                          if self.aggregation_second == "budget_category_group"
                            second_row_details << {:second_row_name => second_row.keyname, :detail => detail}
                          elsif self.aggregation_second == "carrier_type"
                            second_row_details << {:second_row_name => second_row.display_name, :detail => detail}
                          end
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 15 mins to fix
                app/models/item_statistics.rb on lines 191..195

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

                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

                          if self.aggregation_second == "budget_category_group"
                            second_row_details << {:second_row_name => second_row.keyname, :detail => details}
                          elsif self.aggregation_second == "carrier_type"
                            second_row_details << {:second_row_name => second_row.display_name, :detail => details}
                          end
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 15 mins to fix
                app/models/item_statistics.rb on lines 169..173

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

                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

                    if md = self.acquired_at_to.match(/^([0-9]{4})-([0-9]{2})$/)
                      day = Date.new(md[1].to_i, md[2].to_i, 1).end_of_month
                      acquired_at_to = day.to_s
                    else
                      acquired_at_to = self.acquired_at_to
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 15 mins to fix
                app/models/checkout_statistics.rb on lines 40..44

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

                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

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

                          from = start_col + 2 * i
                          to = start_col + 1 + 2 * i
                          sheet.merge_cells sheet.rows.last.cells[from..to]
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 15 mins to fix
                app/models/item_statistics.rb on lines 561..563

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 25.

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

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

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

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

                Refactorings

                Further Reading

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

                          from = start_col + 2 * i
                          to = start_col + 1 + 2 * i
                          sheet.merge_cells sheet.rows.last.cells[from..to]
                Severity: Minor
                Found in app/models/item_statistics.rb and 1 other location - About 15 mins to fix
                app/models/item_statistics.rb on lines 606..608

                Duplicated Code

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

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

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

                Tuning

                This issue has a mass of 25.

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

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

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

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

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status