WP-API/WP-API

View on GitHub
wp-api.js

Summary

Maintainability
F
1 wk
Test Coverage

File wp-api.js has 710 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function( window, undefined ) {

    'use strict';

    /**
Severity: Major
Found in wp-api.js - About 1 day to fix

    Function addMixinsAndHelpers has 208 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        wp.api.utils.addMixinsAndHelpers = function( model, modelClassName, loadingObjects ) {
    
            var hasDate = false,
    
                /**
    Severity: Major
    Found in wp-api.js - About 1 day to fix

      Function constructFromSchema has 139 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              constructFromSchema: function() {
                  var routeModel = this, modelRoutes, collectionRoutes, schemaRoot, loadingObjects,
      
                  /**
                   * Set up the model and collection name mapping options. As the schema is built, the
      Severity: Major
      Found in wp-api.js - About 5 hrs to fix

        Function sync has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    sync: function( method, model, options ) {
                        var beforeSend, success,
                            self = this;
        
                        options    = options || {};
        Severity: Minor
        Found in wp-api.js - About 1 hr to fix

          Function initialize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  initialize: function() {
                      var model = this, deferred;
          
                      Backbone.Model.prototype.initialize.apply( model, arguments );
          
          
          Severity: Minor
          Found in wp-api.js - About 1 hr to fix

            Function buildCollectionGetter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        buildCollectionGetter = function( parentModel, collectionName, embedSourcePoint, embedIndex ) {
                            /**
                             * Returns a promise that resolves to the requested collection
                             *
                             * Uses the embedded data if available, otherwises fetches the
            Severity: Minor
            Found in wp-api.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                              if ( '' !== parentName && parentName !== routeName ) {
              
                                  collectionClassName = wp.api.utils.capitalize( parentName ) + wp.api.utils.capitalize( routeName );
                                  modelClassName      = mapping.models[ collectionClassName ] || collectionClassName;
                                  collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName;
              Severity: Major
              Found in wp-api.js - About 40 mins to fix

                Function buildModelGetter has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                            buildModelGetter = function( parentModel, modelId, modelName, embedSourcePoint, embedCheckField ) {
                Severity: Minor
                Found in wp-api.js - About 35 mins to fix

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

                              TagsMixin = {
                  
                                  /**
                                   * Get the tags for a post.
                                   *
                  Severity: Major
                  Found in wp-api.js and 1 other location - About 2 days to fix
                  wp-api.js on lines 529..609

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

                  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

                              CategoriesMixin = {
                  
                                  /**
                                   * Get a the categories for a post.
                                   *
                  Severity: Major
                  Found in wp-api.js and 1 other location - About 2 days to fix
                  wp-api.js on lines 445..524

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

                  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 ( _.includes( routeEndpoint.methods, 'GET' ) ) {
                  
                                      // Add any non empty args, merging them into the defaults object.
                                      if ( ! _.isEmpty( routeEndpoint.args ) ) {
                  
                  
                  Severity: Major
                  Found in wp-api.js and 1 other location - About 3 hrs to fix
                  wp-api.js on lines 177..210

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

                  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 ( _.includes( routeEndpoint.methods, 'POST' ) || _.includes( routeEndpoint.methods, 'PUT' ) ) {
                  
                                  // Add any non empty args, merging them into the args object.
                                  if ( ! _.isEmpty( routeEndpoint.args ) ) {
                  
                  
                  Severity: Major
                  Found in wp-api.js and 1 other location - About 3 hrs to fix
                  wp-api.js on lines 194..209

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

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

                          if ( ! _.isUndefined( model.prototype.args.featured_media ) ) {
                              model = model.extend( FeaturedMediaMixin );
                          }
                  Severity: Major
                  Found in wp-api.js and 3 other locations - About 40 mins to fix
                  wp-api.js on lines 647..649
                  wp-api.js on lines 657..659
                  wp-api.js on lines 667..669

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

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

                          if ( ! _.isUndefined( model.prototype.args.author ) ) {
                              model = model.extend( AuthorMixin );
                          }
                  Severity: Major
                  Found in wp-api.js and 3 other locations - About 40 mins to fix
                  wp-api.js on lines 652..654
                  wp-api.js on lines 657..659
                  wp-api.js on lines 667..669

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

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

                          if ( ! _.isUndefined( model.prototype.args.categories ) ) {
                              model = model.extend( CategoriesMixin );
                          }
                  Severity: Major
                  Found in wp-api.js and 3 other locations - About 40 mins to fix
                  wp-api.js on lines 647..649
                  wp-api.js on lines 652..654
                  wp-api.js on lines 667..669

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

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

                          if ( ! _.isUndefined( model.prototype.args.tags ) ) {
                              model = model.extend( TagsMixin );
                          }
                  Severity: Major
                  Found in wp-api.js and 3 other locations - About 40 mins to fix
                  wp-api.js on lines 647..649
                  wp-api.js on lines 652..654
                  wp-api.js on lines 657..659

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

                  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