18F/e-manifest

View on GitHub
app/helpers/example_json_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage

Missing top-level module documentation comment.
Open

module ExampleJsonHelper
Severity: Minor
Found in app/helpers/example_json_helper.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Favor format over String#%.
Open

    num = '%09d' % SecureRandom.random_number(1_000_000_000)
Severity: Minor
Found in app/helpers/example_json_helper.rb by rubocop

This cop enforces the use of a single string formatting utility. Valid options include Kernel#format, Kernel#sprintf and String#%.

The detection of String#% cannot be implemented in a reliable manner for all cases, so only two scenarios are considered - if the first argument is a string literal and if the second argument is an array literal.

Example: EnforcedStyle: format(default)

# bad
puts sprintf('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts format('%10s', 'hoge')

Example: EnforcedStyle: sprintf

# bad
puts format('%10s', 'hoge')
puts '%10s' % 'hoge'

# good
puts sprintf('%10s', 'hoge')

Example: EnforcedStyle: percent

# bad
puts format('%10s', 'hoge')
puts sprintf('%10s', 'hoge')

# good
puts '%10s' % 'hoge'

Trailing whitespace detected.
Open

  end 
Severity: Minor
Found in app/helpers/example_json_helper.rb by rubocop

Prefer ranges when generating random numbers instead of integers with offsets.
Open

    str = (0...3).map { (65 + rand(26)).chr }.join
Severity: Minor
Found in app/helpers/example_json_helper.rb by rubocop

This cop checks for the use of randomly generated numbers, added/subtracted with integer literals, as well as those with Integer#succ and Integer#pred methods. Prefer using ranges instead, as it clearly states the intentions.

Example:

# bad
rand(6) + 1
1 + rand(6)
rand(6) - 1
1 - rand(6)
rand(6).succ
rand(6).pred
Random.rand(6) + 1
Kernel.rand(6) + 1
rand(0..5) + 1

# good
rand(1..6)
rand(1...7)

There are no issues that match your filters.

Category
Status