public/mozilla-pdf/web/viewer.js

Summary

Maintainability
F
1 mo
Test Coverage

File viewer.js has 4599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* Copyright 2012 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
Severity: Major
Found in public/mozilla-pdf/web/viewer.js - About 1 wk to fix

    Function pageView has 544 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var PageView = function pageView(container, id, scale,
                                     navigateTo, defaultViewport) {
      this.id = id;
    
      this.rotation = 0;
    Severity: Major
    Found in public/mozilla-pdf/web/viewer.js - About 2 days to fix

      Function pageView has a Cognitive Complexity of 133 (exceeds 5 allowed). Consider refactoring.
      Open

      var PageView = function pageView(container, id, scale,
                                       navigateTo, defaultViewport) {
        this.id = id;
      
        this.rotation = 0;
      Severity: Minor
      Found in public/mozilla-pdf/web/viewer.js - About 2 days to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function textLayerBuilder has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
      Open

      var TextLayerBuilder = function textLayerBuilder(options) {
        var textLayerFrag = document.createDocumentFragment();
      
        this.textLayerDiv = options.textLayerDiv;
        this.layoutDone = false;
      Severity: Minor
      Found in public/mozilla-pdf/web/viewer.js - About 2 days to fix

      Cognitive Complexity

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

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

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

      Further reading

      Function keydown has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
      Open

      window.addEventListener('keydown', function keydown(evt) {
        if (OverlayManager.active) {
          return;
        }
      
      
      Severity: Minor
      Found in public/mozilla-pdf/web/viewer.js - About 1 day 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 textLayerBuilder has 243 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var TextLayerBuilder = function textLayerBuilder(options) {
        var textLayerFrag = document.createDocumentFragment();
      
        this.textLayerDiv = options.textLayerDiv;
        this.layoutDone = false;
      Severity: Major
      Found in public/mozilla-pdf/web/viewer.js - About 1 day to fix

        Function pdfViewLoad has 194 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          load: function pdfViewLoad(pdfDocument, scale) {
            var self = this;
            var isOnePageRenderedResolved = false;
            var resolveOnePageRendered = null;
            var onePageRendered = new Promise(function (resolve) {
        Severity: Major
        Found in public/mozilla-pdf/web/viewer.js - About 7 hrs to fix

          Function keydown has 189 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          window.addEventListener('keydown', function keydown(evt) {
            if (OverlayManager.active) {
              return;
            }
          
          
          Severity: Major
          Found in public/mozilla-pdf/web/viewer.js - About 7 hrs to fix

            Function webViewerInitialized has 155 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function webViewerInitialized() {
              var params = PDFView.parseQueryString(document.location.search.substring(1));
              var file = 'file' in params ? params.file : DEFAULT_URL;
            
              var fileInput = document.createElement('input');
            Severity: Major
            Found in public/mozilla-pdf/web/viewer.js - About 6 hrs to fix

              PDFView has 45 functions (exceeds 20 allowed). Consider refactoring.
              Open

              var PDFView = {
                pages: [],
                thumbnails: [],
                currentScale: UNKNOWN_SCALE,
                currentScaleValue: null,
              Severity: Minor
              Found in public/mozilla-pdf/web/viewer.js - About 6 hrs to fix

                Function thumbnailView has 147 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
                  var anchor = document.createElement('a');
                  anchor.href = PDFView.getAnchorUrl('#page=' + id);
                  anchor.title = mozL10n.get('thumb_page_title', {page: id}, 'Page {{page}}');
                  anchor.onclick = function stopNavigation() {
                Severity: Major
                Found in public/mozilla-pdf/web/viewer.js - About 5 hrs to fix

                  Function GrabToPanClosure has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var GrabToPan = (function GrabToPanClosure() {
                    /**
                     * Construct a GrabToPan instance for a given HTML element.
                     * @param options.element {Element}
                     * @param options.ignoreTarget {function} optional. See `ignoreTarget(node)`
                  Severity: Minor
                  Found in public/mozilla-pdf/web/viewer.js - About 5 hrs to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  Function pageviewDraw has 138 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    this.draw = function pageviewDraw(callback) {
                      var pdfPage = this.pdfPage;
                  
                      if (this.pagePdfPromise) {
                        return;
                  Severity: Major
                  Found in public/mozilla-pdf/web/viewer.js - About 5 hrs to fix

                    Function pdfViewSetHash has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                    Open

                      setHash: function pdfViewSetHash(hash) {
                        if (!hash) {
                          return;
                        }
                    
                    
                    Severity: Minor
                    Found in public/mozilla-pdf/web/viewer.js - About 5 hrs to fix

                    Cognitive Complexity

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

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

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

                    Further reading

                    Function GrabToPanClosure has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var GrabToPan = (function GrabToPanClosure() {
                      /**
                       * Construct a GrabToPan instance for a given HTML element.
                       * @param options.element {Element}
                       * @param options.ignoreTarget {function} optional. See `ignoreTarget(node)`
                    Severity: Major
                    Found in public/mozilla-pdf/web/viewer.js - About 4 hrs to fix

                      Function setupAnnotations has 109 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function setupAnnotations(pageDiv, pdfPage, viewport) {
                      
                          function bindLink(link, dest) {
                            link.href = PDFView.getDestinationHash(dest);
                            link.onclick = function pageViewSetupLinksOnclick() {
                      Severity: Major
                      Found in public/mozilla-pdf/web/viewer.js - About 4 hrs to fix

                        Function pdfHistoryPush has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                        Open

                          push: function pdfHistoryPush(params, isInitialBookmark) {
                            if (!(this.initialized && this.historyUnlocked)) {
                              return;
                            }
                            if (params.dest && !params.hash) {
                        Severity: Minor
                        Found in public/mozilla-pdf/web/viewer.js - About 4 hrs to fix

                        Cognitive Complexity

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

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

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

                        Further reading

                        Function mozPrintCallbackPolyfillClosure has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        (function mozPrintCallbackPolyfillClosure() {
                          if ('mozPrintCallback' in document.createElement('canvas')) {
                            return;
                          }
                          // Cause positive result on feature-detection:
                        Severity: Major
                        Found in public/mozilla-pdf/web/viewer.js - About 4 hrs to fix

                          Function pdfViewLoad has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                          Open

                            load: function pdfViewLoad(pdfDocument, scale) {
                              var self = this;
                              var isOnePageRenderedResolved = false;
                              var resolveOnePageRendered = null;
                              var onePageRendered = new Promise(function (resolve) {
                          Severity: Minor
                          Found in public/mozilla-pdf/web/viewer.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 pdfViewInitialize has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            initialize: function pdfViewInitialize() {
                              var self = this;
                              var container = this.container = document.getElementById('viewerContainer');
                              this.pageViewScroll = {};
                              this.watchScroll(container, this.pageViewScroll, updateViewarea);
                          Severity: Major
                          Found in public/mozilla-pdf/web/viewer.js - About 3 hrs to fix

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

                            var DownloadManager = (function DownloadManagerClosure() {
                            
                              function download(blobUrl, filename) {
                                var a = document.createElement('a');
                                if (a.click) {
                            Severity: Minor
                            Found in public/mozilla-pdf/web/viewer.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 pdfHistoryInitialize has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                            Open

                              initialize: function pdfHistoryInitialize(fingerprint) {
                                if (PDFJS.disableHistory || PDFView.isViewerEmbedded) {
                                  // The browsing history is only enabled when the viewer is standalone,
                                  // i.e. not when it is embedded in a web page.
                                  return;
                            Severity: Minor
                            Found in public/mozilla-pdf/web/viewer.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 ViewHistoryClosure has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                            Open

                            var ViewHistory = (function ViewHistoryClosure() {
                              function ViewHistory(fingerprint) {
                                this.fingerprint = fingerprint;
                                this.isInitializedPromiseResolved = false;
                                this.initializedPromise =
                            Severity: Minor
                            Found in public/mozilla-pdf/web/viewer.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 textLayerBuilder_renderMatches has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              this.renderMatches = function textLayerBuilder_renderMatches(matches) {
                                // Early exit if there is nothing to render.
                                if (matches.length === 0) {
                                  return;
                                }
                            Severity: Major
                            Found in public/mozilla-pdf/web/viewer.js - About 3 hrs to fix

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

                              (function mozPrintCallbackPolyfillClosure() {
                                if ('mozPrintCallback' in document.createElement('canvas')) {
                                  return;
                                }
                                // Cause positive result on feature-detection:
                              Severity: Minor
                              Found in public/mozilla-pdf/web/viewer.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 pdfHistoryInitialize has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                initialize: function pdfHistoryInitialize(fingerprint) {
                                  if (PDFJS.disableHistory || PDFView.isViewerEmbedded) {
                                    // The browsing history is only enabled when the viewer is standalone,
                                    // i.e. not when it is embedded in a web page.
                                    return;
                              Severity: Major
                              Found in public/mozilla-pdf/web/viewer.js - About 3 hrs to fix

                                Function pageViewScrollIntoView has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  this.scrollIntoView = function pageViewScrollIntoView(dest) {
                                    if (PresentationMode.active) {
                                      if (PDFView.page !== this.id) {
                                        // Avoid breaking PDFView.getVisiblePages in presentation mode.
                                        PDFView.page = this.id;
                                Severity: Major
                                Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

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

                                  function webViewerInitialized() {
                                    var params = PDFView.parseQueryString(document.location.search.substring(1));
                                    var file = 'file' in params ? params.file : DEFAULT_URL;
                                  
                                    var fileInput = document.createElement('input');
                                  Severity: Minor
                                  Found in public/mozilla-pdf/web/viewer.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 ViewHistoryClosure has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  var ViewHistory = (function ViewHistoryClosure() {
                                    function ViewHistory(fingerprint) {
                                      this.fingerprint = fingerprint;
                                      this.isInitializedPromiseResolved = false;
                                      this.initializedPromise =
                                  Severity: Major
                                  Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

                                    Function updateViewarea has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function updateViewarea() {
                                    
                                      if (!PDFView.initialized) {
                                        return;
                                      }
                                    Severity: Major
                                    Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

                                      Function pdfViewGetDestinationHash has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        getDestinationHash: function pdfViewGetDestinationHash(dest) {
                                          if (typeof dest === 'string') {
                                            return PDFView.getAnchorUrl('#' + escape(dest));
                                          }
                                          if (dest instanceof Array) {
                                      Severity: Minor
                                      Found in public/mozilla-pdf/web/viewer.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 thumbnailView has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      var ThumbnailView = function thumbnailView(container, id, defaultViewport) {
                                        var anchor = document.createElement('a');
                                        anchor.href = PDFView.getAnchorUrl('#page=' + id);
                                        anchor.title = mozL10n.get('thumb_page_title', {page: id}, 'Page {{page}}');
                                        anchor.onclick = function stopNavigation() {
                                      Severity: Minor
                                      Found in public/mozilla-pdf/web/viewer.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 nextMatch has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        nextMatch: function() {
                                          var previous = this.state.findPrevious;
                                          var currentPageIndex = this.pdfPageSource.page - 1;
                                          var numPages = this.pdfPageSource.pages.length;
                                      
                                      
                                      Severity: Minor
                                      Found in public/mozilla-pdf/web/viewer.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 pageCssTransform has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        this.cssTransform = function pageCssTransform(canvas) {
                                          // Scale canvas, canvas wrapper, and page container.
                                          var width = this.viewport.width;
                                          var height = this.viewport.height;
                                          canvas.style.width = canvas.parentNode.style.width = div.style.width =
                                      Severity: Major
                                      Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

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

                                        var DownloadManager = (function DownloadManagerClosure() {
                                        
                                          function download(blobUrl, filename) {
                                            var a = document.createElement('a');
                                            if (a.click) {
                                        Severity: Major
                                        Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

                                          Function pdfViewError has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                            error: function pdfViewError(message, moreInfo) {
                                              var moreInfoText = mozL10n.get('error_version_info',
                                                {version: PDFJS.version || '?', build: PDFJS.build || '?'},
                                                'PDF.js v{{version}} (build: {{build}})') + '\n';
                                              if (moreInfo) {
                                          Severity: Major
                                          Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

                                            Function pdfViewOpen has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                              open: function pdfViewOpen(url, scale, password,
                                                                         pdfDataRangeTransport, args) {
                                                if (this.pdfDocument) {
                                                  // Reload the preferences if a document was previously opened.
                                                  Preferences.reload();
                                            Severity: Major
                                            Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

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

                                                push: function pdfHistoryPush(params, isInitialBookmark) {
                                                  if (!(this.initialized && this.historyUnlocked)) {
                                                    return;
                                                  }
                                                  if (params.dest && !params.hash) {
                                              Severity: Minor
                                              Found in public/mozilla-pdf/web/viewer.js - About 2 hrs to fix

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

                                                  switchSidebarView: function pdfViewSwitchSidebarView(view, openSidebar) {
                                                    if (openSidebar && !this.sidebarOpen) {
                                                      document.getElementById('sidebarToggle').click();
                                                    }
                                                    var thumbsView = document.getElementById('thumbnailView');
                                                Severity: Minor
                                                Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                  var ProgressBar = (function ProgressBarClosure() {
                                                  
                                                    function clamp(v, min, max) {
                                                      return Math.min(Math.max(v, min), max);
                                                    }
                                                  Severity: Minor
                                                  Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                      setHash: function pdfViewSetHash(hash) {
                                                        if (!hash) {
                                                          return;
                                                        }
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                      Function thumbnailViewDraw has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                        this.draw = function thumbnailViewDraw(callback) {
                                                          if (!this.pdfPage) {
                                                            var promise = PDFView.getPage(this.id);
                                                            promise.then(function(pdfPage) {
                                                              this.setPdfPage(pdfPage);
                                                      Severity: Minor
                                                      Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                          initialize: function(options) {
                                                            if(typeof PDFFindController === 'undefined' || PDFFindController === null) {
                                                              throw 'PDFFindBar cannot be initialized ' +
                                                                    'without a PDFFindController instance.';
                                                            }
                                                        Severity: Minor
                                                        Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                            nextMatch: function() {
                                                              var previous = this.state.findPrevious;
                                                              var currentPageIndex = this.pdfPageSource.page - 1;
                                                              var numPages = this.pdfPageSource.pages.length;
                                                          
                                                          
                                                          Severity: Minor
                                                          Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                            Function pdfHistory_getPreviousParams has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage,
                                                                                                                        beforeUnload) {
                                                                if (!(this.currentBookmark && this.currentPage)) {
                                                                  return null;
                                                                } else if (this.updatePreviousBookmark) {
                                                            Severity: Minor
                                                            Found in public/mozilla-pdf/web/viewer.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 preferencesSet has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              set: function preferencesSet(name, value) {
                                                                return this.initializedPromise.then(function () {
                                                                  if (DEFAULT_PREFERENCES[name] === undefined) {
                                                                    throw new Error('preferencesSet: \'' + name + '\' is undefined.');
                                                                  } else if (value === undefined) {
                                                            Severity: Minor
                                                            Found in public/mozilla-pdf/web/viewer.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 pdfViewSetScale has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                                            Open

                                                              setScale: function pdfViewSetScale(value, resetAutoSettings, noScroll) {
                                                                if (value === 'custom') {
                                                                  return;
                                                                }
                                                                var scale = parseFloat(value);
                                                            Severity: Minor
                                                            Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                              Function pageViewBeforePrint has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                                              Open

                                                                this.beforePrint = function pageViewBeforePrint() {
                                                                  var pdfPage = this.pdfPage;
                                                              
                                                                  var viewport = pdfPage.getViewport(1);
                                                                  // Use the same hack we use for high dpi displays for printing to get better
                                                              Severity: Minor
                                                              Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                Function CustomStyleClosure has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                                                Open

                                                                var CustomStyle = (function CustomStyleClosure() {
                                                                
                                                                  // As noted on: http://www.zachstronaut.com/posts/2009/02/17/
                                                                  //              animate-css-transforms-firefox-webkit.html
                                                                  // in some versions of IE9 it is critical that ms appear in this list
                                                                Severity: Minor
                                                                Found in public/mozilla-pdf/web/viewer.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 pdfViewGetVisibleElements has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                Open

                                                                  getVisibleElements: function pdfViewGetVisibleElements(
                                                                      scrollEl, views, sortByVisibility) {
                                                                    var top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight;
                                                                    var left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth;
                                                                
                                                                
                                                                Severity: Minor
                                                                Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                  Function documentOutlineView has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                  Open

                                                                  var DocumentOutlineView = function documentOutlineView(outline) {
                                                                    var outlineView = document.getElementById('outlineView');
                                                                    while (outlineView.firstChild) {
                                                                      outlineView.removeChild(outlineView.firstChild);
                                                                    }
                                                                  Severity: Minor
                                                                  Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                    Function secondaryToolbarInitialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                    Open

                                                                      initialize: function secondaryToolbarInitialize(options) {
                                                                        this.toolbar = options.toolbar;
                                                                        this.presentationMode = options.presentationMode;
                                                                        this.documentProperties = options.documentProperties;
                                                                        this.buttonContainer = this.toolbar.firstElementChild;
                                                                    Severity: Minor
                                                                    Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                                        mouseScroll: function pdfViewMouseScroll(mouseScrollDelta) {
                                                                          var MOUSE_SCROLL_COOLDOWN_TIME = 50;
                                                                      
                                                                          var currentTime = (new Date()).getTime();
                                                                          var storedTime = this.mouseScrollTimeStamp;
                                                                      Severity: Minor
                                                                      Found in public/mozilla-pdf/web/viewer.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 updateViewarea has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                      function updateViewarea() {
                                                                      
                                                                        if (!PDFView.initialized) {
                                                                          return;
                                                                        }
                                                                      Severity: Minor
                                                                      Found in public/mozilla-pdf/web/viewer.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 bindNamedAction has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                      Open

                                                                          function bindNamedAction(link, action) {
                                                                            link.href = PDFView.getAnchorUrl('');
                                                                            link.onclick = function pageViewSetupNamedActionOnClick() {
                                                                              // See PDF reference, table 8.45 - Named action
                                                                              switch (action) {
                                                                      Severity: Minor
                                                                      Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                        Function textLayerBuilderConvertMatches has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                        Open

                                                                          this.convertMatches = function textLayerBuilderConvertMatches(matches) {
                                                                            var i = 0;
                                                                            var iIndex = 0;
                                                                            var bidiTexts = this.textContent.items;
                                                                            var end = bidiTexts.length - 1;
                                                                        Severity: Minor
                                                                        Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                          Function pdfHistory_goTo has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                          Open

                                                                            _goTo: function pdfHistory_goTo(state) {
                                                                              if (!(this.initialized && this.historyUnlocked &&
                                                                                    this._isStateObjectDefined(state))) {
                                                                                return;
                                                                              }
                                                                          Severity: Minor
                                                                          Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                            Function pdfViewNavigateTo has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                            Open

                                                                              navigateTo: function pdfViewNavigateTo(dest) {
                                                                                var destString = '';
                                                                                var self = this;
                                                                            
                                                                                var goToDestination = function(destRef) {
                                                                            Severity: Minor
                                                                            Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                              Function pdfViewSetScale has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                setScale: function pdfViewSetScale(value, resetAutoSettings, noScroll) {
                                                                                  if (value === 'custom') {
                                                                                    return;
                                                                                  }
                                                                                  var scale = parseFloat(value);
                                                                              Severity: Minor
                                                                              Found in public/mozilla-pdf/web/viewer.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 pdfViewOpen has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                open: function pdfViewOpen(url, scale, password,
                                                                                                           pdfDataRangeTransport, args) {
                                                                                  if (this.pdfDocument) {
                                                                                    // Reload the preferences if a document was previously opened.
                                                                                    Preferences.reload();
                                                                              Severity: Minor
                                                                              Found in public/mozilla-pdf/web/viewer.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 pagechange has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                              window.addEventListener('pagechange', function pagechange(evt) {
                                                                                var page = evt.pageNumber;
                                                                                if (PDFView.previousPageNumber !== page) {
                                                                                  document.getElementById('pageNumber').value = page;
                                                                                  var selected = document.querySelector('.thumbnail.selected');
                                                                              Severity: Minor
                                                                              Found in public/mozilla-pdf/web/viewer.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 scrollIntoView has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                              function scrollIntoView(element, spot) {
                                                                                // Assuming offsetParent is available (it's not available when viewer is in
                                                                                // hidden iframe or object). We have to scroll: if the offsetParent is not set
                                                                                // producing the error. See also animationStartedClosure.
                                                                                var parent = element.offsetParent;
                                                                              Severity: Minor
                                                                              Found in public/mozilla-pdf/web/viewer.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 pdfViewMouseScroll has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                              Open

                                                                                mouseScroll: function pdfViewMouseScroll(mouseScrollDelta) {
                                                                                  var MOUSE_SCROLL_COOLDOWN_TIME = 50;
                                                                              
                                                                                  var currentTime = (new Date()).getTime();
                                                                                  var storedTime = this.mouseScrollTimeStamp;
                                                                              Severity: Minor
                                                                              Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                Function pageViewDrawCallback has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                Open

                                                                                    function pageViewDrawCallback(error) {
                                                                                      // The renderTask may have been replaced by a new one, so only remove the
                                                                                      // reference to the renderTask if it matches the one that is triggering
                                                                                      // this callback.
                                                                                      if (renderTask === self.renderTask) {
                                                                                Severity: Minor
                                                                                Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                  Function documentAttachmentsView has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                  Open

                                                                                  var DocumentAttachmentsView = function documentAttachmentsView(attachments) {
                                                                                    var attachmentsView = document.getElementById('attachmentsView');
                                                                                    while (attachmentsView.firstChild) {
                                                                                      attachmentsView.removeChild(attachmentsView.firstChild);
                                                                                    }
                                                                                  Severity: Minor
                                                                                  Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                    Function pageViewSetupNamedActionOnClick has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                    Open

                                                                                          link.onclick = function pageViewSetupNamedActionOnClick() {
                                                                                            // See PDF reference, table 8.45 - Named action
                                                                                            switch (action) {
                                                                                              case 'GoToPage':
                                                                                                document.getElementById('pageNumber').focus();
                                                                                    Severity: Minor
                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                                                        updateUIState: function(state, previous) {
                                                                                          var notFound = false;
                                                                                          var findMsg = '';
                                                                                          var status = '';
                                                                                      
                                                                                      
                                                                                      Severity: Minor
                                                                                      Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                                                          initialize: function handToolInitialize(options) {
                                                                                            var toggleHandTool = options.toggleHandTool;
                                                                                            this.handTool = new GrabToPan({
                                                                                              element: options.container,
                                                                                              onActiveChanged: function(isActive) {
                                                                                        Severity: Minor
                                                                                        Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                          Function documentPropertiesParseDate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                          Open

                                                                                            parseDate: function documentPropertiesParseDate(inputDate) {
                                                                                              // This is implemented according to the PDF specification (see
                                                                                              // http://www.gnupdf.org/Date for an overview), but note that 
                                                                                              // Adobe Reader doesn't handle changing the date to universal time
                                                                                              // and doesn't use the user's time zone (they're effectively ignoring
                                                                                          Severity: Minor
                                                                                          Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                            Function documentPropertiesGetProperties has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                            Open

                                                                                              getProperties: function documentPropertiesGetProperties() {
                                                                                                if (!OverlayManager.active) {
                                                                                                  // If the dialog was closed before dataAvailablePromise was resolved,
                                                                                                  // don't bother updating the properties.
                                                                                                  return;
                                                                                            Severity: Minor
                                                                                            Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                              Function pdfViewSetupBeforePrint has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                              Open

                                                                                                beforePrint: function pdfViewSetupBeforePrint() {
                                                                                                  if (!this.supportsPrinting) {
                                                                                                    var printMessage = mozL10n.get('printing_not_supported', null,
                                                                                                        'Warning: Printing is not fully supported by this browser.');
                                                                                                    this.error(printMessage);
                                                                                              Severity: Minor
                                                                                              Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                Function scrollIntoView has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                Open

                                                                                                function scrollIntoView(element, spot) {
                                                                                                  // Assuming offsetParent is available (it's not available when viewer is in
                                                                                                  // hidden iframe or object). We have to scroll: if the offsetParent is not set
                                                                                                  // producing the error. See also animationStartedClosure.
                                                                                                  var parent = element.offsetParent;
                                                                                                Severity: Minor
                                                                                                Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                  Function extractText has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                  Open

                                                                                                    extractText: function() {
                                                                                                      if (this.startedTextExtraction) {
                                                                                                        return;
                                                                                                      }
                                                                                                      this.startedTextExtraction = true;
                                                                                                  Severity: Minor
                                                                                                  Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                    Function textLayerBuilderAppendText has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                    Open

                                                                                                      this.appendText = function textLayerBuilderAppendText(geom, styles) {
                                                                                                        var style = styles[geom.fontName];
                                                                                                        var textDiv = document.createElement('div');
                                                                                                        this.textDivs.push(textDiv);
                                                                                                        if (!/\S/.test(geom.str)) {
                                                                                                    Severity: Minor
                                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                      Function CustomStyleClosure has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                      Open

                                                                                                      var CustomStyle = (function CustomStyleClosure() {
                                                                                                      
                                                                                                        // As noted on: http://www.zachstronaut.com/posts/2009/02/17/
                                                                                                        //              animate-css-transforms-firefox-webkit.html
                                                                                                        // in some versions of IE9 it is critical that ms appear in this list
                                                                                                      Severity: Minor
                                                                                                      Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                        Function pageViewReset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                        Open

                                                                                                          this.reset = function pageViewReset(keepAnnotations) {
                                                                                                            if (this.renderTask) {
                                                                                                              this.renderTask.cancel();
                                                                                                            }
                                                                                                            this.resume = null;
                                                                                                        Severity: Minor
                                                                                                        Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

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

                                                                                                          var DocumentOutlineView = function documentOutlineView(outline) {
                                                                                                            var outlineView = document.getElementById('outlineView');
                                                                                                            while (outlineView.firstChild) {
                                                                                                              outlineView.removeChild(outlineView.firstChild);
                                                                                                            }
                                                                                                          Severity: Minor
                                                                                                          Found in public/mozilla-pdf/web/viewer.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 pdfViewSetupBeforePrint has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                                                                          Open

                                                                                                            beforePrint: function pdfViewSetupBeforePrint() {
                                                                                                              if (!this.supportsPrinting) {
                                                                                                                var printMessage = mozL10n.get('printing_not_supported', null,
                                                                                                                    'Warning: Printing is not fully supported by this browser.');
                                                                                                                this.error(printMessage);
                                                                                                          Severity: Minor
                                                                                                          Found in public/mozilla-pdf/web/viewer.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 pdfViewGetHighestPriority has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                                                                          Open

                                                                                                            getHighestPriority: function pdfViewGetHighestPriority(visible, views,
                                                                                                                                                                   scrolledDown) {
                                                                                                              // The state has changed figure out which page has the highest priority to
                                                                                                              // render next (if any).
                                                                                                              // Priority:
                                                                                                          Severity: Minor
                                                                                                          Found in public/mozilla-pdf/web/viewer.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 pdfViewError has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                                                                          Open

                                                                                                            error: function pdfViewError(message, moreInfo) {
                                                                                                              var moreInfoText = mozL10n.get('error_version_info',
                                                                                                                {version: PDFJS.version || '?', build: PDFJS.build || '?'},
                                                                                                                'PDF.js v{{version}} (build: {{build}})') + '\n';
                                                                                                              if (moreInfo) {
                                                                                                          Severity: Minor
                                                                                                          Found in public/mozilla-pdf/web/viewer.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 textLayerBuilderRenderLayer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                          Open

                                                                                                            this.renderLayer = function textLayerBuilderRenderLayer() {
                                                                                                              var textDivs = this.textDivs;
                                                                                                              var canvas = document.createElement('canvas');
                                                                                                              var ctx = canvas.getContext('2d');
                                                                                                          
                                                                                                          
                                                                                                          Severity: Minor
                                                                                                          Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                            Function pdfViewGetDestinationHash has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                            Open

                                                                                                              getDestinationHash: function pdfViewGetDestinationHash(dest) {
                                                                                                                if (typeof dest === 'string') {
                                                                                                                  return PDFView.getAnchorUrl('#' + escape(dest));
                                                                                                                }
                                                                                                                if (dest instanceof Array) {
                                                                                                            Severity: Minor
                                                                                                            Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                              Function ViewHistory has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                              Open

                                                                                                                function ViewHistory(fingerprint) {
                                                                                                                  this.fingerprint = fingerprint;
                                                                                                                  this.isInitializedPromiseResolved = false;
                                                                                                                  this.initializedPromise =
                                                                                                                      this._readFromStorage().then(function (databaseStr) {
                                                                                                              Severity: Minor
                                                                                                              Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                                Function calcFindMatch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                                                                                Open

                                                                                                                  calcFindMatch: function(pageIndex) {
                                                                                                                    var pageContent = this.pageContents[pageIndex];
                                                                                                                    var query = this.state.query;
                                                                                                                    var caseSensitive = this.state.caseSensitive;
                                                                                                                    var queryLen = query.length;
                                                                                                                Severity: Minor
                                                                                                                Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                                  Consider simplifying this complex logical expression.
                                                                                                                  Open

                                                                                                                      if (event.keyCode === 80/*P*/ && (event.ctrlKey || event.metaKey) &&
                                                                                                                          !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
                                                                                                                        window.print();
                                                                                                                        if (hasAttachEvent) {
                                                                                                                          // Only attachEvent can cancel Ctrl + P dialog in IE <=10
                                                                                                                  Severity: Major
                                                                                                                  Found in public/mozilla-pdf/web/viewer.js - About 1 hr to fix

                                                                                                                    Function pdfViewSwitchSidebarView has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                                                                    Open

                                                                                                                      switchSidebarView: function pdfViewSwitchSidebarView(view, openSidebar) {
                                                                                                                        if (openSidebar && !this.sidebarOpen) {
                                                                                                                          document.getElementById('sidebarToggle').click();
                                                                                                                        }
                                                                                                                        var thumbsView = document.getElementById('thumbnailView');
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.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

                                                                                                                    Function pdfHistory_goTo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                                                                    Open

                                                                                                                      _goTo: function pdfHistory_goTo(state) {
                                                                                                                        if (!(this.initialized && this.historyUnlocked &&
                                                                                                                              this._isStateObjectDefined(state))) {
                                                                                                                          return;
                                                                                                                        }
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.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

                                                                                                                    Function matchesReady has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                                                                    Open

                                                                                                                      matchesReady: function(matches) {
                                                                                                                        var offset = this.offset;
                                                                                                                        var numMatches = matches.length;
                                                                                                                        var previous = this.state.findPrevious;
                                                                                                                        if (numMatches) {
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.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

                                                                                                                    Function pdfViewGetVisibleElements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                                                                                    Open

                                                                                                                      getVisibleElements: function pdfViewGetVisibleElements(
                                                                                                                          scrollEl, views, sortByVisibility) {
                                                                                                                        var top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight;
                                                                                                                        var left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth;
                                                                                                                    
                                                                                                                    
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                      extractText: function() {
                                                                                                                        if (this.startedTextExtraction) {
                                                                                                                          return;
                                                                                                                        }
                                                                                                                        this.startedTextExtraction = true;
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 45 mins to fix

                                                                                                                    Cognitive Complexity

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

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

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

                                                                                                                    Further reading

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

                                                                                                                      open: function overlayManagerOpen(name) {
                                                                                                                        return new Promise(function (resolve) {
                                                                                                                          if (!this.overlays[name]) {
                                                                                                                            throw new Error('The overlay does not exist.');
                                                                                                                          } else if (this.active) {
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 45 mins to fix

                                                                                                                    Cognitive Complexity

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

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

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

                                                                                                                    Further reading

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

                                                                                                                      navigateTo: function pdfViewNavigateTo(dest) {
                                                                                                                        var destString = '';
                                                                                                                        var self = this;
                                                                                                                    
                                                                                                                        var goToDestination = function(destRef) {
                                                                                                                    Severity: Minor
                                                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 45 mins to fix

                                                                                                                    Cognitive Complexity

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

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

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

                                                                                                                    Further reading

                                                                                                                    Avoid deeply nested control flow statements.
                                                                                                                    Open

                                                                                                                                  if (data.action) {
                                                                                                                                    bindNamedAction(link, data.action);
                                                                                                                                  } else {
                                                                                                                                    bindLink(link, ('dest' in data) ? data.dest : null);
                                                                                                                                  }
                                                                                                                    Severity: Major
                                                                                                                    Found in public/mozilla-pdf/web/viewer.js - About 45 mins to fix

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

                                                                                                                      var PageView = function pageView(container, id, scale,
                                                                                                                                                       navigateTo, defaultViewport) {
                                                                                                                      Severity: Minor
                                                                                                                      Found in public/mozilla-pdf/web/viewer.js - About 35 mins to fix

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

                                                                                                                          open: function pdfViewOpen(url, scale, password,
                                                                                                                                                     pdfDataRangeTransport, args) {
                                                                                                                        Severity: Minor
                                                                                                                        Found in public/mozilla-pdf/web/viewer.js - About 35 mins to fix

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

                                                                                                                          var ProgressBar = (function ProgressBarClosure() {
                                                                                                                          
                                                                                                                            function clamp(v, min, max) {
                                                                                                                              return Math.min(Math.max(v, min), max);
                                                                                                                            }
                                                                                                                          Severity: Minor
                                                                                                                          Found in public/mozilla-pdf/web/viewer.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 updateMatch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                                          Open

                                                                                                                            updateMatch: function(found) {
                                                                                                                              var state = FindStates.FIND_NOTFOUND;
                                                                                                                              var wrapped = this.offset.wrapped;
                                                                                                                              this.offset.wrapped = false;
                                                                                                                              if (found) {
                                                                                                                          Severity: Minor
                                                                                                                          Found in public/mozilla-pdf/web/viewer.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 presentationModeMouseDown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                                          Open

                                                                                                                            mouseDown: function presentationModeMouseDown(evt) {
                                                                                                                              var self = PresentationMode;
                                                                                                                              if (self.contextMenuOpen) {
                                                                                                                                self.contextMenuOpen = false;
                                                                                                                                evt.preventDefault();
                                                                                                                          Severity: Minor
                                                                                                                          Found in public/mozilla-pdf/web/viewer.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 pdfHistory_pushToHistory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                                                          Open

                                                                                                                            _pushToHistory: function pdfHistory_pushToHistory(params,
                                                                                                                                                                              addPrevious, overwrite) {
                                                                                                                              if (!this.initialized) {
                                                                                                                                return;
                                                                                                                              }
                                                                                                                          Severity: Minor
                                                                                                                          Found in public/mozilla-pdf/web/viewer.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 false;
                                                                                                                          Severity: Major
                                                                                                                          Found in public/mozilla-pdf/web/viewer.js - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this function.
                                                                                                                            Open

                                                                                                                                  return null;
                                                                                                                            Severity: Major
                                                                                                                            Found in public/mozilla-pdf/web/viewer.js - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this function.
                                                                                                                              Open

                                                                                                                                  return params;
                                                                                                                              Severity: Major
                                                                                                                              Found in public/mozilla-pdf/web/viewer.js - About 30 mins to fix

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

                                                                                                                                  updateUIState: function(state, previous) {
                                                                                                                                    var notFound = false;
                                                                                                                                    var findMsg = '';
                                                                                                                                    var status = '';
                                                                                                                                
                                                                                                                                
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                      function pdfViewRenderHighestPriority(currentlyVisiblePages) {
                                                                                                                                    if (PDFView.idleTimeout) {
                                                                                                                                      clearTimeout(PDFView.idleTimeout);
                                                                                                                                      PDFView.idleTimeout = null;
                                                                                                                                    }
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                  initialize: function handToolInitialize(options) {
                                                                                                                                    var toggleHandTool = options.toggleHandTool;
                                                                                                                                    this.handTool = new GrabToPan({
                                                                                                                                      element: options.container,
                                                                                                                                      onActiveChanged: function(isActive) {
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                  request: function presentationModeRequest() {
                                                                                                                                    if (!PDFView.supportsFullscreen || this.isFullscreen ||
                                                                                                                                        !this.viewer.hasChildNodes()) {
                                                                                                                                      return false;
                                                                                                                                    }
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                function getPDFFileNameFromURL(url) {
                                                                                                                                  var reURI = /^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
                                                                                                                                  //            SCHEME      HOST         1.PATH  2.QUERY   3.REF
                                                                                                                                  // Pattern to get last matching NAME.pdf
                                                                                                                                  var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                  get: function preferencesGet(name) {
                                                                                                                                    return this.initializedPromise.then(function () {
                                                                                                                                      var defaultValue = DEFAULT_PREFERENCES[name];
                                                                                                                                
                                                                                                                                      if (defaultValue === undefined) {
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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

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

                                                                                                                                  calcFindMatch: function(pageIndex) {
                                                                                                                                    var pageContent = this.pageContents[pageIndex];
                                                                                                                                    var query = this.state.query;
                                                                                                                                    var caseSensitive = this.state.caseSensitive;
                                                                                                                                    var queryLen = query.length;
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.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 2 locations. Consider refactoring.
                                                                                                                                Open

                                                                                                                                      case 'outline':
                                                                                                                                        thumbsButton.classList.remove('toggled');
                                                                                                                                        outlineButton.classList.add('toggled');
                                                                                                                                        attachmentsButton.classList.remove('toggled');
                                                                                                                                        thumbsView.classList.add('hidden');
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 3787..3798

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

                                                                                                                                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

                                                                                                                                  zoomOut: function pdfViewZoomOut(ticks) {
                                                                                                                                    var newScale = this.currentScale;
                                                                                                                                    do {
                                                                                                                                      newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
                                                                                                                                      newScale = Math.floor(newScale * 10) / 10;
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2866..2874

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

                                                                                                                                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

                                                                                                                                  zoomIn: function pdfViewZoomIn(ticks) {
                                                                                                                                    var newScale = this.currentScale;
                                                                                                                                    do {
                                                                                                                                      newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
                                                                                                                                      newScale = Math.ceil(newScale * 10) / 10;
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2876..2884

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

                                                                                                                                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

                                                                                                                                      case 'attachments':
                                                                                                                                        thumbsButton.classList.remove('toggled');
                                                                                                                                        outlineButton.classList.remove('toggled');
                                                                                                                                        attachmentsButton.classList.add('toggled');
                                                                                                                                        thumbsView.classList.add('hidden');
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 3774..3785

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

                                                                                                                                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

                                                                                                                                      pdfDocument.getOutline().then(function(outline) {
                                                                                                                                        self.outline = new DocumentOutlineView(outline);
                                                                                                                                        document.getElementById('viewOutline').disabled = !outline;
                                                                                                                                
                                                                                                                                        if (outline &&
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 3494..3502

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

                                                                                                                                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

                                                                                                                                      pdfDocument.getAttachments().then(function(attachments) {
                                                                                                                                        self.attachments = new DocumentAttachmentsView(attachments);
                                                                                                                                        document.getElementById('viewAttachments').disabled = !attachments;
                                                                                                                                
                                                                                                                                        if (attachments &&
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 3 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 3485..3493

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

                                                                                                                                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 (!this.pdfPage) {
                                                                                                                                      var promise = PDFView.getPage(this.id);
                                                                                                                                      promise.then(function(pdfPage) {
                                                                                                                                        this.setPdfPage(pdfPage);
                                                                                                                                        this.setImage(img);
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 2 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 4791..4798

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

                                                                                                                                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 (!this.pdfPage) {
                                                                                                                                      var promise = PDFView.getPage(this.id);
                                                                                                                                      promise.then(function(pdfPage) {
                                                                                                                                        this.setPdfPage(pdfPage);
                                                                                                                                        this.draw(callback);
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 2 hrs to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 4842..4849

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

                                                                                                                                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 (!PDFView.supportsFullscreen) {
                                                                                                                                    document.getElementById('presentationMode').classList.add('hidden');
                                                                                                                                    document.getElementById('secondaryPresentationMode').
                                                                                                                                      classList.add('hidden');
                                                                                                                                  }
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 1 hr to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 5376..5379

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

                                                                                                                                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 (!PDFView.supportsPrinting) {
                                                                                                                                    document.getElementById('print').classList.add('hidden');
                                                                                                                                    document.getElementById('secondaryPrint').classList.add('hidden');
                                                                                                                                  }
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 1 hr to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 5381..5385

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

                                                                                                                                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

                                                                                                                                    this.firstPage.addEventListener('click', function() {
                                                                                                                                      this.contextMenuOpen = false;
                                                                                                                                      this.secondaryToolbar.firstPageClick();
                                                                                                                                    }.bind(this));
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 3 other locations - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1796..1799
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1801..1804
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1805..1808

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

                                                                                                                                    this.pageRotateCcw.addEventListener('click', function() {
                                                                                                                                      this.contextMenuOpen = false;
                                                                                                                                      this.secondaryToolbar.pageRotateCcwClick();
                                                                                                                                    }.bind(this));
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 3 other locations - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1792..1795
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1796..1799
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1801..1804

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

                                                                                                                                    this.pageRotateCw.addEventListener('click', function() {
                                                                                                                                      this.contextMenuOpen = false;
                                                                                                                                      this.secondaryToolbar.pageRotateCwClick();
                                                                                                                                    }.bind(this));
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 3 other locations - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1792..1795
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1796..1799
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1805..1808

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

                                                                                                                                    canvas.style.height = canvas.parentNode.style.height = div.style.height =
                                                                                                                                        Math.floor(height) + 'px';
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 4129..4130

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

                                                                                                                                    this.lastPage.addEventListener('click', function() {
                                                                                                                                      this.contextMenuOpen = false;
                                                                                                                                      this.secondaryToolbar.lastPageClick();
                                                                                                                                    }.bind(this));
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 3 other locations - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1792..1795
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1801..1804
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1805..1808

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

                                                                                                                                    canvas.style.width = canvas.parentNode.style.width = div.style.width =
                                                                                                                                        Math.floor(width) + 'px';
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 55 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 4131..4132

                                                                                                                                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

                                                                                                                                  get supportsDocumentFonts() {
                                                                                                                                    var support = true;
                                                                                                                                    Object.defineProperty(this, 'supportsDocumentFonts', { value: support,
                                                                                                                                                                                           enumerable: true,
                                                                                                                                                                                           configurable: true,
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 2 other locations - About 50 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2950..2957
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2968..2975

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

                                                                                                                                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

                                                                                                                                  get supportsIntegratedFind() {
                                                                                                                                    var support = false;
                                                                                                                                    Object.defineProperty(this, 'supportsIntegratedFind', { value: support,
                                                                                                                                                                                            enumerable: true,
                                                                                                                                                                                            configurable: true,
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 2 other locations - About 50 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2959..2966
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2968..2975

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

                                                                                                                                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

                                                                                                                                  get supportsDocumentColors() {
                                                                                                                                    var support = true;
                                                                                                                                    Object.defineProperty(this, 'supportsDocumentColors', { value: support,
                                                                                                                                                                                            enumerable: true,
                                                                                                                                                                                            configurable: true,
                                                                                                                                Severity: Major
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 2 other locations - About 50 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2950..2957
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2959..2966

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

                                                                                                                                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

                                                                                                                                        } else {
                                                                                                                                          toggleHandTool.title =
                                                                                                                                            mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
                                                                                                                                          toggleHandTool.firstElementChild.textContent =
                                                                                                                                            mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 40 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2226..2231

                                                                                                                                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 (isActive) {
                                                                                                                                          toggleHandTool.title =
                                                                                                                                            mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
                                                                                                                                          toggleHandTool.firstElementChild.textContent =
                                                                                                                                            mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 40 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2231..2236

                                                                                                                                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

                                                                                                                                  toggle: function secondaryToolbarToggle() {
                                                                                                                                    if (this.opened) {
                                                                                                                                      this.close();
                                                                                                                                    } else {
                                                                                                                                      this.open();
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 35 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 2084..2090

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

                                                                                                                                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

                                                                                                                                    toggle: function GrabToPan_toggle() {
                                                                                                                                      if (this.active) {
                                                                                                                                        this.deactivate();
                                                                                                                                      } else {
                                                                                                                                        this.activate();
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 35 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 1761..1767

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

                                                                                                                                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 (!evt.resetAutoSettings &&
                                                                                                                                      (document.getElementById('pageWidthOption').selected ||
                                                                                                                                       document.getElementById('pageFitOption').selected ||
                                                                                                                                       document.getElementById('pageAutoOption').selected)) {
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 35 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 5573..5576

                                                                                                                                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 (PDFView.initialized &&
                                                                                                                                      (document.getElementById('pageWidthOption').selected ||
                                                                                                                                       document.getElementById('pageFitOption').selected ||
                                                                                                                                       document.getElementById('pageAutoOption').selected)) {
                                                                                                                                Severity: Minor
                                                                                                                                Found in public/mozilla-pdf/web/viewer.js and 1 other location - About 35 mins to fix
                                                                                                                                public/mozilla-pdf/web/viewer.js on lines 5667..5670

                                                                                                                                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