inertia186/radiator

View on GitHub
lib/radiator/utils.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Module has too many lines. [137/100]
Open

  module Utils
    def extract_signatures(options)
      return [] unless defined? options[:params].map
      
      params = options[:params]
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [28/10]
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [15/10]
Open

    def extract_signatures(options)
      return [] unless defined? options[:params].map
      
      params = options[:params]
      
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Perceived complexity for send_log is too high. [12/7]
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Method has too many lines. [14/10]
Open

    def pakHash(h)
      varint(h.size) + h.map do |k, v|
        pakStr(k.to_s) + case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [14/10]
Open

    def pakArr(a)
      varint(a.size) + a.map do |v|
        case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for pakHash is too high. [19.7/15]
Open

    def pakHash(h)
      varint(h.size) + h.map do |k, v|
        pakStr(k.to_s) + case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method extract_signatures has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_signatures(options)
      return [] unless defined? options[:params].map
      
      params = options[:params]
      
Severity: Minor
Found in lib/radiator/utils.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Cyclomatic complexity for pakArr is too high. [9/6]
Open

    def pakArr(a)
      varint(a.size) + a.map do |v|
        case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for pakHash is too high. [9/6]
Open

    def pakHash(h)
      varint(h.size) + h.map do |k, v|
        pakStr(k.to_s) + case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for send_log is too high. [18.14/15]
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for extract_signatures is too high. [18.92/15]
Open

    def extract_signatures(options)
      return [] unless defined? options[:params].map
      
      params = options[:params]
      
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method send_log has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Assignment Branch Condition size for pakArr is too high. [17/15]
Open

    def pakArr(a)
      varint(a.size) + a.map do |v|
        case v
        when Symbol then pakStr(v.to_s)
        when String then pakStr(v)
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for send_log is too high. [7/6]
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method send_log has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def send_log(level, obj, prefix = nil)
      log_message = case obj
      when String
        log_message = if !!prefix
          "#{prefix} :: #{obj}"
