CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/kses.php

Summary

Maintainability
F
6 days
Test Coverage

File kses.php has 696 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * HTML/XHTML filter that only allows some elements and attributes
 *
 * Added wp_ prefix to avoid conflicts with existing kses users
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 1 day to fix

    Function wp_kses_hair has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_kses_hair($attr, $allowed_protocols) {
        $attrarr = array ();
        $mode = 0;
        $attrname = '';
        $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action');
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/kses.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

    Function wp_kses_attr has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
        # Is there a closing XHTML slash at the end of the attributes?
    
        $xhtml_slash = '';
        if (preg_match('%\s/\s*$%', $attr))
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/kses.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 wp_kses_hair has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wp_kses_hair($attr, $allowed_protocols) {
        $attrarr = array ();
        $mode = 0;
        $attrname = '';
        $uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action');
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 3 hrs to fix

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

      function safecss_filter_attr( $css, $deprecated = '' ) {
          $css = wp_kses_no_null($css);
          $css = str_replace(array("\n","\r","\t"), '', $css);
      
          if ( preg_match( '%[\\(&]|/\*%', $css ) ) // remove any inline css containing \ ( & or comments
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/kses.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 wp_kses_check_attr_val has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
          $ok = true;
      
          switch (strtolower($checkname)) {
              case 'maxlen' :
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 1 hr to fix

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

        function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
            # Is there a closing XHTML slash at the end of the attributes?
        
            $xhtml_slash = '';
            if (preg_match('%\s/\s*$%', $attr))
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 1 hr to fix

          Function wp_kses_check_attr_val has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
              $ok = true;
          
              switch (strtolower($checkname)) {
                  case 'maxlen' :
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/kses.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 safecss_filter_attr has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function safecss_filter_attr( $css, $deprecated = '' ) {
              $css = wp_kses_no_null($css);
              $css = str_replace(array("\n","\r","\t"), '', $css);
          
              if ( preg_match( '%[\\(&]|/\*%', $css ) ) // remove any inline css containing \ ( & or comments
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 1 hr to fix

            Function wp_kses_bad_protocol_once2 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function wp_kses_bad_protocol_once2($matches) {
                global $_kses_allowed_protocols;
            
                if ( is_array($matches) ) {
                    if ( ! isset($matches[1]) || empty($matches[1]) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/kses.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 wp_kses_split2 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function wp_kses_split2($string, $allowed_html, $allowed_protocols) {
                $string = wp_kses_stripslashes($string);
            
                if (substr($string, 0, 1) != '<')
                    return '&gt;';
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 1 hr to fix

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

              function wp_kses_split2($string, $allowed_html, $allowed_protocols) {
                  $string = wp_kses_stripslashes($string);
              
                  if (substr($string, 0, 1) != '<')
                      return '&gt;';
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/kses.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

              Avoid too many return statements within this method.
              Open

                      return '';
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols);
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return "<$slash$elem>";
                  Severity: Major
                  Found in Web.Admin/2014/wordpress/wp-includes/kses.php - About 30 mins to fix

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

                    function valid_unicode($i) {
                        return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
                                ($i >= 0x20 && $i <= 0xd7ff) ||
                                ($i >= 0xe000 && $i <= 0xfffd) ||
                                ($i >= 0x10000 && $i <= 0x10ffff) );
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/kses.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

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

                                    if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match))
                                        # "value"
                                        {
                                        $thisval = $match[1];
                                        if ( in_array($attrname, $uris) )
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/kses.php and 1 other location - About 3 hrs to fix
                    Web.Admin/2014/wordpress/wp-includes/kses.php on lines 640..654

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

                    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 (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match))
                                        # 'value'
                                        {
                                        $thisval = $match[1];
                                        if ( in_array($attrname, $uris) )
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/kses.php and 1 other location - About 3 hrs to fix
                    Web.Admin/2014/wordpress/wp-includes/kses.php on lines 624..638

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

                    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