reactrb/reactrb

View on GitHub

Showing 108 of 108 total issues

Literal typeof React.renderToString === 'undefined' appeared as a condition.
Open

    elsif !(`typeof React.renderToString === 'undefined'`)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Unused method argument - name. If it's necessary, use _ or _name as an argument name to indicate that it won't be used. You can also write as html_tag?(*) if you want the method to accept any arguments but don't care about them.
Open

  def self.html_tag?(name)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Shadowing outer local variable - element.
Open

              @buffer.last.to_s.span.tap { |element| element.waiting_on_resources = saved_waiting_on_resources }
Severity: Minor
Found in lib/react/rendering_context.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

Literal Opal.global.React === undefined || Opal.global.React.version === undefined appeared as a condition.
Open

  if `Opal.global.React === undefined || Opal.global.React.version === undefined`
Severity: Minor
Found in lib/hyper-react.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal typeof ReactDOM === 'undefined' appeared as a condition.
Open

    if !(`typeof ReactDOM === 'undefined'`)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Useless assignment to variable - message.
Open

        message = ["%c" + message[0], style]+message[1..-1]

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Unused method argument - name. If it's necessary, use _ or _name as an argument name to indicate that it won't be used. You can also write as html_attr?(*) if you want the method to accept any arguments but don't care about them.
Open

  def self.html_attr?(name)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Unused method argument - container. If it's necessary, use _ or _container as an argument name to indicate that it won't be used.
Open

  def self.render(element, container)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Literal #{component} === undefined appeared as a condition.
Open

      raise "#{name} is not defined" if `#{component} === undefined`
Severity: Minor
Found in lib/react/api.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Useless private access modifier.
Open

    private
Severity: Minor
Found in lib/react/api.rb by rubocop

This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

Example:

class Foo
  public # this is redundant (default access is public)

  def method
  end

  private # this is not redundant (a method is defined)
  def method2
  end

  private # this is redundant (no following methods are defined)
end

Example:

class Foo
  # The following is not redundant (conditionally defined methods are
  # considered as always defining a method)
  private

  if condition?
    def method
    end
  end

  protected # this is not redundant (method is defined)

  define_method(:method2) do
  end

  protected # this is redundant (repeated from previous modifier)

  [1,2,3].each do |i|
    define_method("foo#{i}") do
    end
  end

  # The following is redundant (methods defined on the class'
  # singleton class are not affected by the public modifier)
  public

  def self.method3
  end
end

Example:

# Lint/UselessAccessModifier:
#   ContextCreatingMethods:
#     - concerning
require 'active_support/concern'
class Foo
  concerning :Bar do
    def some_public_method
    end

    private

    def some_private_method
    end
  end

  # this is not redundant because `concerning` created its own context
  private

  def some_other_private_method
  end
end

Example:

# Lint/UselessAccessModifier:
#   MethodCreatingMethods:
#     - delegate
require 'active_support/core_ext/module/delegation'
class Foo
  # this is not redundant because `delegate` creates methods
  private

  delegate :method_a, to: :method_b
end

Literal typeof ReactDOM === 'undefined' appeared as a condition.
Open

    if !(`typeof ReactDOM === 'undefined'`)
Severity: Minor
Found in lib/react/top_level_render.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Literal typeof React.renderToString === 'undefined' appeared as a condition.
Open

      elsif !(`typeof React.renderToString === 'undefined'`)
Severity: Minor
Found in lib/react/server.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

      return unless values = rules[prop_name][:values]
Severity: Minor
Found in lib/react/validator.rb by rubocop

This cop checks for assignments in the conditions of if/while/until.

Example:

# bad

if some_var = true
  do_something
end

Example:

# good

if some_var == true
  do_something
end

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

      rescue Exception => e
        self.class.process_exception(e, self)
Severity: Minor
Found in lib/react/component.rb by rubocop

This cop checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end

Shadowing outer local variable - element.
Open

              React.create_element(name, *args) { buffer }.tap do |element|
Severity: Minor
Found in lib/react/rendering_context.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

Shadowing outer local variable - value.
Open

        yield.tap do |value|

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

Unused method argument - name. If it's necessary, use _ or _name as an argument name to indicate that it won't be used. You can also write as action_missing(*) if you want the method to accept any arguments but don't care about them.
Open

          def action_missing(name)
Severity: Minor
Found in lib/reactive-ruby/rails/railtie.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Literal typeof ReactDOMServer === 'undefined' appeared as a condition.
Open

    if !(`typeof ReactDOMServer === 'undefined'`)
Severity: Minor
Found in lib/react/top_level.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end

Unused method argument - new_block. If it's necessary, use _ or _new_block as an argument name to indicate that it won't be used.
Open

    def render(props = {}, &new_block)
Severity: Minor
Found in lib/react/element.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Literal typeof React.findDOMNode === 'undefined' appeared as a condition.
Open

        elsif !(`typeof React.findDOMNode === 'undefined'`)
Severity: Minor
Found in lib/react/component/api.rb by rubocop

This cop checks for literals used as the conditions or as operands in and/or expressions serving as the conditions of if/while/until.

Example:

# bad

if 20
  do_something
end

Example:

# bad

if some_var && true
  do_something
end

Example:

# good

if some_var && some_condition
  do_something
end
Severity
Category
Status
Source
Language