SpeciesFileGroup/taxonworks

View on GitHub
app/models/collecting_event.rb

Summary

Maintainability
F
3 days
Test Coverage

Possible SQL injection
Open

    retval = CollectingEvent.where(sql)
Severity: Minor
Found in app/models/collecting_event.rb by brakeman

Injection is #1 on the 2013 OWASP Top Ten web security risks. SQL injection is when a user is able to manipulate a value which is used unsafely inside a SQL query. This can lead to data leaks, data loss, elevation of privilege, and other unpleasant outcomes.

Brakeman focuses on ActiveRecord methods dealing with building SQL statements.

A basic (Rails 2.x) example looks like this:

User.first(:conditions => "username = '#{params[:username]}'")

Brakeman would produce a warning like this:

Possible SQL injection near line 30: User.first(:conditions => ("username = '#{params[:username]}'"))

The safe way to do this query is to use a parameterized query:

User.first(:conditions => ["username = ?", params[:username]])

Brakeman also understands the new Rails 3.x way of doing things (and local variables and concatenation):

username = params[:user][:name].downcase
password = params[:user][:password]

User.first.where("username = '" + username + "' AND password = '" + password + "'")

This results in this kind of warning:

Possible SQL injection near line 37:
User.first.where((((("username = '" + params[:user][:name].downcase) + "' AND password = '") + params[:user][:password]) + "'"))

See the Ruby Security Guide for more information and Rails-SQLi.org for many examples of SQL injection in Rails.

Possible SQL injection
Open

        collecting_events = CollectingEvent.where(sql_string).distinct
Severity: Minor
Found in app/models/collecting_event.rb by brakeman

Injection is #1 on the 2013 OWASP Top Ten web security risks. SQL injection is when a user is able to manipulate a value which is used unsafely inside a SQL query. This can lead to data leaks, data loss, elevation of privilege, and other unpleasant outcomes.

Brakeman focuses on ActiveRecord methods dealing with building SQL statements.

A basic (Rails 2.x) example looks like this:

User.first(:conditions => "username = '#{params[:username]}'")

Brakeman would produce a warning like this:

Possible SQL injection near line 30: User.first(:conditions => ("username = '#{params[:username]}'"))

The safe way to do this query is to use a parameterized query:

User.first(:conditions => ["username = ?", params[:username]])

Brakeman also understands the new Rails 3.x way of doing things (and local variables and concatenation):

username = params[:user][:name].downcase
password = params[:user][:password]

User.first.where("username = '" + username + "' AND password = '" + password + "'")

This results in this kind of warning:

Possible SQL injection near line 37:
User.first.where((((("username = '" + params[:user][:name].downcase) + "' AND password = '") + params[:user][:password]) + "'"))

See the Ruby Security Guide for more information and Rails-SQLi.org for many examples of SQL injection in Rails.

Class CollectingEvent has 79 methods (exceeds 20 allowed). Consider refactoring.
Open

class CollectingEvent < ApplicationRecord
  include Housekeeping
  include Shared::Citations
  include Shared::DataAttributes
  include Shared::HasRoles
