ManageIQ/more_core_extensions

View on GitHub

Showing 70 of 70 total issues

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - sum_x.square)

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

Use sum { ... } instead of map { ... }.sum.
Open

        sum_xy = coordinates.map { |x, y| x * y }.sum

Use extend MoreCoreExtensions::CacheWithTimeout::ClassMethods instead of send(:extend, MoreCoreExtensions::CacheWithTimeout::ClassMethods).
Open

Module.send(:extend, MoreCoreExtensions::CacheWithTimeout::ClassMethods)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use prepend MoreCoreExtensions::StringToIWithMethod instead of send(:prepend, MoreCoreExtensions::StringToIWithMethod).
Open

String.send(:prepend, MoreCoreExtensions::StringToIWithMethod)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - sum_x.square)

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        y_intercept = (sum_y - slope * sum_x) / n

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

Use prepend MoreCoreExtensions::ObjectToIWithMethod instead of send(:prepend, MoreCoreExtensions::ObjectToIWithMethod).
Open

Object.send(:prepend, MoreCoreExtensions::ObjectToIWithMethod)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

metadata['rubygems_mfa_required'] must be set to 'true'.
Open

Gem::Specification.new do |spec|
  spec.name          = "more_core_extensions"
  spec.version       = MoreCoreExtensions::VERSION
  spec.authors       = ["Jason Frey", "Brandon Dunne"]
  spec.email         = ["fryguy9@gmail.com", "bdunne@redhat.com"]
Severity: Minor
Found in more_core_extensions.gemspec by rubocop

Requires a gemspec to have rubygems_mfa_required metadata set.

This setting tells RubyGems that MFA (Multi-Factor Authentication) is required for accounts to be able perform privileged operations, such as (see RubyGems' documentation for the full list of privileged operations):

  • gem push
  • gem yank
  • gem owner --add/remove
  • adding or removing owners using gem ownership page

This helps make your gem more secure, as users can be more confident that gem updates were pushed by maintainers.

Example:

# bad
Gem::Specification.new do |spec|
  # no `rubygems_mfa_required` metadata specified
end

# good
Gem::Specification.new do |spec|
  spec.metadata = {
    'rubygems_mfa_required' => 'true'
  }
end

# good
Gem::Specification.new do |spec|
  spec.metadata['rubygems_mfa_required'] = 'true'
end

# bad
Gem::Specification.new do |spec|
  spec.metadata = {
    'rubygems_mfa_required' => 'false'
  }
end

# good
Gem::Specification.new do |spec|
  spec.metadata = {
    'rubygems_mfa_required' => 'true'
  }
end

# bad
Gem::Specification.new do |spec|
  spec.metadata['rubygems_mfa_required'] = 'false'
end

# good
Gem::Specification.new do |spec|
  spec.metadata['rubygems_mfa_required'] = 'true'
end

Use include MoreCoreExtensions::ArrayCompactMap instead of send(:include, MoreCoreExtensions::ArrayCompactMap).
Open

Array.send(:include, MoreCoreExtensions::ArrayCompactMap)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use sum { ... } instead of map { ... }.sum.
Open

        sum_x2 = x_array.map(&:square).sum

Use prepend MoreCoreExtensions::NumericRounding instead of send(:prepend, MoreCoreExtensions::NumericRounding).
Open

Numeric.send(:prepend, MoreCoreExtensions::NumericRounding)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use prepend MoreCoreExtensions::IEC60027_2 instead of send(:prepend, MoreCoreExtensions::IEC60027_2).
Open

String.send(:prepend, MoreCoreExtensions::IEC60027_2)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use include MoreCoreExtensions::ArrayRandom instead of send(:include, MoreCoreExtensions::ArrayRandom).
Open

Array.send(:include, MoreCoreExtensions::ArrayRandom)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use extend MoreCoreExtensions::ArrayStretch::ClassMethods instead of send(:extend, MoreCoreExtensions::ArrayStretch::ClassMethods).
Open

Array.send(:extend, MoreCoreExtensions::ArrayStretch::ClassMethods)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use include MoreCoreExtensions::CacheWithTimeout instead of send(:include, MoreCoreExtensions::CacheWithTimeout).
Open

Module.send(:include, MoreCoreExtensions::CacheWithTimeout)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use include MoreCoreExtensions::ModuleNamespace instead of send(:include, MoreCoreExtensions::ModuleNamespace).
Open

Module.send(:include, MoreCoreExtensions::ModuleNamespace)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Use prepend MoreCoreExtensions::NumericClamp instead of send(:prepend, MoreCoreExtensions::NumericClamp).
Open

Numeric.send(:prepend, MoreCoreExtensions::NumericClamp)

Checks for send, public_send, and __send__ methods when using mix-in.

include and prepend methods were private methods until Ruby 2.0, they were mixed-in via send method. This cop uses Ruby 2.1 or higher style that can be called by public methods. And extend method that was originally a public method is also targeted for style unification.

Example:

# bad
Foo.send(:include, Bar)
Foo.send(:prepend, Bar)
Foo.send(:extend, Bar)

# bad
Foo.public_send(:include, Bar)
Foo.public_send(:prepend, Bar)
Foo.public_send(:extend, Bar)

# bad
Foo.__send__(:include, Bar)
Foo.__send__(:prepend, Bar)
Foo.__send__(:extend, Bar)

# good
Foo.include Bar
Foo.prepend Bar
Foo.extend Bar

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        slope * x + y_intercept

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        r_squared   = (n * sum_xy - sum_x * sum_y) / Math.sqrt((n * sum_x2 - sum_x.square) * (n * sum_y2 - sum_y.square)) rescue nil

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d

Wrap expressions with varying precedence with parentheses to avoid ambiguity.
Open

        r_squared   = (n * sum_xy - sum_x * sum_y) / Math.sqrt((n * sum_x2 - sum_x.square) * (n * sum_y2 - sum_y.square)) rescue nil

Looks for expressions containing multiple binary operators where precedence is ambiguous due to lack of parentheses. For example, in 1 + 2 * 3, the multiplication will happen before the addition, but lexically it appears that the addition will happen first.

The cop does not consider unary operators (ie. !a or -b) or comparison operators (ie. a =~ b) because those are not ambiguous.

NOTE: Ranges are handled by Lint/AmbiguousRange.

Example:

# bad
a + b * c
a || b && c
a ** b + c

# good (different precedence)
a + (b * c)
a || (b && c)
(a ** b) + c

# good (same precedence)
a + b + c
a * b / c % d
Severity
Category
Status
Source
Language