project-eutopia/keisan

View on GitHub

Showing 40 of 40 total issues

Class Node has 45 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Node
      def value(context = nil)
        raise Exceptions::NotImplementedError.new
      end

Severity: Minor
Found in lib/keisan/ast/node.rb - About 6 hrs to fix

    Class ConstantLiteral has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class ConstantLiteral < Literal
          def evaluate(context = nil)
            self
          end
    
    
    Severity: Minor
    Found in lib/keisan/ast/constant_literal.rb - About 3 hrs to fix

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

          def add_token_to_components!(token)
            if token.is_a?(Tokens::LineSeparator)
              @components << Parsing::LineSeparator.new
            elsif is_start_of_line? || @components[-1].is_a?(Parsing::Operator)
              # Expect an element or a unary operator
      Severity: Minor
      Found in lib/keisan/parser.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

      Class Number has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Number < ConstantLiteral
            attr_reader :number
      
            def initialize(number)
              @number = number
      Severity: Minor
      Found in lib/keisan/ast/number.rb - About 2 hrs to fix

        Method node_of_component has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def node_of_component(component)
                case component
                when Parsing::Number
                  AST::Number.new(component.value)
                when Parsing::String
        Severity: Major
        Found in lib/keisan/ast/line_builder.rb - About 2 hrs to fix

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

                def consume_operators_with_priority!(priority)
                  p_indexes = @priorities.map.with_index.select {|p,index| p == priority}
                  # :left, :right, or :none
                  associativity = AST::Operator.associativity_of_priority(priority)
          
          
          Severity: Minor
          Found in lib/keisan/ast/line_builder.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 consume_operators_with_priority! has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def consume_operators_with_priority!(priority)
                  p_indexes = @priorities.map.with_index.select {|p,index| p == priority}
                  # :left, :right, or :none
                  associativity = AST::Operator.associativity_of_priority(priority)
          
          
          Severity: Minor
          Found in lib/keisan/ast/line_builder.rb - About 1 hr to fix

            Method components_to_basic_nodes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def components_to_basic_nodes(components)
                    nodes_components = []
            
                    components.each do |component|
                      if component.is_a?(Keisan::Parsing::LineSeparator)
            Severity: Minor
            Found in lib/keisan/ast/line_builder.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 simplify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def simplify(context = nil)
                    context ||= Context.new
            
                    super(context)
            
            
            Severity: Minor
            Found in lib/keisan/ast/plus.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 add_token_to_components! has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def add_token_to_components!(token)
                  if token.is_a?(Tokens::LineSeparator)
                    @components << Parsing::LineSeparator.new
                  elsif is_start_of_line? || @components[-1].is_a?(Parsing::Operator)
                    # Expect an element or a unary operator
            Severity: Minor
            Found in lib/keisan/parser.rb - About 1 hr to fix

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

                  def initialize(string: nil, tokens: nil)
                    if string.nil? && tokens.nil?
                      raise Exceptions::InternalError.new("Invalid arguments")
                    end
              
              
              Severity: Minor
              Found in lib/keisan/parser.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 simplify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def simplify(context = nil)
                      context ||= Context.new
              
                      super(context)
              
              
              Severity: Minor
              Found in lib/keisan/ast/times.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 simplify has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def simplify(context = nil)
                      context ||= Context.new
              
                      super(context)
              
              
              Severity: Minor
              Found in lib/keisan/ast/plus.rb - About 1 hr to fix

                Method evaluate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def evaluate(context = nil)
                        context ||= Context.new
                        if context.has_variable?(name)
                          variable = variable_node_from_context(context)
                
                
                Severity: Minor
                Found in lib/keisan/ast/variable.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 while_loop has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def while_loop(ast_function, context, simplify: true)
                        logical_node, body_node = ast_function.children[0], ast_function.children[1]
                        current = Keisan::AST::Null.new
                
                        begin
                Severity: Minor
                Found in lib/keisan/functions/while.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 validate_arguments! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def validate_arguments!(count)
                      case arity
                      when Integer
                        if arity < 0 && count < arity.abs || arity >= 0 && count != arity
                          raise Keisan::Exceptions::InvalidFunctionError.new("Require #{arity} arguments to #{name}")
                Severity: Minor
                Found in lib/keisan/function.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 simplify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def simplify(ast_function, context = nil)
                        validate_arguments!(ast_function.children.count)
                        raise Exceptions::InternalError.new("received non-diff function") unless ast_function.name == "diff"
                        function, variables = function_and_variables(ast_function)
                        context ||= Context.new
                Severity: Minor
                Found in lib/keisan/functions/diff.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 simplify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def simplify(context = nil)
                        context ||= Context.new
                
                        super(context)
                
                
                Severity: Minor
                Found in lib/keisan/ast/exponent.rb - About 45 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 simplify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def simplify(ast_function, context = nil)
                        validate_arguments!(ast_function.children.count)
                        context ||= Context.new
                        bool = ast_function.children[0].simplify(context).to_node
                
                
                Severity: Minor
                Found in lib/keisan/functions/if.rb - About 45 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 unbound_variables has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def unbound_variables(context = nil)
                        context ||= Context.new
                        defined_variables = Set.new
                
                        children.inject(Set.new) do |unbound_vars, child|
                Severity: Minor
                Found in lib/keisan/ast/multi_line.rb - About 45 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

                Severity
                Category
                Status
                Source
                Language