SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,635 of 12,635 total issues

Prefer 1.month.
Open

           .where(t['updated_at'].gt( 1.months.ago ))
Severity: Minor
Found in app/models/keyword.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

unexpected token tCOMMA (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    a = Loan.where(project_id:, updated_at: (3.weeks.ago..1.day.from_now))
Severity: Minor
Found in app/models/loan.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tCOMMA (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

          project_id:,
Severity: Minor
Found in app/models/loan_item.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

            created.push LoanItem.create!(loan_item_object: o, loan_id:)
Severity: Minor
Found in app/models/loan_item.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

            created.push LoanItem.create!(loan_item_object: o.tag_object, loan_id:)
Severity: Minor
Found in app/models/loan_item.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

dynamic constant assignment (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    REQUEST_PARAMS = {

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

class definition in method body (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

  class Request

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

Freeze mutable objects assigned to constants.
Open

  DOI_MATCH = /^(doi:|http(s)?:\/\/(dx\.)?doi\.org\/)/i
Severity: Minor
Found in app/models/identifier/global/doi.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

Example: EnforcedStyle: literals (default)

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

# good
CONST = <<~TESTING.freeze
  This is a heredoc
TESTING

# good
CONST = Something.new

Example: EnforcedStyle: strict

# bad
CONST = Something.new

# bad
CONST = Struct.new do
  def foo
    puts 1
  end
end

# good
CONST = Something.new.freeze

# good
CONST = Struct.new do
  def foo
    puts 1
  end
end.freeze

Avoid more than 3 levels of block nesting.
Open

          if check_byte == 11
            check_byte = 0
          end

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

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

The maximum level of nesting allowed is configurable.

Avoid more than 3 levels of block nesting.
Open

            if serial < 3000
              century = '18'
            end

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

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

The maximum level of nesting allowed is configurable.

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

        if (year > Time.now.year) or (year < 2001)

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

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

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

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

Example: EnforcedStyle: strict

# `strict` means that `Time` should be used with `zone`.

# bad
Time.now
Time.parse('2015-03-02 19:05:37')

# bad
Time.current
Time.at(timestamp).in_time_zone

# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')

Example: EnforcedStyle: flexible (default)

# `flexible` allows usage of `in_time_zone` instead of `zone`.

# bad
Time.now
Time.parse('2015-03-02 19:05:37')

# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')

# good
Time.current
Time.at(timestamp).in_time_zone

Use 2 (not 4) spaces for indentation.
Open

    validate :source_use_only

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

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

Example:

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

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

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

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

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

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

    write_attribute(:identifier, ::Utilities::Strings.increment_contained_integer(identifier))
Severity: Minor
Found in app/models/identifier/local.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

unexpected token tRCURLY (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

      .where(i: {id:})

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

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

  validates_uniqueness_of :name
Severity: Minor
Found in app/models/import.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 :import_predicate
Severity: Minor
Found in app/models/import_attribute.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

unexpected token tLABEL (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

        src_data: record

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tRPAREN (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    if id.nil? || (@event_id_identifier_namespace ||= Namespace.find_by(id:)).nil?

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tCOMMA (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    return { moved:, unmoved: }
Severity: Minor
Found in app/models/loan_item.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

unexpected token tCOMMA (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

          i = LoanItem.create!(loan_item_object: co, by: user_id, loan_id:, project_id:)
Severity: Minor
Found in app/models/loan_item.rb by rubocop

This is not actually a cop. It does not inspect anything. It just provides methods to repack Parser's diagnostics/errors into RuboCop's offenses.

Severity
Category
Status
Source
Language