SpeciesFileGroup/taxonworks

View on GitHub
lib/catalog/collection_object.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method data_for has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.data_for(collection_object)
    o = collection_object
    data = Catalog::CollectionObject::Entry.new(o)

    data.items << Catalog::CollectionObject::EntryItem.new(type: :collected_on, object: o.collecting_event, start_date: o.collecting_event.start_date, end_date: o.collecting_event.end_date) if o.collecting_event_id.present?
Severity: Major
Found in lib/catalog/collection_object.rb - About 4 hrs to fix

    Method data_for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.data_for(collection_object)
        o = collection_object
        data = Catalog::CollectionObject::Entry.new(o)
    
        data.items << Catalog::CollectionObject::EntryItem.new(type: :collected_on, object: o.collecting_event, start_date: o.collecting_event.start_date, end_date: o.collecting_event.end_date) if o.collecting_event_id.present?
    Severity: Minor
    Found in lib/catalog/collection_object.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

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

            start_date: b.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: (li.returned? ? li.date_returned.to_time : li.loan.date_closed.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

          start_date: o.created_at.to_time)  if o.container
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: li.loan.date_sent.to_time
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: d.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: d.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: n.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: d.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

        data.items << Catalog::CollectionObject::EntryItem.new(type: :digital_record_created_by, object: o.creator, start_date: o.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

          date = t&.source&.nomenclature_date&.to_time
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

        data.items << Catalog::CollectionObject::EntryItem.new(type: :digital_record_updated_by, object: o.updater, start_date: o.updated_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: v.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: (li.returned? ? li.date_returned.to_time : li.loan.date_closed.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            start_date: g.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

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

            type: :tagged, object: t, start_date: t.created_at.to_time)
    Severity: Minor
    Found in lib/catalog/collection_object.rb by rubocop

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

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

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

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

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

    Example: EnforcedStyle: strict

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

    Example: EnforcedStyle: flexible (default)

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

    TODO found
    Open

          # TODO: extracts, sequences,
    Severity: Minor
    Found in lib/catalog/collection_object.rb by fixme

    There are no issues that match your filters.

    Category
    Status