Severity: Major
Found in app/models/collecting_event.rb - About 1 day to fix

    File collecting_event.rb has 655 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class CollectingEvent < ApplicationRecord
      include Housekeeping
      include Shared::Citations
      include Shared::DataAttributes
      include Shared::HasRoles
    Severity: Major
    Found in app/models/collecting_event.rb - About 1 day to fix

      Method filter_by has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def filter_by(params)
            sql_string = ''
            unless params.blank? # not strictly necessary, but handy for debugging
              sql_string = Utilities::Dates.date_sql_from_params(params)
      
      
      Severity: Minor
      Found in app/models/collecting_event.rb - About 2 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 has too many lines. [32/25]
      Open

          def filter_by(params)
            sql_string = ''
            unless params.blank? # not strictly necessary, but handy for debugging
              sql_string = Utilities::Dates.date_sql_from_params(params)
      
      
      Severity: Minor
      Found in app/models/collecting_event.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 filter_by has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def filter_by(params)
            sql_string = ''
            unless params.blank? # not strictly necessary, but handy for debugging
              sql_string = Utilities::Dates.date_sql_from_params(params)
      
      
      Severity: Minor
      Found in app/models/collecting_event.rb - About 1 hr to fix

        Method update_verbatim_georeferences has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_verbatim_georeferences
              if Rails.env == 'production'
                puts "You can't run this in #{Rails.env} mode."
                exit
              end
        Severity: Minor
        Found in app/models/collecting_event.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

        Method similar_lat_longs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def similar_lat_longs(lat, long, project_id, piece = '', include_values = true)
            sql = '('
            sql += "verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(lat)}%'" unless lat.blank?
            sql += " or verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(long)}%'" unless long.blank?
            sql += " or verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(piece)}%'" unless piece.blank?
        Severity: Minor
        Found in app/models/collecting_event.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

        Method similar_lat_longs has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def similar_lat_longs(lat, long, project_id, piece = '', include_values = true)
        Severity: Minor
        Found in app/models/collecting_event.rb - About 35 mins to fix

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

            def generate_verbatim_data_georeference(reference_self = false, no_cached: false)
              return false if (verbatim_latitude.nil? || verbatim_longitude.nil?)
              begin
                CollectingEvent.transaction do
                  vg_attributes = {collecting_event_id: id.to_s, no_cached: no_cached}
          Severity: Minor
          Found in app/models/collecting_event.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 get_geographic_name_classification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_geographic_name_classification
              case geographic_name_classification_method
              when :preferred_georeference
                # quick
                r = preferred_georeference.geographic_item.quick_geographic_name_hierarchy # almost never the case, UI not setup to do this
          Severity: Minor
          Found in app/models/collecting_event.rb - About 25 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 verbatim_map_center has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def verbatim_map_center(delta_z = 0.0)
              retval = nil
              unless verbatim_latitude.blank? or verbatim_longitude.blank?
                lat     = Utilities::Geo.degrees_minutes_seconds_to_decimal_degrees(verbatim_latitude.to_s)
                long    = Utilities::Geo.degrees_minutes_seconds_to_decimal_degrees(verbatim_longitude.to_s)
          Severity: Minor
          Found in app/models/collecting_event.rb - About 25 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

          Favor Rails.env.production? over Rails.env == 'production'.
          Open

                if Rails.env == 'production'
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks that Rails.env is compared using .production?-like methods instead of equality against a string or symbol.

          Example:

          # bad
          Rails.env == 'production'
          
          # bad, always returns false
          Rails.env == :test
          
          # good
          Rails.env.production?

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                puts "attempted: #{attempted}"
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

          Use start_date_year.present? instead of !start_date_year.blank?.
          Open

              !start_date_day.blank? && !start_date_month.blank? && !start_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 end_date_year.present? instead of !end_date_year.blank?.
          Open

              !end_date_day.blank? && !end_date_month.blank? && !end_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 minimum_elevation.present? instead of !minimum_elevation.blank?.
          Open

              errors.add(:maximum_elevation, 'Maximum elevation is lower than minimum elevation.') if !minimum_elevation.blank? && !maximum_elevation.blank? && maximum_elevation < minimum_elevation
          Severity: Minor
          Found in app/models/collecting_event.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 self.send(v).present? instead of !self.send(v).blank?.
          Open

                return true if !self.send(v).blank?
          Severity: Minor
          Found in app/models/collecting_event.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?

          Specify a :dependent option.
          Open

            has_one :verbatim_data_georeference, class_name: 'Georeference::VerbatimData'
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

          Example:

          # bad
          class User < ActiveRecord::Base
            has_many :comments
            has_one :avatar
          end
          
          # good
          class User < ActiveRecord::Base
            has_many :comments, dependent: :restrict_with_exception
            has_one :avatar, dependent: :destroy
            has_many :patients, through: :appointments
          end

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                puts "failed: #{failed}"
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

          Use self.time_start_minute.present? instead of !self.time_start_minute.blank?.
          Open

            validates_presence_of :time_start_hour, if: -> { !self.time_start_minute.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 self.time_end_second.present? instead of !self.time_end_second.blank?.
          Open

            validates_presence_of :time_end_minute, if: -> { !self.time_end_second.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 id_fragment.present? instead of unless id_fragment.blank?.
          Open

                  unless id_fragment.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 piece.present? instead of unless piece.blank?.
          Open

              sql += " or verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(piece)}%'" unless piece.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 verbatim_collectors.present? instead of !verbatim_collectors.blank?.
          Open

              !verbatim_collectors.blank? || collectors.any?
          Severity: Minor
          Found in app/models/collecting_event.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 sql_string.present? instead of unless sql_string.blank?.
          Open

                    unless sql_string.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 start_date_day.present? instead of !start_date_day.blank?.
          Open

              !start_date_day.blank? && !start_date_month.blank? && !start_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 params.present? instead of unless params.blank?.
          Open

                unless params.blank? # not strictly necessary, but handy for debugging
          Severity: Minor
          Found in app/models/collecting_event.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 v_locality_fragment.present? instead of unless v_locality_fragment.blank?.
          Open

                  unless v_locality_fragment.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 lat.present? instead of unless lat.blank?.
          Open

              sql += "verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(lat)}%'" unless lat.blank?
          Severity: Minor
          Found in app/models/collecting_event.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?

          Avoid using update_columns because it skips validations.
          Open

              update_columns(cached: string)
          Severity: Minor
          Found in app/models/collecting_event.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 self.time_end_minute.present? instead of !self.time_end_minute.blank?.
          Open

            validates_presence_of :time_end_hour, if: -> { !self.time_end_minute.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 sql_string.present? instead of unless sql_string.blank?.
          Open

                    unless sql_string.blank?
          Severity: Minor
          Found in app/models/collecting_event.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?

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                    puts "failed for #{c.id}, #{g.errors.full_messages.join('; ')}"
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

          Use end_date_day.present? instead of !end_date_day.blank?.
          Open

              !end_date_day.blank? && !end_date_month.blank? && !end_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 verbatim_geolocation_uncertainty.present? instead of !verbatim_geolocation_uncertainty.blank?.
          Open

              errors.add(:verbatim_geolocation_uncertainty, 'Provide both verbatim_latitude and verbatim_longitude if you provide verbatim_uncertainty.') if !verbatim_geolocation_uncertainty.blank? && verbatim_longitude.blank? && verbatim_latitude.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 verbatim_latitude.present? instead of !verbatim_latitude.blank?.
          Open

            validates_presence_of :verbatim_longitude, if: -> { !verbatim_latitude.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 self.time_start_second.present? instead of !self.time_start_second.blank?.
          Open

            validates_presence_of :time_start_minute, if: -> { !self.time_start_second.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 maximum_elevation.present? instead of !maximum_elevation.blank?.
          Open

              errors.add(:maximum_elevation, 'Maximum elevation is lower than minimum elevation.') if !minimum_elevation.blank? && !maximum_elevation.blank? && maximum_elevation < minimum_elevation
          Severity: Minor
          Found in app/models/collecting_event.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(:verbatim_label, value)
          Severity: Minor
          Found in app/models/collecting_event.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(:time_end, nil) if matches.include?(self.time_end.to_s)
          Severity: Minor
          Found in app/models/collecting_event.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_columns because it skips validations.
          Open

              update_columns(
          Severity: Minor
          Found in app/models/collecting_event.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

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                puts "passed: #{passed}"
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

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

                  unless any_label_fragment.blank?
          Severity: Minor
          Found in app/models/collecting_event.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 start_date_month.present? instead of !start_date_month.blank?.
          Open

              !start_date_day.blank? && !start_date_month.blank? && !start_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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?

          Do not use exit in Rails applications.
          Open

                  exit
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop enforces that exit calls are not used within a rails app. Valid options are instead to raise an error, break, return, or some other form of stopping execution of current request.

          There are two obvious cases where exit is particularly harmful:

          • Usage in library code for your application. Even though Rails will rescue from a SystemExit and continue on, unit testing that library code will result in specs exiting (potentially silently if exit(0) is used.)
          • Usage in application code outside of the web process could result in the program exiting, which could result in the code failing to run and do its job.

          Example:

          # bad
          exit(0)
          
          # good
          raise 'a bad error has happened'

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                  puts "You can't run this in #{Rails.env} mode."
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

          Prefer 1.week.
          Open

            scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
          Severity: Minor
          Found in app/models/collecting_event.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 self.send(a).present? instead of unless self.send(a).blank?.
          Open

                return true unless self.send(a).blank?
          Severity: Minor
          Found in app/models/collecting_event.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 long.present? instead of unless long.blank?.
          Open

              sql += " or verbatim_label LIKE '%#{::Utilities::Strings.escape_single_quote(long)}%'" unless long.blank?
          Severity: Minor
          Found in app/models/collecting_event.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?

          Specify an :inverse_of option.
          Open

            has_one :preferred_georeference, -> { order(:position) }, class_name: 'Georeference', foreign_key: :collecting_event_id
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop looks for has(one|many) and belongsto associations where Active Record can't automatically determine the inverse association because of a scope or the options used. Using the blog with order scope example below, traversing the a Blog's association in both directions with blog.posts.first.blog would cause the blog to be loaded from the database twice.

          :inverse_of must be manually specified for Active Record to use the associated object in memory, or set to false to opt-out. Note that setting nil does not stop Active Record from trying to determine the inverse automatically, and is not considered a valid value for this.

          Example:

          # good
          class Blog < ApplicationRecord
            has_many :posts
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end

          Example:

          # bad
          class Blog < ApplicationRecord
            has_many :posts, -> { order(published_at: :desc) }
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: :blog)
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            with_options inverse_of: :blog do
              has_many :posts, -> { order(published_at: :desc) }
            end
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          # When you don't want to use the inverse association.
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: false)
          end

          Example:

          # bad
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          # good
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end

          Example:

          # bad
          # However, RuboCop can not detect this pattern...
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician
            belongs_to :patient
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end
          
          # good
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician, inverse_of: :appointments
            belongs_to :patient, inverse_of: :appointments
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end

          @see https://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

          Do not write to stdout. Use Rails's logger if you want to log.
          Open

                    puts "created for #{c.id}"
          Severity: Minor
          Found in app/models/collecting_event.rb by rubocop

          This cop checks for the use of output calls like puts and print

          Example:

          # bad
          puts 'A debug message'
          pp 'A debug message'
          print 'A debug message'
          
          # good
          Rails.logger.debug 'A debug message'

          Use verbatim_date.present? instead of !verbatim_date.blank?.
          Open

              !verbatim_date.blank? || some_start_date? || some_end_date?
          Severity: Minor
          Found in app/models/collecting_event.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(:time_start, nil) if matches.include?(self.time_start.to_s)
          Severity: Minor
          Found in app/models/collecting_event.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 find_each instead of each.
          Open

                CollectingEvent.includes(:georeferences).where(georeferences: {id: nil}).each do |c|
          Severity: Minor
          Found in app/models/collecting_event.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

          Use verbatim_longitude.present? instead of !verbatim_longitude.blank?.
          Open

            validates_presence_of :verbatim_latitude, if: -> { !verbatim_longitude.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 end_date_month.present? instead of !end_date_month.blank?.
          Open

              !end_date_day.blank? && !end_date_month.blank? && !end_date_year.blank?
          Severity: Minor
          Found in app/models/collecting_event.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(:md5_of_verbatim_label, Utilities::Strings.generate_md5(value))
          Severity: Minor
          Found in app/models/collecting_event.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

          TODO found
          Open

              #   TODO: this needs to be in a rake task or somewhere else
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

            # @TODO: See Utilities::Geo.distance_in_meters(String)
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

              # TODO: this will be impossibly slow in present form
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

            # TODO: parametrize to include gazeteer
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

                where(q.between_date_range.to_sql).distinct # TODO: uniq should likely not be here
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

              # TODO: use joins(:geographic_items).where(containing scope), simplied to
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

              # TODO: DRY, use general form of this
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

              # TODO: deprecate for lib/queries/collecting_event
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

            #   TODO: deprecate
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

              # TODO: remove all of this for direct call to Queries::CollectingEvent::Filter
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

          TODO found
          Open

            #   TODO: include initials when we find out a clean way of producing them
          Severity: Minor
          Found in app/models/collecting_event.rb by fixme

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

            def georeference_latitude
              retval = 0.0
              if georeferences.count > 0
                retval = Georeference.where(collecting_event_id: self.id).order(:position).limit(1)[0].latitude.to_f
              end
          Severity: Minor
          Found in app/models/collecting_event.rb and 1 other location - About 20 mins to fix
          app/models/collecting_event.rb on lines 1069..1074

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

          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 georeference_longitude
              retval = 0.0
              if georeferences.count > 0
                retval = Georeference.where(collecting_event_id: self.id).order(:position).limit(1)[0].longitude.to_f
              end
          Severity: Minor
          Found in app/models/collecting_event.rb and 1 other location - About 20 mins to fix
          app/models/collecting_event.rb on lines 1061..1066

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

          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

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

            validates_presence_of :verbatim_longitude, if: -> { !verbatim_latitude.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

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

            validates_presence_of :end_date_month, if: -> { !end_date_day.nil? }
          Severity: Minor
          Found in app/models/collecting_event.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

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

            validates_presence_of :time_end_minute, if: -> { !self.time_end_second.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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 :end_date_year, date_year: {min_year: 1000, max_year: Time.now.year + 5}
          Severity: Minor
          Found in app/models/collecting_event.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 :start_date_year, date_year: {min_year: 1000, max_year: Time.now.year + 5}
          Severity: Minor
          Found in app/models/collecting_event.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, uniqueness: value over validates_uniqueness_of.
          Open

            validates_uniqueness_of :md5_of_verbatim_label, scope: [:project_id], unless: -> { verbatim_label.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

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

            validates_presence_of :start_date_month, if: -> { !start_date_day.nil? }
          Severity: Minor
          Found in app/models/collecting_event.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

                  CollectingEvent.where(project_id: project_id, updated_by_id: user_id, created_at: 3.hours.ago..Time.now).limit(5).to_a).uniq,
          Severity: Minor
          Found in app/models/collecting_event.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

              a.verbatim_label = [verbatim_label, "[CLONED FROM #{id}", "at #{Time.now}]"].compact.join(' ')
          Severity: Minor
          Found in app/models/collecting_event.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 :time_start_minute, if: -> { !self.time_start_second.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

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

            validates_presence_of :time_end_hour, if: -> { !self.time_end_minute.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

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

            validates_presence_of :time_start_hour, if: -> { !self.time_start_minute.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

            scope :used_recently, -> { joins(:collection_objects).where(collection_objects: { created_at: 1.weeks.ago..Time.now } ) }
          Severity: Minor
          Found in app/models/collecting_event.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 :verbatim_latitude, if: -> { !verbatim_longitude.blank? }
          Severity: Minor
          Found in app/models/collecting_event.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

          There are no issues that match your filters.

          Category
          Status