Severity: Minor
Found in lib/radiator/utils.rb - About 1 hr to fix

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

            case v
            when Symbol then pakStr(v.to_s)
            when String then pakStr(v)
            when Integer then paks(v)
            when TrueClass then pakC(1)
    Severity: Major
    Found in lib/radiator/utils.rb and 2 other locations - About 1 hr to fix
    lib/radiator/operation.rb on lines 36..46
    lib/radiator/utils.rb on lines 131..141

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

            pakStr(k.to_s) + case v
            when Symbol then pakStr(v.to_s)
            when String then pakStr(v)
            when Integer then paks(v)
            when TrueClass then pakC(1)
    Severity: Major
    Found in lib/radiator/utils.rb and 2 other locations - About 1 hr to fix
    lib/radiator/operation.rb on lines 36..46
    lib/radiator/utils.rb on lines 114..124

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Trailing whitespace detected.
    Open

            
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Indent when as deep as case.
    Open

            when ::Array then pakArr(v)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Indent when as deep as case.
    Open

            when ::Hash then pakHash(v)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Useless assignment to variable - log_message.
    Open

          log_message = case obj
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    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

    Avoid the use of double negation (!!).
    Open

            if !!@logger
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

    Example:

    # bad
    !!something
    
    # good
    !something.nil?

    Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

    Indent when as deep as case.
    Open

            when Integer then paks(v)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Indent when as deep as case.
    Open

            when NilClass then next
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use snake_case for method names.
    Open

        def pakC(i)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Avoid the use of double negation (!!).
    Open

              if !!prefix
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

    Example:

    # bad
    !!something
    
    # good
    !something.nil?

    Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

    Indent when as deep as case.
    Open

          when String
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use snake_case for method names.
    Open

        def pakHash(h)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Use snake_case for method names.
    Open

        def pakL!(i)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Favor format over sprintf.
    Open

            s.each_byte { |b| a << sprintf('%02X', b) }
    Severity: Minor
    Found in lib/radiator/utils.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'

    Indent when as deep as case.
    Open

            when String then pakStr(v)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Space inside { missing.
    Open

                @logger.send level, ({prefix => obj}).inspect
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

            
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

            
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Indent when as deep as case.
    Open

            when FalseClass then pakC(0)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

      
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    end at 34, 8 is not aligned with if at 30, 22.
    Open

            end
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks whether the end keywords are aligned properly.

    Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

    If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

    If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

    If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

    Example: EnforcedStyleAlignWith: keyword (default)

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
               end

    Example: EnforcedStyleAlignWith: variable

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
    end

    Example: EnforcedStyleAlignWith: startofline

    # bad
    
    variable = if true
        end
    
    # good
    
    puts(if true
    end)

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    end at 142, 8 is not aligned with case at 131, 25.
    Open

            end
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks whether the end keywords are aligned properly.

    Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

    If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

    If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

    If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

    Example: EnforcedStyleAlignWith: keyword (default)

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
               end

    Example: EnforcedStyleAlignWith: variable

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
    end

    Example: EnforcedStyleAlignWith: startofline

    # bad
    
    variable = if true
        end
    
    # good
    
    puts(if true
    end)

    Indent when as deep as case.
    Open

            when TrueClass then pakC(1)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Trailing whitespace detected.
    Open

            
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Missing top-level module documentation comment.
    Open

      module Utils
    Severity: Minor
    Found in lib/radiator/utils.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

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use snake_case for method names.
    Open

        def pakArr(a)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Use snake_case for method names.
    Open

        def pakI(i)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Use a guard clause instead of wrapping the code inside a conditional expression.
    Open

          if %w(DEBUG TRACE).include? ENV['LOG']
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use a guard clause instead of wrapping the code inside a conditional expression

    Example:

    # bad
    def test
      if something
        work
      end
    end
    
    # good
    def test
      return unless something
      work
    end
    
    # also good
    def test
      work if something
    end
    
    # bad
    if something
      raise 'exception'
    else
      ok
    end
    
    # good
    raise 'exception' if something
    ok

    %w-literals should be delimited by [ and ].
    Open

          if %w(DEBUG TRACE).include? ENV['LOG']
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Trailing whitespace detected.
    Open

          
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Avoid using rescue in its modifier form.
    Open

              tx[:signatures] rescue nil
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of rescue in its modifier form.

    Example:

    # bad
    some_method rescue handle_error
    
    # good
    begin
      some_method
    rescue
      handle_error
    end

    Avoid using rescue in its modifier form.
    Open

              Time.parse(tx[:expiration] + 'Z') rescue nil
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of rescue in its modifier form.

    Example:

    # bad
    some_method rescue handle_error
    
    # good
    begin
      some_method
    rescue
      handle_error
    end

    Indent when as deep as case.
    Open

            when Symbol then pakStr(v.to_s)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks how the whens of a case expression are indented in relation to its case or end keyword.

    It will register a separate offense for each misaligned when.

    Example:

    # If Layout/EndAlignment is set to keyword style (default)
    # *case* and *end* should always be aligned to same depth,
    # and therefore *when* should always be aligned to both -
    # regardless of configuration.
    
    # bad for all styles
    case n
      when 0
        x * 2
      else
        y / 3
    end
    
    # good for all styles
    case n
    when 0
      x * 2
    else
      y / 3
    end

    Example: EnforcedStyle: case (default)

    # if EndAlignment is set to other style such as
    # start_of_line (as shown below), then *when* alignment
    # configuration does have an effect.
    
    # bad
    a = case n
    when 0
      x * 2
    else
      y / 3
    end
    
    # good
    a = case n
        when 0
          x * 2
        else
          y / 3
    end

    Example: EnforcedStyle: end

    # bad
    a = case n
        when 0
          x * 2
        else
          y / 3
    end
    
    # good
    a = case n
    when 0
      x * 2
    else
      y / 3
    end

    Align else with if.
    Open

            else
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cops checks the alignment of else keywords. Normally they should be aligned with an if/unless/while/until/begin/def keyword, but there are special cases when they should follow the same rules as the alignment of end.

    Example:

    # bad
    if something
      code
     else
      code
    end
    
    # bad
    if something
      code
     elsif something
      code
    end
    
    # good
    if something
      code
    else
      code
    end

    Space inside } missing.
    Open

                @logger.send level, ({prefix => obj}).inspect
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

    Example: EnforcedStyle: space

    # The `space` style enforces that hash literals have
    # surrounding space.
    
    # bad
    h = {a: 1, b: 2}
    
    # good
    h = { a: 1, b: 2 }

    Example: EnforcedStyle: no_space

    # The `no_space` style enforces that hash literals have
    # no surrounding space.
    
    # bad
    h = { a: 1, b: 2 }
    
    # good
    h = {a: 1, b: 2}

    Example: EnforcedStyle: compact

    # The `compact` style normally requires a space inside
    # hash braces, with the exception that successive left
    # braces or right braces are collapsed together in nested hashes.
    
    # bad
    h = { a: { b: 2 } }
    
    # good
    h = { a: { b: 2 }}

    Trailing whitespace detected.
    Open

            
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Avoid the use of double negation (!!).
    Open

              if !!prefix
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

    Example:

    # bad
    !!something
    
    # good
    !something.nil?

    Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

    Avoid the use of double negation (!!).
    Open

          debug("Current node: #{@url}", prefix) if !!log_debug_node && @url
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

    Example:

    # bad
    !!something
    
    # good
    !something.nil?

    Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

    Favor format over sprintf.
    Open

            s.each { |b| a << sprintf('%02X', b) }
    Severity: Minor
    Found in lib/radiator/utils.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'

    end at 55, 6 is not aligned with case at 28, 20.
    Open

          end
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks whether the end keywords are aligned properly.

    Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

    If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

    If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

    If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

    Example: EnforcedStyleAlignWith: keyword (default)

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
               end

    Example: EnforcedStyleAlignWith: variable

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
    end

    Example: EnforcedStyleAlignWith: startofline

    # bad
    
    variable = if true
        end
    
    # good
    
    puts(if true
    end)

    Use 2 (not -12) spaces for indentation.
    Open

              "#{prefix} :: #{obj}"
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use snake_case for method names.
    Open

        def pakStr(s)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Trailing whitespace detected.
    Open

        
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Use snake_case for method names.
    Open

        def pakS(i)
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop makes sure that all methods use the configured style, snake_case or camelCase, for their names.

    Example: EnforcedStyle: snake_case (default)

    # bad
    def fooBar; end
    
    # good
    def foo_bar; end

    Example: EnforcedStyle: camelCase

    # bad
    def foo_bar; end
    
    # good
    def fooBar; end

    Avoid the use of double negation (!!).
    Open

            log_message = if !!prefix
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for uses of double negation (!!) to convert something to a boolean value. As this is both cryptic and usually redundant, it should be avoided.

    Example:

    # bad
    !!something
    
    # good
    !something.nil?

    Please, note that when something is a boolean value !!something and !something.nil? are not the same thing. As you're unlikely to write code that can accept values of any type this is rarely a problem in practice.

    Convert if nested inside else to elsif.
    Open

              if !!prefix
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

    Example:

    # bad
    if condition_a
      action_a
    else
      if condition_b
        action_b
      else
        action_c
      end
    end
    
    # good
    if condition_a
      action_a
    elsif condition_b
      action_b
    else
      action_c
    end

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

          if %w(DEBUG TRACE).include? ENV['LOG']
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    Don't use parentheses around a literal.
    Open

                @logger.send level, ({prefix => obj}).inspect
    Severity: Minor
    Found in lib/radiator/utils.rb by rubocop

    This cop checks for redundant parentheses.

    Example:

    # bad
    (x) if ((y.z).nil?)
    
    # good
    x if y.z.nil?

    There are no issues that match your filters.

    Category
    Status