SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,579 of 12,579 total issues

Prefer symbols instead of strings as hash keys.
Open

                                      '7' => 'TaxonNameRelationship::Typification::Genus::Tautonomy::Linnaean',
Severity: Minor
Found in lib/tasks/import/sf/sf_taxa.rake by rubocop

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

Use find_or_create_by! instead of find_or_create_by if the return value is not checked. Or check persisted? on model returned from find_or_create_by.
Open

                tnr = TaxonNameRelationship.find_or_create_by(
Severity: Minor
Found in lib/tasks/import/sf/sf_taxa.rake by rubocop

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

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

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

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

Example:

# bad
user.save
user.update(name: 'Joe')
user.find_or_create_by(name: 'Joe')
user.destroy

# good
unless user.save
  # ...
end
user.save!
user.update!(name: 'Joe')
user.find_or_create_by!(name: 'Joe')
user.destroy!

user = User.find_or_create_by(name: 'Joe')
unless user.persisted?
  # ...
end

def save_user
  return user.save
end

Example: AllowImplicitReturn: true (default)

# good
users.each { |u| u.save }

def save_user
  user.save
end

Example: AllowImplicitReturn: false

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

# good
users.each { |u| u.save! }

def save_user
  user.save!
end

def save_user
  return user.save
end

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

# bad
merchant.create
customers.builder.save
Mailer.create

module Service::Mailer
  self.create
end

# good
merchant.customers.create
MerchantService.merchant.customers.destroy
Service::Mailer.update(message: 'Message')
::Service::Mailer.update
Services::Service::Mailer.update(message: 'Message')
Service::Mailer::update

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

      puts "#{Time.now.strftime "%H:%M:%S"}."
Severity: Minor
Found in lib/tasks/initialize/geo.rake 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

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

    tags = Keyword.where(project_id:).joins(:tags)

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 tRBRACK (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

      [ObservationMatrixRow.where(project_id:).find(observation_matrix_row_id.to_i)&.observation_object_id.to_i]

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

        where(project_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.

Use page.presence || 1 instead of page.blank? ? 1 : page.
Open

    @page = page.blank? ? 1 : page
Severity: Minor
Found in lib/tools/image_matrix.rb by rubocop

This cop checks code that can be written more easily using Object#presence defined by Active Support.

Example:

# bad
a.present? ? a : nil

# bad
!a.present? ? nil : a

# bad
a.blank? ? nil : a

# bad
!a.blank? ? a : nil

# good
a.presence

Example:

# bad
a.present? ? a : b

# bad
!a.present? ? b : a

# bad
a.blank? ? b : a

# bad
!a.blank? ? a : b

# good
a.presence || b

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

              str = d_name + descriptors_hash[d_key][:observations][otu_collection_object].collect{|o| "%g" % o.continuous_value}.join(' OR ')
Severity: Minor
Found in lib/tools/interactive_key.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Prefer symbols instead of strings as hash keys.
Open

             'malaise' => 'Malaise trap',
Severity: Minor
Found in lib/utilities/collecting_methods.rb by rubocop

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

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

              logger.error "DataAttribute ERROR" + da.errors.full_messages.join(';')

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Prefer symbols instead of strings as hash keys.
Open

                                 '5' => 'TaxonNameRelationship::Iczn::Invalidating::Synonym::Objective::UnjustifiedEmendation',
Severity: Minor
Found in lib/tasks/import/sf/sf_taxa.rake by rubocop

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

Prefer symbols instead of strings as hash keys.
Open

                                      '2' => 'TaxonNameRelationship::Typification::Genus::Original::OriginalDesignation',
Severity: Minor
Found in lib/tasks/import/sf/sf_taxa.rake by rubocop

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

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

        rescue ActiveRecord::RecordInvalid
Severity: Minor
Found in lib/tasks/maintenance/geo.rake 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.

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

        puts Rainbow("Reindex complete.").yellow

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

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

            puts Rainbow("Reseting project preferences").purple
Severity: Minor
Found in lib/tasks/maintenance/projects.rake by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

Please use Rails.root.join('path', 'to') instead.
Open

      package_json_path = Pathname.new("#{Rails.root}/package.json").realpath
Severity: Minor
Found in lib/tasks/shakapacker.rake by rubocop

This cop is used to identify usages of file path joining process to use Rails.root.join clause. It is used to add uniformity when joining paths.

Example: EnforcedStyle: arguments (default)

# bad
Rails.root.join('app/models/goober')
File.join(Rails.root, 'app/models/goober')
"#{Rails.root}/app/models/goober"

# good
Rails.root.join('app', 'models', 'goober')

Example: EnforcedStyle: slashes

# bad
Rails.root.join('app', 'models', 'goober')
File.join(Rails.root, 'app/models/goober')
"#{Rails.root}/app/models/goober"

# good
Rails.root.join('app/models/goober')

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

      .execute("SELECT EXISTS(SELECT * FROM information_schema.tables " \
Severity: Minor
Found in lib/tasks/tw.rake by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

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

  VERSION = "0.41.0"
Severity: Minor
Found in lib/taxonworks/version.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

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

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

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

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

    if observation_matrix_id.to_i == 0 && !otu_filter.blank?
Severity: Minor
Found in lib/tools/image_matrix.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 more than 3 levels of block nesting.
Open

                if o.sample_max
                  d_value[:max] = o.sample_max if d_value[:max] < o.sample_max
                else
                  d_value[:max] = o.sample_min if d_value[:max] < o.sample_min
                end
Severity: Minor
Found in lib/tools/interactive_key.rb by rubocop

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

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

The maximum level of nesting allowed is configurable.

Severity
Category
Status
Source
Language