MiraitSystems/enju_trunk

View on GitHub
app/models/reminder_list.rb

Summary

Maintainability
F
5 days
Test Coverage

Method output_reminder_postal_card has a Cognitive Complexity of 118 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_reminder_postal_card(file, reminder_lists, user, current_user)
    logger.info "create_file=> #{file}"
    report_path = EnjuTrunk.report_path

    report = ThinReports::Report.create do
Severity: Minor
Found in app/models/reminder_list.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 output_reminder_list_tsv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_reminder_list_tsv(reminder_lists)
    columns = [
      [:checkout_id, 'activerecord.attributes.reminder_list.checkout_id'],
      [:title, 'activerecord.attributes.reminder_list.original_title'],
      [:call_number, 'activerecord.attributes.item.call_number'],
Severity: Minor
Found in app/models/reminder_list.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_reminder_postal_card has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.output_reminder_postal_card(file, reminder_lists, user, current_user)
    logger.info "create_file=> #{file}"
    report_path = EnjuTrunk.report_path

    report = ThinReports::Report.create do
Severity: Major
Found in app/models/reminder_list.rb - About 3 hrs to fix

    Method output_reminder_letter has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.output_reminder_letter(file, reminder_lists, user, current_user)
        logger.info "create_file=> #{file}"
    
        report = EnjuTrunk.new_report('reminder_letter.tlf')
        report.layout.config.list(:list) do
    Severity: Minor
    Found in app/models/reminder_list.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File reminder_list.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ReminderList < ActiveRecord::Base
      attr_accessible :item_identifier, :status, :mail_sent_at
    
      default_scope :order => 'reminder_lists.id DESC'
    
    
    Severity: Minor
    Found in app/models/reminder_list.rb - About 2 hrs to fix

      Method output_reminder_list_tsv has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.output_reminder_list_tsv(reminder_lists)
          columns = [
            [:checkout_id, 'activerecord.attributes.reminder_list.checkout_id'],
            [:title, 'activerecord.attributes.reminder_list.original_title'],
            [:call_number, 'activerecord.attributes.item.call_number'],
      Severity: Minor
      Found in app/models/reminder_list.rb - About 1 hr to fix

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

          def self.output_reminder_letter(file, reminder_lists, user, current_user)
            logger.info "create_file=> #{file}"
        
            report = EnjuTrunk.new_report('reminder_letter.tlf')
            report.layout.config.list(:list) do
        Severity: Minor
        Found in app/models/reminder_list.rb - About 1 hr to fix

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

            def self.output_reminder_list_pdf(reminder_lists)
              report = EnjuTrunk.new_report('reminder_list.tlf')
          
              # set page_num
              report.events.on :page_create do |e|
          Severity: Minor
          Found in app/models/reminder_list.rb - About 1 hr to fix

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

              def self.output_reminder_list_pdf(reminder_lists)
                report = EnjuTrunk.new_report('reminder_list.tlf')
            
                # set page_num
                report.events.on :page_create do |e|
            Severity: Minor
            Found in app/models/reminder_list.rb - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                      while address.length > max_column
                        address.length.times { |i|
                          cnt += 0.5 if address[i] =~ /^[\s0-9A-Za-z]+$/
                          cnt += 1 unless address[i] =~ /^[\s0-9A-Za-z]+$/
                          if cnt.to_f >= max_column or address[i+1].nil? or address[i] =~ /^[\n]+$/
            Severity: Major
            Found in app/models/reminder_list.rb and 1 other location - About 3 hrs to fix
            app/models/reminder_list.rb on lines 216..229

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

            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

                    while name.length > max_column
                      name.length.times { |i|
                        cnt += 0.5 if name[i] =~ /^[\s0-9A-Za-z]+$/
                        cnt += 1 unless name[i] =~ /^[\s0-9A-Za-z]+$/
                        if cnt.to_f >= max_column or name[i+1].nil? or name[i] =~ /^[\n]+$/
            Severity: Major
            Found in app/models/reminder_list.rb and 1 other location - About 3 hrs to fix
            app/models/reminder_list.rb on lines 191..204

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

            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

                    page.list(:list).add_row do |row|
                      row.item(:item_identifier).value(reminder_list.checkout.item.item_identifier) if reminder_list.checkout.item.item_identifier
                      row.item(:title).value(reminder_list.checkout.item.manifestation.original_title) if reminder_list.checkout.item.manifestation.original_title
                      row.item(:due_date).value(reminder_list.checkout.due_date) if reminder_list.checkout.due_date
            Severity: Minor
            Found in app/models/reminder_list.rb and 1 other location - About 55 mins to fix
            app/models/reminder_list.rb on lines 254..257

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

            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

                      page.list(:list).add_row do |row|
                        row.item(:item_identifier).value(reminder_list.checkout.item.item_identifier) if reminder_list.checkout.item.item_identifier
                        row.item(:title).value(reminder_list.checkout.item.manifestation.original_title) if reminder_list.checkout.item.manifestation.original_title
                        row.item(:due_date).value(reminder_list.checkout.due_date) if reminder_list.checkout.due_date
            Severity: Minor
            Found in app/models/reminder_list.rb and 1 other location - About 55 mins to fix
            app/models/reminder_list.rb on lines 301..304

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

            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