prismicio/javascript-kit

View on GitHub

Showing 60 of 126 total issues

File fragments.js has 774 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

var documents = require('./documents');
var DateUtils = require('./utils/date');
var WithFragments = documents.WithFragments;
Severity: Major
Found in lib/fragments.js - About 1 day to fix

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

    'use strict';
    
    var Requests = require('./requests'),
        Cookies = require('./cookies'),
        documents = require('./documents'),
    Severity: Major
    Found in lib/api.js - About 1 day to fix

      Function linkedDocuments has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

        linkedDocuments: function() {
          var i, j, link;
          var result = [];
          var Fragments = require('./fragments');
          for (var field in this.data) {
      Severity: Minor
      Found in lib/documents.js - 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

      File browser.js has 394 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*eslint-env node, mocha */
      /*global chai, Prismic */
      /*eslint no-unused-vars: 0 */
      
      var assert = chai.assert;
      Severity: Minor
      Found in browsertests/browser.js - About 5 hrs to fix

        File documents.js has 341 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        "use strict";
        
        var DateUtils = require('./utils/date');
        
        /**
        Severity: Minor
        Found in lib/documents.js - About 4 hrs to fix

          Function getText has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            getText: function(name, after) {
              var Fragments = require('./fragments');
              var fragment = this.get(name);
          
              if (fragment instanceof Fragments.StructuredText) {
          Severity: Minor
          Found in lib/documents.js - 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

          exports has 29 functions (exceeds 20 allowed). Consider refactoring.
          Open

          module.exports = {
          
            /**
             * Convert a predicate (array of 3 elements) into a query for prismic.io (string)
             */
          Severity: Minor
          Found in lib/predicates.js - About 3 hrs to fix

            Function asHtml has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              asHtml: function(linkResolver, htmlSerializer) {
                var blockGroups = [],
                    blockGroup,
                    block,
                    html = [];
            Severity: Minor
            Found in lib/fragments.js - 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 serialize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            function serialize(element, content, htmlSerializer) {
              // Return the user customized output (if available)
              if (htmlSerializer) {
                var custom = htmlSerializer(element, content);
                if (custom) {
            Severity: Minor
            Found in lib/fragments.js - 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

            prototype has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            WithFragments.prototype = {
              /**
               * Gets the fragment in the current Document object. Since you most likely know the type
               * of this fragment, it is advised that you use a dedicated method, like get StructuredText() or getDate(),
               * for instance.
            Severity: Minor
            Found in lib/documents.js - About 2 hrs to fix

              Function insertSpans has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function insertSpans(text, spans, linkResolver, htmlSerializer) {
                if (!spans || !spans.length) {
                  return htmlEscape(text);
                }
              
              
              Severity: Major
              Found in lib/fragments.js - About 2 hrs to fix

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

                  submit: function(callback) {
                    var self = this;
                    var url = this.form.action;
                
                    if (this.data) {
                Severity: Minor
                Found in lib/api.js - 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 ajaxRequest has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                var ajaxRequest = (function() {
                  if(typeof XMLHttpRequest != 'undefined' && 'withCredentials' in new XMLHttpRequest()) {
                    return function(url, callback) {
                
                      var xhr = new XMLHttpRequest();
                Severity: Minor
                Found in lib/requests.js - 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 parse has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  parse: function(data) {
                    var refs,
                        master,
                        forms = {},
                        form,
                Severity: Major
                Found in lib/api.js - About 2 hrs to fix

                  prototype has 21 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  Api.prototype = {
                  
                    // Predicates
                    AT: "at",
                    ANY: "any",
                  Severity: Minor
                  Found in lib/api.js - About 2 hrs to fix

                    Function nodeJSRequest has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var nodeJSRequest = (function() {
                      if(typeof require == 'function' && require('http')) {
                        var http = require('http'),
                            https = require('https'),
                            url = require('url'),
                    Severity: Major
                    Found in lib/requests.js - About 2 hrs to fix

                      Function serialize has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function serialize(element, content, htmlSerializer) {
                        // Return the user customized output (if available)
                        if (htmlSerializer) {
                          var custom = htmlSerializer(element, content);
                          if (custom) {
                      Severity: Minor
                      Found in lib/fragments.js - About 2 hrs to fix

                        Function asHtml has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          asHtml: function(linkResolver, htmlSerializer) {
                            var blockGroups = [],
                                blockGroup,
                                block,
                                html = [];
                        Severity: Minor
                        Found in lib/fragments.js - About 1 hr to fix

                          Function initField has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function initField(field) {
                          
                            var classForType = {
                              "Color": Color,
                              "Number": Num,
                          Severity: Minor
                          Found in lib/fragments.js - About 1 hr to fix

                            Function linkedDocuments has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              linkedDocuments: function() {
                                var i, j, link;
                                var result = [];
                                var Fragments = require('./fragments');
                                for (var field in this.data) {
                            Severity: Minor
                            Found in lib/documents.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language