prismicio/javascript-kit

View on GitHub
lib/fragments.js

Summary

Maintainability
F
1 wk
Test Coverage

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

    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

    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 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 insertSpans has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function insertSpans(text, spans, linkResolver, htmlSerializer) {
              if (!spans || !spans.length) {
                return htmlEscape(text);
              }
            
            
            Severity: Minor
            Found in lib/fragments.js - 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 getFirstImage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              getFirstImage: function() {
                var self = this;
                var firstImage = Object.keys(this.nonRepeat).reduce(function(image, key) {
                  if (image) {
                    return image;
            Severity: Minor
            Found in lib/fragments.js - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Avoid deeply nested control flow statements.
            Open

                        if (console && console.error) console.error('Impossible to convert span.data as a Fragment', span);
            Severity: Major
            Found in lib/fragments.js - About 45 mins to fix

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

              function ImageView(url, width, height, alt, copyright) {
              Severity: Minor
              Found in lib/fragments.js - About 35 mins to fix

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

                  getFirstTitle: function() {
                    var self = this;
                    var firstTitle = Object.keys(this.nonRepeat).reduce(function(title, key) {
                      if (title) return title;
                      else {
                Severity: Minor
                Found in lib/fragments.js - 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 SliceZone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function SliceZone(data) {
                  this.value = [];
                  for (var i = 0; i < data.length; i++) {
                    var sliceType = data[i]['slice_type'];
                    var label = data[i]['slice_label'] || null;
                Severity: Minor
                Found in lib/fragments.js - 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 parseFragments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function parseFragments(json) {
                  var result = {};
                  for (var key in json) {
                    if (json.hasOwnProperty(key)) {
                      if (Array.isArray(json[key])) {
                Severity: Minor
                Found in lib/fragments.js - 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 function.
                Open

                  return "<!-- Warning: " + element.type + " not implemented. Upgrade the Developer Kit. -->" + content;
                Severity: Major
                Found in lib/fragments.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return '<a' + target + ' href="' + element.url + '">' + content + '</a>';
                  Severity: Major
                  Found in lib/fragments.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return '<span class="' + element.data.label + '">' + content + '</span>';
                    Severity: Major
                    Found in lib/fragments.js - About 30 mins to fix

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

                        getFirstParagraph: function() {
                          var self = this;
                          var firstParagraph = Object.keys(this.nonRepeat).reduce(function(paragraph, key) {
                            if (paragraph) return paragraph;
                            else {
                      Severity: Minor
                      Found in lib/fragments.js - 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 3 locations. Consider refactoring.
                      Open

                      Num.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 2 hrs to fix
                      lib/fragments.js on lines 416..439
                      lib/fragments.js on lines 455..478

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

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

                      DateFragment.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 2 hrs to fix
                      lib/fragments.js on lines 377..400
                      lib/fragments.js on lines 455..478

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

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

                      Timestamp.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 2 hrs to fix
                      lib/fragments.js on lines 377..400
                      lib/fragments.js on lines 416..439

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

                      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

                      function ImageView(url, width, height, alt, copyright) {
                        /**
                         * @field
                         * @description the URL of the ImageView (useable as it, in a <img> tag in HTML, for instance)
                         */
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 2 hrs to fix
                      lib/api.js on lines 833..859

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

                      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

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

                        asText: function(linkResolver) {
                          var output = "";
                          for (var i=0; i<this.value.length; i++) {
                            output += this.value[i].asText(linkResolver) + '\n';
                          }
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 2 hrs to fix
                      lib/fragments.js on lines 1216..1222

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

                      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

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

                        asText: function(linkResolver) {
                          var output = "";
                          for (var i = 0; i < this.value.length; i++) {
                            output += this.value[i].asText(linkResolver) + '\n';
                          }
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 2 hrs to fix
                      lib/fragments.js on lines 691..697

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

                      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

                        asHtml: function (linkResolver) {
                          var output = "";
                          for (var i = 0; i < this.value.length; i++) {
                            output += this.value[i].asHtml(linkResolver);
                          }
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 2 hrs to fix
                      lib/fragments.js on lines 669..675

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

                      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

                        asHtml: function(linkResolver) {
                          var output = "";
                          for (var i = 0; i < this.value.length; i++) {
                            output += this.value[i].asHtml(linkResolver);
                          }
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 2 hrs to fix
                      lib/fragments.js on lines 1203..1209

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

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

                      Text.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 269..288
                      lib/fragments.js on lines 303..322

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

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

                      Select.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 17..36
                      lib/fragments.js on lines 303..322

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

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

                      Color.prototype = {
                        /**
                         * Turns the fragment into a useable HTML version of it.
                         * If the native HTML code doesn't suit your design, this function is meant to be overriden.
                         *
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 17..36
                      lib/fragments.js on lines 269..288

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

                      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

                          var nonRepeatText = Object.keys(this.nonRepeat).reduce(function(acc, key) {
                            return acc + self.nonRepeat[key].asText(linkResolver);
                          }, "");
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 1 hr to fix
                      lib/fragments.js on lines 1089..1091

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

                      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

                          var nonRepeatHtml = Object.keys(this.nonRepeat).reduce(function(acc, key) {
                            return acc + self.nonRepeat[key].asHtml(linkResolver);
                          }, "");
                      Severity: Major
                      Found in lib/fragments.js and 1 other location - About 1 hr to fix
                      lib/fragments.js on lines 1106..1108

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

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

                        getFirstParagraph: function() {
                          return this.toArray().reduce(function(st, fragment) {
                            if (st) return st;
                            else {
                              return fragment.getFirstParagraph();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 699..706
                      lib/fragments.js on lines 708..715

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

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

                        getFirstTitle: function() {
                          return this.toArray().reduce(function(st, fragment) {
                            if (st) return st;
                            else {
                              return fragment.getFirstTitle();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 699..706
                      lib/fragments.js on lines 717..724

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

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

                        getFirstImage: function() {
                          return this.toArray().reduce(function(image, fragment) {
                            if (image) return image;
                            else {
                              return fragment.getFirstImage();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 1 hr to fix
                      lib/fragments.js on lines 708..715
                      lib/fragments.js on lines 717..724

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

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

                        getFirstParagraph: function() {
                          return this.value.reduce(function(paragraph, slice) {
                            if (paragraph) return paragraph;
                            else {
                              return slice.getFirstParagraph();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 55 mins to fix
                      lib/fragments.js on lines 1224..1231
                      lib/fragments.js on lines 1233..1240

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

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

                        getFirstImage: function() {
                          return this.value.reduce(function(image, slice) {
                            if (image) return image;
                            else {
                              return slice.getFirstImage();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 55 mins to fix
                      lib/fragments.js on lines 1233..1240
                      lib/fragments.js on lines 1242..1249

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

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

                        getFirstTitle: function() {
                          return this.value.reduce(function(text, slice) {
                            if (text) return text;
                            else {
                              return slice.getFirstTitle();
                      Severity: Major
                      Found in lib/fragments.js and 2 other locations - About 55 mins to fix
                      lib/fragments.js on lines 1224..1231
                      lib/fragments.js on lines 1242..1249

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

                      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

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

                          if(typeof fragment.getFirstTitle === "function") {
                            return fragment.getFirstTitle();
                          } else if (fragment instanceof StructuredText) {
                            return fragment.getTitle();
                          } else return null;
                      Severity: Minor
                      Found in lib/fragments.js and 1 other location - About 55 mins to fix
                      lib/fragments.js on lines 1145..1149

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

                      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

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

                              if(typeof fragment.getFirstTitle === "function") {
                                return fragment.getFirstTitle();
                              } else if (fragment instanceof StructuredText) {
                                return fragment.getTitle();
                              } else return null;
                      Severity: Minor
                      Found in lib/fragments.js and 1 other location - About 55 mins to fix
                      lib/fragments.js on lines 1043..1047

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

                      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

                      Identical blocks of code found in 4 locations. Consider refactoring.
                      Open

                          if (!isFunction(linkResolver)) {
                            // Backward compatibility with the old ctx argument
                            var ctx = linkResolver;
                            linkResolver = function(doc, isBroken) {
                              return ctx.linkResolver(ctx, doc, isBroken);
                      Severity: Major
                      Found in lib/fragments.js and 3 other locations - About 40 mins to fix
                      lib/documents.js on lines 372..378
                      lib/documents.js on lines 397..403
                      lib/documents.js on lines 418..424

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

                      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(typeof fragment.getFirstImage === "function") {
                            return fragment.getFirstImage();
                          } else if (fragment instanceof ImageEl) {
                            return fragment;
                          } else return null;
                      Severity: Minor
                      Found in lib/fragments.js and 1 other location - About 35 mins to fix
                      lib/fragments.js on lines 1123..1127

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

                      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(typeof element.getFirstImage === "function") {
                                return element.getFirstImage();
                              } else if (element instanceof ImageEl) {
                                return element;
                              } else return null;
                      Severity: Minor
                      Found in lib/fragments.js and 1 other location - About 35 mins to fix
                      lib/fragments.js on lines 1034..1038

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

                      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