reactrb/reactrb

View on GitHub
lib/react/validator.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class Validator has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Validator
    attr_accessor :errors
    attr_reader :props_wrapper
    private :errors, :props_wrapper

Severity: Minor
Found in lib/react/validator.rb - About 2 hrs to fix

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

          props.reject { |name, value| rules[name] }
    Severity: Minor
    Found in lib/react/validator.rb by rubocop

    This cop checks for unused block arguments.

    Example:

    # bad
    
    do_something do |used, unused|
      puts used
    end
    
    do_something do |bar|
      puts :foo
    end
    
    define_method(:foo) do |bar|
      puts :baz
    end

    Example:

    #good
    
    do_something do |used, _unused|
      puts used
    end
    
    do_something do
      puts :foo
    end
    
    define_method(:foo) do |_bar|
      puts :baz
    end

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

            .select {|key, value| value.keys.include?("default") }
    Severity: Minor
    Found in lib/react/validator.rb by rubocop

    This cop checks for unused block arguments.

    Example:

    # bad
    
    do_something do |used, unused|
      puts used
    end
    
    do_something do |bar|
      puts :foo
    end
    
    define_method(:foo) do |bar|
      puts :baz
    end

    Example:

    #good
    
    do_something do |used, _unused|
      puts used
    end
    
    do_something do
      puts :foo
    end
    
    define_method(:foo) do |_bar|
      puts :baz
    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

    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 klass = rules[prop_name][:type]
    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

    Method React::Validator#errors is defined at both lib/react/validator.rb:3 and lib/react/validator.rb:76.
    Open

        def errors
    Severity: Minor
    Found in lib/react/validator.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    There are no issues that match your filters.

    Category
    Status