codeclimate/codeclimate-yaml

View on GitHub
lib/cc/yaml/nodes/sequence.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class has too many lines. [105/100]
Open

    class Sequence < Node
      attr_reader :children
      alias_method :__getobj__, :children

      def self.[](node_type)
Severity: Minor
Found in lib/cc/yaml/nodes/sequence.rb by rubocop

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

Class Sequence has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Sequence < Node
      attr_reader :children
      alias_method :__getobj__, :children

      def self.[](node_type)
Severity: Minor
Found in lib/cc/yaml/nodes/sequence.rb - About 2 hrs to fix

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

          def visit_child(visitor, value)
            child =
              if self.class.type
                self.class.type.new(self)
              else
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.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.

    Inconsistent indentation detected.
    Open

            def dup_values
              @children = @children.map { |child| child.dup }
              self
            end
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.rb by rubocop

    This cops checks for inconsistent indentation.

    Example:

    class A
      def test
        puts 'hello'
         puts 'world'
      end
    end

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

          def visit_scalar(visitor, type, value, implicit = true)
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.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

    Use nested module/class definitions instead of compact style.
    Open

    module CC::Yaml
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.rb by rubocop

    This cop checks the style of children definitions at classes and modules. Basically there are two different styles:

    Example: EnforcedStyle: nested (default)

    # good
    # have each child on its own line
    class Foo
      class Bar
      end
    end

    Example: EnforcedStyle: compact

    # good
    # combine definitions as much as possible
    class Foo::Bar
    end

    The compact style is only forced for classes/modules with one child.

    Useless assignment to variable - list.
    Open

              list = value.nested_warnings(*prefix) + list
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.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

    Use alias instead of alias_method in a class body.
    Open

          alias_method :__getobj__, :children
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.rb by rubocop

    This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

    Example: EnforcedStyle: prefer_alias (default)

    # bad
    alias_method :bar, :foo
    alias :bar :foo
    
    # good
    alias bar foo

    Example: EnforcedStyle: preferaliasmethod

    # bad
    alias :bar :foo
    alias bar foo
    
    # good
    alias_method :bar, :foo

    Pass &:dup as an argument to map instead of a block.
    Open

              @children = @children.map { |child| child.dup }
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.rb by rubocop

    Use symbols as procs when possible.

    Example:

    # bad
    something.map { |s| s.upcase }
    
    # good
    something.map(&:upcase)

    Use && instead of and.
    Open

            if other.respond_to? :to_a and other.to_a.size == children.size
    Severity: Minor
    Found in lib/cc/yaml/nodes/sequence.rb by rubocop

    This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

    Example: EnforcedStyle: always (default)

    # bad
    foo.save and return
    
    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    if foo && bar
    end

    Example: EnforcedStyle: conditionals

    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    foo.save and return
    
    # good
    if foo && bar
    end

    There are no issues that match your filters.

    Category
    Status