WP-API/WP-API

View on GitHub
lib/endpoints/class-wp-rest-posts-controller.php

Summary

Maintainability
F
2 wks
Test Coverage

File class-wp-rest-posts-controller.php has 1318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class WP_REST_Posts_Controller extends WP_REST_Controller {

    /**
Severity: Major
Found in lib/endpoints/class-wp-rest-posts-controller.php - About 3 days to fix

    Method get_item_schema has 299 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_item_schema() {
    
            $schema = array(
                '$schema'    => 'http://json-schema.org/draft-04/schema#',
                'title'      => $this->post_type,
    Severity: Major
    Found in lib/endpoints/class-wp-rest-posts-controller.php - About 1 day to fix

      Function prepare_item_for_database has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function prepare_item_for_database( $request ) {
              $prepared_post = new stdClass;
      
              // ID.
              if ( isset( $request['id'] ) ) {
      Severity: Minor
      Found in lib/endpoints/class-wp-rest-posts-controller.php - About 7 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 prepare_item_for_response has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public function prepare_item_for_response( $post, $request ) {
              $GLOBALS['post'] = $post;
              setup_postdata( $post );
      
              $schema = $this->get_item_schema();
      Severity: Minor
      Found in lib/endpoints/class-wp-rest-posts-controller.php - About 5 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 get_collection_params has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_collection_params() {
              $params = parent::get_collection_params();
      
              $params['context']['default'] = 'view';
      
      
      Severity: Major
      Found in lib/endpoints/class-wp-rest-posts-controller.php - About 5 hrs to fix

        Method get_items has 123 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_items( $request ) {
        
                // Make sure a search string is set in case the orderby is set to 'relevance'.
                if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) && empty( $request['filter']['s'] ) ) {
                    return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
        Severity: Major
        Found in lib/endpoints/class-wp-rest-posts-controller.php - About 4 hrs to fix

          Function get_items has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_items( $request ) {
          
                  // Make sure a search string is set in case the orderby is set to 'relevance'.
                  if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) && empty( $request['filter']['s'] ) ) {
                      return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
          Severity: Minor
          Found in lib/endpoints/class-wp-rest-posts-controller.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 prepare_item_for_response has 122 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function prepare_item_for_response( $post, $request ) {
                  $GLOBALS['post'] = $post;
                  setup_postdata( $post );
          
                  $schema = $this->get_item_schema();
          Severity: Major
          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 4 hrs to fix

            WP_REST_Posts_Controller has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class WP_REST_Posts_Controller extends WP_REST_Controller {
            
                /**
                 * Post type.
                 *
            Severity: Minor
            Found in lib/endpoints/class-wp-rest-posts-controller.php - About 4 hrs to fix

              Method prepare_item_for_database has 94 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function prepare_item_for_database( $request ) {
                      $prepared_post = new stdClass;
              
                      // ID.
                      if ( isset( $request['id'] ) ) {
              Severity: Major
              Found in lib/endpoints/class-wp-rest-posts-controller.php - About 3 hrs to fix

                Method prepare_links has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function prepare_links( $post ) {
                        $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
                
                        // Entity meta.
                        $links = array(
                Severity: Major
                Found in lib/endpoints/class-wp-rest-posts-controller.php - About 3 hrs to fix

                  Function get_item_schema has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function get_item_schema() {
                  
                          $schema = array(
                              '$schema'    => 'http://json-schema.org/draft-04/schema#',
                              'title'      => $this->post_type,
                  Severity: Minor
                  Found in lib/endpoints/class-wp-rest-posts-controller.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 update_item has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function update_item( $request ) {
                          $id = (int) $request['id'];
                          $post = $this->get_post( $id );
                  
                          if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
                  Severity: Minor
                  Found in lib/endpoints/class-wp-rest-posts-controller.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 create_item has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function create_item( $request ) {
                          if ( ! empty( $request['id'] ) ) {
                              return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
                          }
                  
                  
                  Severity: Minor
                  Found in lib/endpoints/class-wp-rest-posts-controller.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 create_item has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function create_item( $request ) {
                          if ( ! empty( $request['id'] ) ) {
                              return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) );
                          }
                  
                  
                  Severity: Major
                  Found in lib/endpoints/class-wp-rest-posts-controller.php - About 2 hrs to fix

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

                        protected function prepare_links( $post ) {
                            $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
                    
                            // Entity meta.
                            $links = array(
                    Severity: Minor
                    Found in lib/endpoints/class-wp-rest-posts-controller.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 update_item has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function update_item( $request ) {
                            $id = (int) $request['id'];
                            $post = $this->get_post( $id );
                    
                            if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
                    Severity: Major
                    Found in lib/endpoints/class-wp-rest-posts-controller.php - About 2 hrs to fix

                      Method register_routes has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function register_routes() {
                      
                              register_rest_route( $this->namespace, '/' . $this->rest_base, array(
                                  array(
                                      'methods'         => WP_REST_Server::READABLE,
                      Severity: Minor
                      Found in lib/endpoints/class-wp-rest-posts-controller.php - About 1 hr to fix

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

                            public function delete_item( $request ) {
                                $id = (int) $request['id'];
                                $force = (bool) $request['force'];
                        
                                $post = $this->get_post( $id );
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-posts-controller.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 delete_item has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function delete_item( $request ) {
                                $id = (int) $request['id'];
                                $force = (bool) $request['force'];
                        
                                $post = $this->get_post( $id );
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-posts-controller.php - About 1 hr to fix

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

                              protected function handle_status_param( $post_status, $post_type ) {
                          
                                  switch ( $post_status ) {
                                      case 'draft':
                                      case 'pending':
                          Severity: Minor
                          Found in lib/endpoints/class-wp-rest-posts-controller.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

                          Function get_item_permissions_check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function get_item_permissions_check( $request ) {
                          
                                  $post = $this->get_post( (int) $request['id'] );
                          
                                  if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
                          Severity: Minor
                          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 35 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 check_read_permission has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function check_read_permission( $post ) {
                                  $post_type = get_post_type_object( $post->post_type );
                                  if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
                                      return false;
                                  }
                          Severity: Minor
                          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 35 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 get_collection_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function get_collection_params() {
                                  $params = parent::get_collection_params();
                          
                                  $params['context']['default'] = 'view';
                          
                          
                          Severity: Minor
                          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 35 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 $meta_update;
                          Severity: Major
                          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return rest_ensure_response( $response );
                            Severity: Major
                            Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent id.' ), array( 'status' => 400 ) );
                              Severity: Major
                              Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
                                Severity: Major
                                Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                              return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
                                  Severity: Major
                                  Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return false;
                                    Severity: Major
                                    Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return $fields_update;
                                      Severity: Major
                                      Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return $fields_update;
                                        Severity: Major
                                        Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return apply_filters( "rest_pre_insert_{$this->post_type}", $prepared_post, $request );
                                          Severity: Major
                                          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return $meta_update;
                                            Severity: Major
                                            Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return $response;
                                              Severity: Major
                                              Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return $response;
                                                Severity: Major
                                                Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return true;
                                                  Severity: Major
                                                  Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

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

                                                        protected function prepare_items_query( $prepared_args = array(), $request = null ) {
                                                    
                                                            $valid_vars = array_flip( $this->get_allowed_query_vars( $request ) );
                                                            $query_args = array();
                                                            foreach ( $valid_vars as $var => $index ) {
                                                    Severity: Minor
                                                    Found in lib/endpoints/class-wp-rest-posts-controller.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 handle_terms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        protected function handle_terms( $post_id, $request ) {
                                                            $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
                                                            foreach ( $taxonomies as $taxonomy ) {
                                                                $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in lib/endpoints/class-wp-rest-posts-controller.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 ( ! empty( $schema['properties']['excerpt'] ) && isset( $request['excerpt'] ) ) {
                                                                if ( is_string( $request['excerpt'] ) ) {
                                                                    $prepared_post->post_excerpt = wp_filter_post_kses( $request['excerpt'] );
                                                                } elseif ( isset( $request['excerpt']['raw'] ) ) {
                                                                    $prepared_post->post_excerpt = wp_filter_post_kses( $request['excerpt']['raw'] );
                                                    Severity: Major
                                                    Found in lib/endpoints/class-wp-rest-posts-controller.php and 1 other location - About 1 hr to fix
                                                    lib/endpoints/class-wp-rest-posts-controller.php on lines 851..857

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

                                                    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 ( ! empty( $schema['properties']['content'] ) && isset( $request['content'] ) ) {
                                                                if ( is_string( $request['content'] ) ) {
                                                                    $prepared_post->post_content = wp_filter_post_kses( $request['content'] );
                                                                } elseif ( isset( $request['content']['raw'] ) ) {
                                                                    $prepared_post->post_content = wp_filter_post_kses( $request['content']['raw'] );
                                                    Severity: Major
                                                    Found in lib/endpoints/class-wp-rest-posts-controller.php and 1 other location - About 1 hr to fix
                                                    lib/endpoints/class-wp-rest-posts-controller.php on lines 860..866

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

                                                    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