GutenYe/optimism

View on GitHub
lib/optimism.rb

Summary

Maintainability
D
2 days
Test Coverage

File optimism.rb has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "optimism/util"
require "optimism/parser"
require "optimism/semantics"
require "optimism/require"

Severity: Minor
Found in lib/optimism.rb - About 3 hrs to fix

    Class Optimism has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Optimism
      autoload :VERSION, "optimism/version"
    
      Error         = Class.new Exception 
      EMissingFile   = Class.new Error
    Severity: Minor
    Found in lib/optimism.rb - About 3 hrs to fix

      Method method_missing has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def method_missing(name, *args, &blk)
          return super if UNDEF_METHODS.include?(name)
      
          # relative path: __
          if name =~ /^__+$/
      Severity: Minor
      Found in lib/optimism.rb - About 3 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

      Method _fetch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def _fetch(*args)
          if args.length == 1 then
            path_s = args[0]
            raise_error = true
          else
      Severity: Minor
      Found in lib/optimism.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

      Method method_missing has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def method_missing(name, *args, &blk)
          return super if UNDEF_METHODS.include?(name)
      
          # relative path: __
          if name =~ /^__+$/
      Severity: Minor
      Found in lib/optimism.rb - About 1 hr to fix

        Method _fetch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def _fetch(*args)
            if args.length == 1 then
              path_s = args[0]
              raise_error = true
            else
        Severity: Minor
        Found in lib/optimism.rb - About 1 hr to fix

          Method _convert_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def _convert_hash(hash, opts={})
              o = Optimism.new(nil, opts)
          
              hash.each { |k, v|
                v = _convert_hash(v, opts.merge(name: k.to_s, parent: o)) if Hash === v
          Severity: Minor
          Found in lib/optimism.rb - About 55 mins 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

          Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(content=nil, options={}, &blk)
              @options = {symbolize_key: true}.merge(options)
          
              @_parser = case (p=options[:parser])
                         when Symbol
          Severity: Minor
          Found in lib/optimism.rb - About 35 mins 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

          Avoid too many return statements within this method.
          Open

                return !! _data[$1.to_sym]
          Severity: Major
          Found in lib/optimism.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return _create_child_node(name, args[0], &blk)
            Severity: Major
            Found in lib/optimism.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return _data.__send__(name, *args, &blk)
              Severity: Major
              Found in lib/optimism.rb - About 30 mins to fix

                Method _walk_up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def _walk_up(path, opts={})
                    node = self
                    nodes = path.split(".")
                    nodes.reverse! if opts[:reverse]
                
                
                Severity: Minor
                Found in lib/optimism.rb - About 25 mins 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

                Method _walk_down has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def _walk_down(path, opts={})
                    node = self
                    nodes = path.split(".")
                    nodes.reverse! if opts[:reverse]
                
                
                Severity: Minor
                Found in lib/optimism.rb - About 25 mins 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

                Method _symbolize_keys! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def _symbolize_keys!(hash)
                    hash.keys.each do |key, value|
                      value = hash.delete(key)
                      _symbolize_keys!(value) if Hash === value
                
                
                Severity: Minor
                Found in lib/optimism.rb - About 25 mins 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

                There are no issues that match your filters.

                Category
                Status