CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

Function editor_settings has a Cognitive Complexity of 195 (exceeds 5 allowed). Consider refactoring.
Open

    public static function editor_settings($editor_id, $set) {
        $first_run = false;

        if ( empty(self::$first_init) ) {
            if ( is_admin() ) {
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 3 days 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 class-wp-editor.php has 899 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Facilitates adding of the WordPress editor as used on the Write and Edit screens.
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 2 days to fix

    Method editor_settings has 249 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function editor_settings($editor_id, $set) {
            $first_run = false;
    
            if ( empty(self::$first_init) ) {
                if ( is_admin() ) {
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 1 day to fix

      Method wp_mce_translation has 190 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function wp_mce_translation() {
      
              $mce_translation = array(
                  // Default TinyMCE strings
                  'New document' => __( 'New document' ),
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 7 hrs to fix

        Method editor_js has 125 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function editor_js() {
                global $tinymce_version, $concatenate_scripts, $compress_scripts;
        
                /**
                 * Filter "tiny_mce_version" is deprecated
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 5 hrs to fix

          Function editor_js has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function editor_js() {
                  global $tinymce_version, $concatenate_scripts, $compress_scripts;
          
                  /**
                   * Filter "tiny_mce_version" is deprecated
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - 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

          Function editor has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function editor( $content, $editor_id, $settings = array() ) {
          
                  $set = self::parse_settings( $editor_id, $settings );
                  $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"';
                  $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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_fullscreen_html has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function wp_fullscreen_html() {
                  global $content_width;
                  $post = get_post();
          
                  $width = isset( $content_width ) && 800 > $content_width ? $content_width : 800;
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 2 hrs to fix

            Method editor has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function editor( $content, $editor_id, $settings = array() ) {
            
                    $set = self::parse_settings( $editor_id, $settings );
                    $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"';
                    $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 2 hrs to fix

              Method wp_link_dialog has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function wp_link_dialog() {
                      $search_panel_visible = '1' == get_user_setting( 'wplink', '0' ) ? ' search-panel-visible' : '';
              
                      // display: none is required here, see #WP27605
                      ?>
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 2 hrs to fix

                Function parse_settings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function parse_settings( $editor_id, $settings ) {
                        $set = wp_parse_args( $settings,  array(
                            'wpautop'           => true,
                            'media_buttons'     => true,
                            'default_editor'    => '',
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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 parse_settings has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function parse_settings( $editor_id, $settings ) {
                        $set = wp_parse_args( $settings,  array(
                            'wpautop'           => true,
                            'media_buttons'     => true,
                            'default_editor'    => '',
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 1 hr to fix

                  Method wp_link_query has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function wp_link_query( $args = array() ) {
                          $pts = get_post_types( array( 'public' => true ), 'objects' );
                          $pt_names = array_keys( $pts );
                  
                          $query = array(
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 1 hr to fix

                    Function wp_fullscreen_html has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function wp_fullscreen_html() {
                            global $content_width;
                            $post = get_post();
                    
                            $width = isset( $content_width ) && 800 > $content_width ? $content_width : 800;
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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

                    Function _parse_init has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static function _parse_init($init) {
                            $options = '';
                    
                            foreach ( $init as $k => $v ) {
                                if ( is_bool($v) ) {
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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

                    Consider simplifying this complex logical expression.
                    Open

                                if ( is_bool($v) ) {
                                    $val = $v ? 'true' : 'false';
                                    $options .= $k . ':' . $val . ',';
                                    continue;
                                } elseif ( !empty($v) && is_string($v) && ( ('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v) ) ) {
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                      if ( @is_file( $path ) && @is_readable( $path ) ) {
                                                          include_once( $path );
                                                          $ext_plugins .= $strings . "\n";
                                                          $loaded_langs[] = $name;
                                                      }
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        if ( @is_file( $path . $mce_locale . '.js' ) )
                                                            $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n";
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          if ( @is_file( $path . $mce_locale . '_dlg.js' ) )
                                                              $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n";
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                        if ( $file && file_exists( "$template_dir/$file" ) )
                                                            $mce_css[] = "$template_uri/$file";
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                              if ( function_exists('realpath') )
                                                                  $path = trailingslashit( realpath($path) );
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                                if ( 'en' != $mce_locale && empty( $strings ) ) {
                                                                    if ( @is_file( $path . 'en.js' ) ) {
                                                                        $str1 = @file_get_contents( $path . 'en.js' );
                                                                        $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
                                                                    }
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                                  if ( ! empty( $strings ) )
                                                                      $ext_plugins .= "\n" . $strings . "\n";
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php - About 45 mins to fix

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

                                        public static function wp_link_query( $args = array() ) {
                                            $pts = get_post_types( array( 'public' => true ), 'objects' );
                                            $pt_names = array_keys( $pts );
                                    
                                            $query = array(
                                    Severity: Minor
                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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

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

                                        public static function enqueue_scripts() {
                                            wp_enqueue_script('word-count');
                                    
                                            if ( self::$has_tinymce )
                                                wp_enqueue_script('editor');
                                    Severity: Minor
                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.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 ( 'en' != $mce_locale && empty( $strings ) ) {
                                                                        if ( @is_file( $path . 'en.js' ) ) {
                                                                            $str1 = @file_get_contents( $path . 'en.js' );
                                                                            $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
                                                                        }
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-editor.php and 1 other location - About 3 hrs to fix
                                    Web.Admin/2014/wordpress/wp-admin/includes/post.php on lines 1353..1363

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

                                    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