jlawrence11/eos

View on GitHub
src/Parser.php

Summary

Maintainability
F
3 days
Test Coverage

Function in2post has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    public static function in2post($infix) {
        // if an equation was not passed, use the one that was passed in the constructor
        //$infix = (isset($infix)) ? $infix : $this->inFix;

        //check to make sure 'valid' equation
Severity: Minor
Found in src/Parser.php - About 6 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

File Parser.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Equation Operating System Classes.
 *
 * This class was created for the safe parsing of mathematical equations
Severity: Minor
Found in src/Parser.php - About 3 hrs to fix

    Function replaceVars has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function replaceVars($infix, $vArray)
        {
            //Remove old '$' and '&' signis so the regex works properly.
            $infix = preg_replace('/[$&]/', "", $infix);
            //Find all the variables that were passed and replaces them
    Severity: Minor
    Found in src/Parser.php - 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

    Method in2post has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function in2post($infix) {
            // if an equation was not passed, use the one that was passed in the constructor
            //$infix = (isset($infix)) ? $infix : $this->inFix;
    
            //check to make sure 'valid' equation
    Severity: Major
    Found in src/Parser.php - About 2 hrs to fix

      Function solvePF has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function solvePF($pfArray) {
              $pf = $pfArray;
      
              // create our temporary function variables
              $temp = array();
      Severity: Minor
      Found in src/Parser.php - 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

      Function solveIF has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function solveIF($infix, $vArray = null) {
              //Check to make sure a 'valid' expression
              self::checkInfix($infix);
      
              //$ops = new Stack();
      Severity: Minor
      Found in src/Parser.php - 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

      Method solveIF has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function solveIF($infix, $vArray = null) {
              //Check to make sure a 'valid' expression
              self::checkInfix($infix);
      
              //$ops = new Stack();
      Severity: Minor
      Found in src/Parser.php - About 1 hr to fix

        Method solvePF has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function solvePF($pfArray) {
                $pf = $pfArray;
        
                // create our temporary function variables
                $temp = array();
        Severity: Minor
        Found in src/Parser.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if(in_array(strtolower($match[2]), array('pi', 'e'))) {
                          $t = (strtolower($match[2])=='pi') ? pi() : exp(1);
                          $infix = str_replace($match[0], $match[1] . $front. $t. $back . $match[3], $infix);
                      } elseif(!isset($vArray[$match[2]]) && (!is_array($vArray != "") && !is_numeric($vArray) && 0 !== $vArray)) {
                          throw new \Exception("Variable replacement does not exist for '". $match[2] ."' in ". self::$inFix .".", Math::E_NO_VAR);
          Severity: Major
          Found in src/Parser.php - About 40 mins to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if((!in_array($match[3], array_merge(self::$ST, self::$ST1, self::$ST2, self::$SEP['close'])) && $match[3] != "") || is_numeric($match[3])) //$this->SEP['open'] removed
                            $back = "*";
                        else
                            $back = "";
            Severity: Minor
            Found in src/Parser.php and 1 other location - About 50 mins to fix
            src/Parser.php on lines 477..480

            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 97.

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if((!in_array($match[1], array_merge(self::$ST, self::$ST1, self::$ST2, self::$SEP['open'])) && $match[1] != "") || is_numeric($match[1])) //$this->SEP['close'] removed
                            $front = "*";
                        else
                            $front = "";
            Severity: Minor
            Found in src/Parser.php and 1 other location - About 50 mins to fix
            src/Parser.php on lines 482..485

            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 97.

            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

            There are no issues that match your filters.

            Category
            Status