lucliscio/fanKounter

View on GitHub
src/libs/rain.tpl.class.php

Summary

Maintainability
D
3 days
Test Coverage

File rain.tpl.class.php has 439 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

/**
 *  RainTPL
 *  -------
Severity: Minor
Found in src/libs/rain.tpl.class.php - About 6 hrs to fix

    Function var_replace has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        function var_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
    
            //all variables
            if( preg_match_all( '/' . $tag_left_delimiter . '\$(\w+(?:\.\${0,1}[A-Za-z0-9_]+)*(?:(?:\[\${0,1}[A-Za-z0-9_]+\])|(?:\-\>\${0,1}[A-Za-z0-9_]+))*)(.*?)' . $tag_right_delimiter . '/', $html, $matches ) ){
    
    Severity: Minor
    Found in src/libs/rain.tpl.class.php - About 4 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 compileCode has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        protected function compileCode( $parsed_code ){
    
            //variables initialization
            $compiled_code = $open_if = $comment_is_open = $ignore_is_open = null;
            $loop_level = 0;
    Severity: Minor
    Found in src/libs/rain.tpl.class.php - About 4 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 compileCode has 96 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

        protected function compileCode( $parsed_code ){
    
            //variables initialization
            $compiled_code = $open_if = $comment_is_open = $ignore_is_open = null;
            $loop_level = 0;
    Severity: Major
    Found in src/libs/rain.tpl.class.php - About 3 hrs to fix

      Function func_replace has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          function func_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
      
              preg_match_all( '/' . '\{\#{0,1}(\"{0,1}.*?\"{0,1})(\|\w.*?)\#{0,1}\}' . '/', $html, $matches );
      
              for( $i=0, $n=count($matches[0]); $i<$n; $i++ ){
      Severity: Minor
      Found in src/libs/rain.tpl.class.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 var_replace has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function var_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
      
              //all variables
              if( preg_match_all( '/' . $tag_left_delimiter . '\$(\w+(?:\.\${0,1}[A-Za-z0-9_]+)*(?:(?:\[\${0,1}[A-Za-z0-9_]+\])|(?:\-\>\${0,1}[A-Za-z0-9_]+))*)(.*?)' . $tag_right_delimiter . '/', $html, $matches ) ){
      
      Severity: Major
      Found in src/libs/rain.tpl.class.php - About 2 hrs to fix

        Method func_replace has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function func_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
        
                preg_match_all( '/' . '\{\#{0,1}(\"{0,1}.*?\"{0,1})(\|\w.*?)\#{0,1}\}' . '/', $html, $matches );
        
                for( $i=0, $n=count($matches[0]); $i<$n; $i++ ){
        Severity: Minor
        Found in src/libs/rain.tpl.class.php - About 1 hr to fix

          Function path_replace has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function path_replace( $html, $tpl_basedir ){
          
                  if( self::$path_replace ){
          
                      $tpl_dir = self::$base_url . self::$tpl_dir . $tpl_basedir;
          Severity: Minor
          Found in src/libs/rain.tpl.class.php - 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 path_replace has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function path_replace( $html, $tpl_basedir ){
          
                  if( self::$path_replace ){
          
                      $tpl_dir = self::$base_url . self::$tpl_dir . $tpl_basedir;
          Severity: Minor
          Found in src/libs/rain.tpl.class.php - About 1 hr to fix

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

                protected function printDebug(RainTpl_Exception $e){
                    if (!self::$debug) {
                        throw $e;
                    }
                    $output = sprintf('<h2>Exception: %s</h2><h3>%s</h3><p>template: %s</p>',
            Severity: Minor
            Found in src/libs/rain.tpl.class.php - About 1 hr to fix

              Function printDebug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function printDebug(RainTpl_Exception $e){
                      if (!self::$debug) {
                          throw $e;
                      }
                      $output = sprintf('<h2>Exception: %s</h2><h3>%s</h3><p>template: %s</p>',
              Severity: Minor
              Found in src/libs/rain.tpl.class.php - 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

              Function draw has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  function draw( $tpl_name, $return_string = false ){
              
                      try {
                          // compile the template if necessary and set the template filepath
                          $this->check_template( $tpl_name );
              Severity: Minor
              Found in src/libs/rain.tpl.class.php - 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 const_replace has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  function const_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
              Severity: Major
              Found in src/libs/rain.tpl.class.php - About 50 mins to fix

                Method func_replace has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    function func_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
                Severity: Major
                Found in src/libs/rain.tpl.class.php - About 50 mins to fix

                  Method var_replace has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      function var_replace( $html, $tag_left_delimiter, $tag_right_delimiter, $php_left_delimiter = null, $php_right_delimiter = null, $loop_level = null, $echo = null ){
                  Severity: Major
                  Found in src/libs/rain.tpl.class.php - About 50 mins to fix

                    Function check_template has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function check_template( $tpl_name ){
                    
                            if( !isset($this->tpl['checked']) ){
                    
                                $tpl_basename                       = basename( $tpl_name );                                                        // template basename
                    Severity: Minor
                    Found in src/libs/rain.tpl.class.php - 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 compileFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        protected function compileFile( $tpl_basename, $tpl_basedir, $tpl_filename, $cache_dir, $compiled_filename ){
                    Severity: Minor
                    Found in src/libs/rain.tpl.class.php - About 35 mins to fix

                      Function configure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static function configure( $setting, $value = null ){
                              if( is_array( $setting ) )
                                  foreach( $setting as $key => $value )
                                      self::configure( $key, $value );
                              else if( property_exists( __CLASS__, $setting ) ){
                      Severity: Minor
                      Found in src/libs/rain.tpl.class.php - 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

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

                                                  if( $function_var ){
                                                      
                                                          // check if there's a function or a static method and separate, function by parameters
                                                          $function_var = str_replace("::", "@double_dot@", $function_var );
                      
                      Severity: Major
                      Found in src/libs/rain.tpl.class.php and 1 other location - About 4 hrs to fix
                      src/libs/rain.tpl.class.php on lines 714..742

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

                      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 2 locations. Consider refactoring.
                      Open

                                  if( $function_var ){
                                      
                                      // check if there's a function or a static method and separate, function by parameters
                                      $function_var = str_replace("::", "@double_dot@", $function_var );
                      
                      Severity: Major
                      Found in src/libs/rain.tpl.class.php and 1 other location - About 4 hrs to fix
                      src/libs/rain.tpl.class.php on lines 816..843

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

                      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