SpeciesFileGroup/taxonworks

View on GitHub
app/models/person.rb

Summary

Maintainability
F
5 days
Test Coverage

Method merge_with has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
Open

  def merge_with(person_id)
    return false if person_id == id
    if r_person = Person.find(person_id) # get the person to merge to this person
      begin
        ApplicationRecord.transaction do
Severity: Minor
Found in app/models/person.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 has too many lines. [148/25]
Open

  def merge_with(person_id)
    return false if person_id == id
    if r_person = Person.find(person_id) # get the person to merge to this person
      begin
        ApplicationRecord.transaction do
Severity: Minor
Found in app/models/person.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method merge_with has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def merge_with(person_id)
    return false if person_id == id
    if r_person = Person.find(person_id) # get the person to merge to this person
      begin
        ApplicationRecord.transaction do
Severity: Major
Found in app/models/person.rb - About 5 hrs to fix

    File person.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Person < ApplicationRecord
      include Housekeeping::Users
      include Housekeeping::Timestamps
      include Shared::AlternateValues
      include Shared::DataAttributes
    Severity: Minor
    Found in app/models/person.rb - About 4 hrs to fix

      Class Person has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Person < ApplicationRecord
        include Housekeeping::Users
        include Housekeeping::Timestamps
        include Shared::AlternateValues
        include Shared::DataAttributes
      Severity: Minor
      Found in app/models/person.rb - About 3 hrs to fix

        Method bibtex_name has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def bibtex_name
            out = ''
        
            out << prefix + ' ' unless prefix.blank?
            out << last_name unless last_name.blank?
        Severity: Minor
        Found in app/models/person.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 parse_to_people has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.parse_to_people(name_string)
            parser(name_string).collect { |n| 
              Person::Unvetted.new(
                last_name: n['family'] ? NameCase(n['family']) : nil,
                first_name: n['given'] ? NameCase(n['given']) : nil,
        Severity: Minor
        Found in app/models/person.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 not_active_after_death has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def not_active_after_death
            unless is_editor? || is_author?
              errors.add(:year_active_start, 'is older than year of death') if year_active_start && year_died && year_active_start > year_died
              errors.add(:year_active_end, 'is older than year of death') if year_active_end && year_died && year_active_end > year_died
            end
        Severity: Minor
        Found in app/models/person.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

        Avoid deeply nested control flow statements.
        Open

                              if l_o.type == r_o.type &&
                                  l_o.alternate_value_object_attribute == r_o.alternate_value_object_attribute &&
                                  l_o.project_id == r_o.project_id
                                skip = true
                                break # stop looking in this bunch, if you found a match
        Severity: Major
        Found in app/models/person.rb - About 45 mins to fix

          Avoid more than 3 levels of block nesting.
          Open

                              if l_o.text == r_o.text &&
                                  l_o.note_object_attribute == r_o.note.object_attribute &&
                                  l_o.project_id == r_o.project_id
                                skip = true
                                break # stop looking in this bunch, if you found a match
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Avoid more than 3 levels of block nesting.
          Open

                              if l_o.type == r_o.type &&
                                  l_o.identifier == r_o.identifier &&
                                  l_o.project_id == r_o.project_id
                                skip = true
                                break # stop looking in this bunch, if you found a match
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Avoid more than 3 levels of block nesting.
          Open

                              if l_o.value == r_o.value
                                if l_o.type == r_o.type &&
                                    l_o.alternate_value_object_attribute == r_o.alternate_value_object_attribute &&
                                    l_o.project_id == r_o.project_id
                                  skip = true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Avoid more than 3 levels of block nesting.
          Open

                        if self.last_name != r_person.last_name
                          # create a last_name alternate_value of the r_person first name
                          skip_av = false
                          av_list = l_person_hash['alternate values']
                          av_list ||= {}
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Avoid more than 3 levels of block nesting.
          Open

                        if first_name != r_person.first_name
                          # create a first_name alternate_value of the r_person first name
                          skip_av = false
                          av_list = l_person_hash['alternate values']
                          av_list ||= {}
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Avoid more than 3 levels of block nesting.
          Open

                              if l_o.type == r_o.type &&
                                  l_o.controlled_vocabulary_term_id == r_o.controlled_vocabulary_term_id &&
                                  l_o.value == r_o.value &&
                                  l_o.project_id == r_o.project_id
                                skip = true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for excessive nesting of conditional and looping constructs.

          You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

          The maximum level of nesting allowed is configurable.

          Use find_each instead of each.
          Open

                    Role.where(person_id: r_person.id).each do |r|
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop is used to identify usages of all.each and change them to use all.find_each instead.

          Example:

          # bad
          User.all.each
          
          # good
          User.all.find_each

          Prefer 1.week.
          Open

                .where(t['created_at'].gt(1.weeks.ago))
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for correct grammar when using ActiveSupport's core extensions to the numeric classes.

          Example:

          # bad
          3.day.ago
          1.months.ago
          
          # good
          3.days.ago
          1.month.ago

          Use if r_person.first_name.present? instead of unless r_person.first_name.blank?.
          Open

                    unless r_person.first_name.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:prefix, NameCase(prefix)) if prefix && will_save_change_to_prefix? 
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:first_name, NameCase(first_name)) if first_name && will_save_change_to_first_name?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use if prefix.present? instead of unless prefix.blank?.
          Open

              out << prefix + ' ' unless prefix.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if r_person.suffix.present? instead of unless r_person.suffix.blank?.
          Open

                      unless r_person.suffix.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

                      write_attribute(:prefix, r_person.prefix)
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:last_name, NameCase(last_name)) if last_name && will_save_change_to_last_name?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use if r_person.prefix.present? instead of unless r_person.prefix.blank?.
          Open

                      unless r_person.prefix.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if first_name.present? instead of unless first_name.blank?.
          Open

              out << first_name unless first_name.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:suffix, NameCase(suffix)) if suffix && will_save_change_to_suffix?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Avoid using update_column because it skips validations.
          Open

              update_column(:cached, bibtex_name)
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

          Methods may be ignored from this rule by configuring a Whitelist.

          Example:

          # bad
          Article.first.decrement!(:view_count)
          DiscussionBoard.decrement_counter(:post_count, 5)
          Article.first.increment!(:view_count)
          DiscussionBoard.increment_counter(:post_count, 5)
          person.toggle :active
          product.touch
          Billing.update_all("category = 'authorized', author = 'David'")
          user.update_attribute(:website, 'example.com')
          user.update_columns(last_request_at: Time.current)
          Post.update_counters 5, comment_count: -1, action_count: 1
          
          # good
          user.update(website: 'example.com')
          FileUtils.touch('file')

          Example: Whitelist: ["touch"]

          # bad
          DiscussionBoard.decrement_counter(:post_count, 5)
          DiscussionBoard.increment_counter(:post_count, 5)
          person.toggle :active
          
          # good
          user.touch

          Use if last_name.present? instead of unless last_name.blank?.
          Open

              out << last_name unless last_name.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if r_person.last_name.present? instead of unless r_person.last_name.blank?.
          Open

                    unless r_person.last_name.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if suffix.present? instead of unless suffix.blank?.
          Open

              out << suffix unless suffix.blank?
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          TODO found
          Open

                    # TODO: handle prefix and suffix
          Severity: Minor
          Found in app/models/person.rb by fixme

          TODO found
          Open

            # TODO: remove this
          Severity: Minor
          Found in app/models/person.rb by fixme

          TODO found
          Open

            # has_many :sources, through: :roles # TODO: test and confirm dependent
          Severity: Minor
          Found in app/models/person.rb by fixme

          TODO found
          Open

                    # TODO: handle years attributes
          Severity: Minor
          Found in app/models/person.rb by fixme

          TODO found
          Open

            # TODO: deprecate this, always set explicitly
          Severity: Minor
          Found in app/models/person.rb by fixme

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

                          skip_av = false
                          av_list = l_person_hash['alternate values']
                          av_list ||= {}
                          av_list.each do |av|
                            if av.value == r_person.last_name
          Severity: Major
          Found in app/models/person.rb and 1 other location - About 1 hr to fix
          app/models/person.rb on lines 199..216

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

          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

                          skip_av = false
                          av_list = l_person_hash['alternate values']
                          av_list ||= {}
                          av_list.each do |av|
                            if av.value == r_person.first_name
          Severity: Major
          Found in app/models/person.rb and 1 other location - About 1 hr to fix
          app/models/person.rb on lines 227..244

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

          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

              i = t.project(t['person_id'], t['type'], t['created_at']).from(t)
                .where(t['created_at'].gt(1.weeks.ago))
                .where(t['created_by_id'].eq(user_id))
                .where(t['type'].eq(role_type))
                .order(t['created_at'].desc)
          Severity: Minor
          Found in app/models/person.rb and 1 other location - About 45 mins to fix
          app/models/geographic_area.rb on lines 436..440

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

          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 not_active_before_birth
              errors.add(:year_active_start, 'is younger than than year of birth') if year_active_start && year_born && year_active_start < year_born
              errors.add(:year_active_end, 'is younger than year of birth') if year_active_end && year_born && year_active_end < year_born
            end
          Severity: Minor
          Found in app/models/person.rb and 1 other location - About 15 mins to fix
          app/models/observation/sample.rb on lines 14..17

          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

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

            validates :year_died, inclusion: {in: 0..Time.now.year}, allow_nil: true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

            validates :year_active_start, inclusion: {in: 0..Time.now.year}, allow_nil: true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Use 2 (not 1) spaces for indentation.
          Open

               return false
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for indentation that doesn't use the specified number of spaces.

          See also the IndentationConsistency cop which is the companion to this one.

          Example:

          # bad
          class A
           def test
            puts 'hello'
           end
          end
          
          # good
          class A
            def test
              puts 'hello'
            end
          end

          Example: IgnoredPatterns: ['^\s*module']

          # bad
          module A
          class B
            def test
            puts 'hello'
            end
          end
          end
          
          # good
          module A
          class B
            def test
              puts 'hello'
            end
          end
          end

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

            validates :year_born, inclusion: {in: 0..Time.now.year}, allow_nil: true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Prefer the new style validations validates :column, presence: value over validates_presence_of.
          Open

            validates_presence_of :last_name, :type
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of old-style attribute validation macros.

          Example:

          # bad
          validates_acceptance_of :foo
          validates_confirmation_of :foo
          validates_exclusion_of :foo
          validates_format_of :foo
          validates_inclusion_of :foo
          validates_length_of :foo
          validates_numericality_of :foo
          validates_presence_of :foo
          validates_absence_of :foo
          validates_size_of :foo
          validates_uniqueness_of :foo
          
          # good
          validates :foo, acceptance: true
          validates :foo, confirmation: true
          validates :foo, exclusion: true
          validates :foo, format: true
          validates :foo, inclusion: true
          validates :foo, length: true
          validates :foo, numericality: true
          validates :foo, presence: true
          validates :foo, absence: true
          validates :foo, size: true
          validates :foo, uniqueness: true

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

            validates :year_active_end, inclusion: {in: 0..Time.now.year}, allow_nil: true
          Severity: Minor
          Found in app/models/person.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          There are no issues that match your filters.

          Category
          Status