SpeciesFileGroup/taxonworks

View on GitHub
app/models/taxon_name_relationship.rb

Summary

Maintainability
F
3 days
Test Coverage

Class TaxonNameRelationship has 56 methods (exceeds 20 allowed). Consider refactoring.
Open

class TaxonNameRelationship < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::Notes
  include Shared::IsData
Severity: Major
Found in app/models/taxon_name_relationship.rb - About 1 day to fix

    File taxon_name_relationship.rb has 428 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_dependency Rails.root.to_s + '/app/models/taxon_name_classification.rb'  
    
    # A NOMEN https://github.com/SpeciesFileGroup/nomen relationship between two Protonyms.
    #
    # Unless otherwise noted relationships read left to right, and can be interpreted by inserting "of" after the class name.
    Severity: Minor
    Found in app/models/taxon_name_relationship.rb - About 6 hrs to fix

      Method has too many lines. [53/25]
      Open

        def set_cached_names_for_taxon_names
          begin
            TaxonName.transaction do
              if is_combination?
                t = object_taxon_name

      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 validate_subject_and_object_ranks has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_subject_and_object_ranks
          tname = self.type_name
      
          if tname =~ /TaxonNameRelationship::(Icnp|Icn|Iczn|Ictv)/ && tname != 'TaxonNameRelationship::Iczn::Validating::UncertainPlacement'
            rank_group = self.subject_taxon_name.rank_class.try(:parent)
      Severity: Minor
      Found in app/models/taxon_name_relationship.rb - About 4 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

      Method set_cached_names_for_taxon_names has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def set_cached_names_for_taxon_names
          begin
            TaxonName.transaction do
              if is_combination?
                t = object_taxon_name
      Severity: Major
      Found in app/models/taxon_name_relationship.rb - About 2 hrs to fix

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

          def set_cached_names_for_taxon_names
            begin
              TaxonName.transaction do
                if is_combination?
                  t = object_taxon_name
        Severity: Minor
        Found in app/models/taxon_name_relationship.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 validate_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def validate_type
            unless TAXON_NAME_RELATIONSHIP_NAMES.include?(type)
              errors.add(:type, "'#{type}' is not a valid taxon name relationship")
            end
        
        
        Severity: Minor
        Found in app/models/taxon_name_relationship.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 sv_fix_combination_relationship has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def sv_fix_combination_relationship
            s = self.subject_taxon_name
            list = s.list_of_coordinated_names + [s]
            if s.rank_string =~ /Species/
              s_new = list.detect{|t| t.rank_class.rank_name == 'species'}
        Severity: Minor
        Found in app/models/taxon_name_relationship.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

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

          def sv_fix_subject_parent_update
            if TAXON_NAME_RELATIONSHIP_NAMES_SYNONYM.include?(self.type_name)
              obj = self.object_taxon_name
              subj = self.subject_taxon_name
              unless obj.parent_id == subj.parent_id
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb - About 35 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Avoid more than 3 levels of block nesting.
        Open

                  unless self.type_class.valid_subject_ranks.include?(self.subject_taxon_name.parent.rank_string)
                    soft_validations.add(:subject_taxon_name_id, "#{self.subject_taxon_name.rank_class.rank_name.capitalize} rank of #{self.subject_taxon_name.cached_html} is not compatible with the #{self.subject_status} relationship")
                    soft_validations.add(:type, "Relationship #{self.subject_status} is not compatible with the #{self.subject_taxon_name.rank_class.rank_name} rank of #{self.subject_taxon_name.cached_html}")
                  end

        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

                  unless self.type_class.valid_object_ranks.include?(self.object_taxon_name.rank_string)
                    errors.add(:object_taxon_name_id, "#{self.object_taxon_name.rank_class.rank_name.capitalize} rank of #{self.object_taxon_name.cached_html} is not compatible with the #{self.subject_status} relationship")
                    errors.add(:type, "Relationship #{self.subject_status} is not compatible with the #{self.object_taxon_name.rank_class.rank_name} rank of #{self.object_taxon_name.cached_html}")
                  end

        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.

        Prefer self[:attr] over read_attribute(:attr).
        Open

            r = read_attribute(:type).to_s

        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

                    t.update_column(:cached_misspelling, t.get_cached_misspelling)

        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

        Avoid using update_columns because it skips validations.
        Open

                  t.update_columns(

        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

        Avoid using update_column because it skips validations.
        Open

                    s.update_column(:cached_valid_taxon_name_id, vn.id)

        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

        Avoid using update_column because it skips validations.
        Open

                      c.update_column(:cached_valid_taxon_name_id, vn.id)

        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

        Avoid using update_columns because it skips validations.
        Open

                  t.update_columns(

        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 save! instead of save if the return value is not checked.
        Open

                  self.save

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        Use save! instead of save if the return value is not checked.
        Open

                  self.save

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        Redundant receiver in with_options.
        Open

            v.validate :validate_subject_and_object_share_code,

        This cop checks for redundant receiver in with_options. Receiver is implicit from Rails 4.2 or higher.

        Example:

        # bad
        class Account < ApplicationRecord
          with_options dependent: :destroy do |assoc|
            assoc.has_many :customers
            assoc.has_many :products
            assoc.has_many :invoices
            assoc.has_many :expenses
          end
        end
        
        # good
        class Account < ApplicationRecord
          with_options dependent: :destroy do
            has_many :customers
            has_many :products
            has_many :invoices
            has_many :expenses
          end
        end

        Example:

        # bad
        with_options options: false do |merger|
          merger.invoke(merger.something)
        end
        
        # good
        with_options options: false do
          invoke(something)
        end
        
        # good
        client = Client.new
        with_options options: false do |merger|
          client.invoke(merger.something, something)
        end
        
        # ok
        # When `with_options` includes a block, all scoping scenarios
        # cannot be evaluated. Thus, it is ok to include the explicit
        # receiver.
        with_options options: false do |merger|
          merger.invoke
          with_another_method do |another_receiver|
            merger.invoke(another_receiver)
          end
        end

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

            write_attribute(:type, value.to_s)

        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 save! instead of save if the return value is not checked.
        Open

                    subj.save

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        Avoid using update_columns because it skips validations.
        Open

                    t.update_columns(

        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

        Avoid using update_column because it skips validations.
        Open

                    c.update_column(:cached_valid_taxon_name_id, vn.id)

        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 save! instead of save if the return value is not checked.
        Open

                  self.save

        This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to save and an exception is better than unhandled failure.

        This will allow: - update or save calls, assigned to a variable, or used as a condition in an if/unless/case statement. - create calls, assigned to a variable that then has a call to persisted?. - calls if the result is explicitly returned from methods and blocks, or provided as arguments. - calls whose signature doesn't look like an ActiveRecord persistence method.

        By default it will also allow implicit returns from methods and blocks. that behavior can be turned off with AllowImplicitReturn: false.

        You can permit receivers that are giving false positives with AllowedReceivers: []

        Example:

        # bad
        user.save
        user.update(name: 'Joe')
        user.find_or_create_by(name: 'Joe')
        user.destroy
        
        # good
        unless user.save
          # ...
        end
        user.save!
        user.update!(name: 'Joe')
        user.find_or_create_by!(name: 'Joe')
        user.destroy!
        
        user = User.find_or_create_by(name: 'Joe')
        unless user.persisted?
          # ...
        end
        
        def save_user
          return user.save
        end

        Example: AllowImplicitReturn: true (default)

        # good
        users.each { |u| u.save }
        
        def save_user
          user.save
        end

        Example: AllowImplicitReturn: false

        # bad
        users.each { |u| u.save }
        def save_user
          user.save
        end
        
        # good
        users.each { |u| u.save! }
        
        def save_user
          user.save!
        end
        
        def save_user
          return user.save
        end

        Example: AllowedReceivers: ['merchant.customers', 'Service::Mailer']

        # bad
        merchant.create
        customers.builder.save
        Mailer.create
        
        module Service::Mailer
          self.create
        end
        
        # good
        merchant.customers.create
        MerchantService.merchant.customers.destroy
        Service::Mailer.update(message: 'Message')
        ::Service::Mailer.update
        Services::Service::Mailer.update(message: 'Message')
        Service::Mailer::update

        Avoid using update_columns because it skips validations.
        Open

                    t.update_columns(

        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

        Do not use to_time on Date objects, because they know nothing about the time zone in use.
        Open

            self.source ? (self.source.cached_nomenclature_date ? self.source.cached_nomenclature_date.to_time : Time.now) : Time.now

        This cop checks for the correct use of Date methods, such as Date.today, Date.current etc.

        Using Date.today is dangerous, because it doesn't know anything about Rails time zone. You must use Time.zone.today instead.

        The cop also reports warnings when you are using to_time method, because it doesn't know about Rails time zone either.

        Two styles are supported for this cop. When EnforcedStyle is 'strict' then the Date methods today, current, yesterday, and tomorrow are prohibited and the usage of both to_time and 'totimeincurrentzone' are reported as warning.

        When EnforcedStyle is 'flexible' then only Date.today is prohibited and only to_time is reported as warning.

        Example: EnforcedStyle: strict

        # bad
        Date.current
        Date.yesterday
        Date.today
        date.to_time
        
        # good
        Time.zone.today
        Time.zone.today - 1.day

        Example: EnforcedStyle: flexible (default)

        # bad
        Date.today
        date.to_time
        
        # good
        Time.zone.today
        Time.zone.today - 1.day
        Date.current
        Date.yesterday
        date.in_time_zone

        Avoid using update_column because it skips validations.
        Open

                    t.update_column( :cached_author_year, t.get_author_and_year)

        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 self.type_class.present? instead of unless self.type_class.blank?.
        Open

            unless self.type_class.blank? # only validate if it is set

        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: why isn't this disjoint?
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb by fixme

        TODO found
        Open

          # TODO: Isolate to individual classes per type
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb by fixme

        TODO found
        Open

                elsif type_name =~/TaxonNameRelationship::Hybrid/ # TODO: move to Hybrid
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb by fixme

        TODO found
        Open

          # @TODO SourceClassifiedAs is not really Combination in the other sense
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb by fixme

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

          def sv_validate_disjoint_subject
            classifications = self.subject_taxon_name.taxon_name_classifications.reload.map {|i| i.type_name}
            disjoint_subject_classes = self.type_class.disjoint_subject_classes
            compare = disjoint_subject_classes & classifications
            compare.each do |i|
        Severity: Major
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 1 hr to fix
        app/models/taxon_name_relationship.rb on lines 448..455

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

        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 sv_validate_disjoint_object
            classifications = self.object_taxon_name.taxon_name_classifications.reload.map {|i| i.type_name}
            disjoint_object_classes = self.type_class.disjoint_object_classes
            compare = disjoint_object_classes & classifications
            compare.each do |i|
        Severity: Major
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 1 hr to fix
        app/models/taxon_name_relationship.rb on lines 459..466

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

        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

                    errors.add(:object_taxon_name_id, "#{self.object_taxon_name.rank_class.rank_name.capitalize} rank of #{self.object_taxon_name.cached_html} is not compatible with the #{self.subject_status} relationship")
                    errors.add(:type, "Relationship #{self.subject_status} is not compatible with the #{self.object_taxon_name.rank_class.rank_name} rank of #{self.object_taxon_name.cached_html}")
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 45 mins to fix
        app/models/taxon_name_relationship.rb on lines 318..319

        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

                    soft_validations.add(:subject_taxon_name_id, "#{self.subject_taxon_name.rank_class.rank_name.capitalize} rank of #{self.subject_taxon_name.cached_html} is not compatible with the #{self.subject_status} relationship")
                    soft_validations.add(:type, "Relationship #{self.subject_status} is not compatible with the #{self.subject_taxon_name.rank_class.rank_name} rank of #{self.subject_taxon_name.cached_html}")
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 45 mins to fix
        app/models/taxon_name_relationship.rb on lines 309..310

        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

              soft_validations.add(:subject_taxon_name_id, "Relationship should move from #{s.rank_class.rank_name} #{s.cached_html} to #{s_new.rank_class.rank_name} #{s.cached_html}",
                                   fix: :sv_fix_coordinated_subject_taxa, success_message: "Relationship moved to  #{s_new.rank_class.rank_name}")
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 25 mins to fix
        app/models/taxon_name_relationship.rb on lines 698..699

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

        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

              soft_validations.add(:object_taxon_name_id, "Relationship should move from #{o.rank_class.rank_name} #{o.cached_html} to #{o_new.rank_class.rank_name} #{o.cached_html}",
                                   fix: :sv_fix_coordinated_object_taxa, success_message: "Relationship moved to  #{o_new.rank_class.rank_name}")
        Severity: Minor
        Found in app/models/taxon_name_relationship.rb and 1 other location - About 25 mins to fix
        app/models/taxon_name_relationship.rb on lines 688..689

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

        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

            self.source ? (self.source.cached_nomenclature_date ? self.source.cached_nomenclature_date.to_time : Time.now) : Time.now

        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

        Redundant use of Object#to_s in interpolation.
        Open

              errors.add(:object_taxon_name_id, "#{self.object_taxon_name.try(:cached_html).to_s} should not refer to itself") unless self.type =~ /OriginalCombination/

        This cop checks for string conversion in string interpolation, which is redundant.

        Example:

        # bad
        
        "result is #{something.to_s}"

        Example:

        # good
        
        "result is #{something}"

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

          validates_presence_of :subject_taxon_name, message: 'Missing taxon name on the left side'

        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

        Prefer single-quoted strings when you don't need string interpolation or special symbols.
        Open

            where("taxon_name_relationships.type LIKE ? OR taxon_name_relationships.type LIKE ?", "#{base_string1}%", "#{base_string2}%") }

        Checks if uses of quotes match the configured preference.

        Example: EnforcedStyle: single_quotes (default)

        # bad
        "No special symbols"
        "No string interpolation"
        "Just text"
        
        # good
        'No special symbols'
        'No string interpolation'
        'Just text'
        "Wait! What's #{this}!"

        Example: EnforcedStyle: double_quotes

        # bad
        'Just some text'
        'No special chars or interpolation'
        
        # good
        "Just some text"
        "No special chars or interpolation"
        "Every string in #{project} uses double_quotes"

        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

            self.source ? (self.source.cached_nomenclature_date ? self.source.cached_nomenclature_date.to_time : Time.now) : Time.now

        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, uniqueness: value over validates_uniqueness_of.
        Open

          validates_uniqueness_of :object_taxon_name_id, scope: :type, if: :is_combination?

        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

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

          validates_presence_of :type, message: 'Relationship type should be specified'

        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

        Use 2 (not 0) spaces for indentation.
        Open

                soft_validations.add(:subject_taxon_name_id, "#{self.subject_status.capitalize}  #{subj.cached_html_name_and_author_year} should have the same parent with  #{obj.cached_html_name_and_author_year}",

        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

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

          validates_presence_of :object_taxon_name, message: 'Missing taxon name on the right side'

        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

        Prefer the new style validations validates :column, uniqueness: value over validates_uniqueness_of.
        Open

          validates_uniqueness_of :object_taxon_name_id, scope: [:type, :subject_taxon_name_id], unless: :is_combination?

        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

        There are no issues that match your filters.

        Category
        Status