armandofox/audience1st

View on GitHub
lib/tasks/clients.rake

Summary

Maintainability
Test Coverage

Use sample(8) instead of shuffle[0,8].
Open

      admin_pw = ENV['ADMIN_PASSWORD'] || ('a'..'z').to_a.shuffle[0,8].join
Severity: Minor
Found in lib/tasks/clients.rake by rubocop

This cop is used to identify usages of shuffle.first, shuffle.last and shuffle[] and change them to use sample instead.

Example:

# bad
[1, 2, 3].shuffle.first
[1, 2, 3].shuffle.first(2)
[1, 2, 3].shuffle.last
[1, 2, 3].shuffle[2]
[1, 2, 3].shuffle[0, 2]    # sample(2) will do the same
[1, 2, 3].shuffle[0..2]    # sample(3) will do the same
[1, 2, 3].shuffle(random: Random.new).first

# good
[1, 2, 3].shuffle
[1, 2, 3].sample
[1, 2, 3].sample(3)
[1, 2, 3].shuffle[1, 3]    # sample(3) might return a longer Array
[1, 2, 3].shuffle[1..3]    # sample(3) might return a longer Array
[1, 2, 3].shuffle[foo, bar]
[1, 2, 3].shuffle(random: Random.new)

Use tr instead of gsub.
Open

        :venue              => ENV['VENUE_FULLNAME'].gsub(/_/,' '),
Severity: Minor
Found in lib/tasks/clients.rake by rubocop

This cop identifies places where gsub can be replaced by tr or delete.

Example:

# bad
'abc'.gsub('b', 'd')
'abc'.gsub('a', '')
'abc'.gsub(/a/, 'd')
'abc'.gsub!('a', 'd')

# good
'abc'.gsub(/.*/, 'a')
'abc'.gsub(/a+/, 'd')
'abc'.tr('b', 'd')
'a b c'.delete(' ')

There are no issues that match your filters.

Category
Status