Showing 529 of 529 total issues

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

Function putBinaryImageData has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function putBinaryImageData(ctx, imgData) {
    if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
      ctx.putImageData(imgData, 0, 0);
      return;
    }
Severity: Major
Found in public/mozilla-pdf/core/pdf.js - About 3 hrs to fix

    Method index has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        respond_to do |format|
          format.json do
            groups = Group.where('name ilike :query OR institutional_group_name ilike :query',
                                  {:query => "%#{params[:query]}%"})
    Severity: Minor
    Found in app/controllers/app_admin/groups_controller.rb - 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 InternalRenderTaskClosure has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var InternalRenderTask = (function InternalRenderTaskClosure() {
    
      function InternalRenderTask(callback, params, objs, commonObjs, operatorList,
                                  pageNumber) {
        this.callback = callback;
    Severity: Major
    Found in public/mozilla-pdf/core/pdf.js - About 3 hrs to fix

      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 addContextCurrentTransform has 91 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function addContextCurrentTransform(ctx) {
          // If the context doesn't expose a `mozCurrentTransform`, add a JS based on.
          if (!ctx.mozCurrentTransform) {
            // Store the original context
            ctx._scaleX = ctx._scaleX || 1.0;
        Severity: Major
        Found in public/mozilla-pdf/core/pdf.js - About 3 hrs to fix

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

                if (bbox && isArray(bbox) && 4 == bbox.length) {
                  var width = bbox[2] - bbox[0];
                  var height = bbox[3] - bbox[1];
                  this.rectangle(bbox[0], bbox[1], width, height);
                  this.clip();
          Severity: Major
          Found in public/mozilla-pdf/core/pdf.js and 1 other location - About 3 hrs to fix
          public/mozilla-pdf/core/pdf.js on lines 5450..5456

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

          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 (rect && isArray(rect) && 4 == rect.length) {
                  var width = rect[2] - rect[0];
                  var height = rect[3] - rect[1];
                  this.rectangle(rect[0], rect[1], width, height);
                  this.clip();
          Severity: Major
          Found in public/mozilla-pdf/core/pdf.js and 1 other location - About 3 hrs to fix
          public/mozilla-pdf/core/pdf.js on lines 5298..5304

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

          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

          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

          Method index has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              respond_to do |format|
                format.json {
                  users = Person.hacky_search(params[:query]).map(&:user).compact
                  render :json => view_context.json_for(users)
          Severity: Minor
          Found in app/controllers/app_admin/users_controller.rb - 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 parseResource has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function parseResource(href, lang, successCallback, failureCallback) {
              var baseURL = href.replace(/[^\/]*$/, '') || './';
          
              // handle escaped characters (backslashes) in a string
              function evalString(text) {
          Severity: Major
          Found in public/mozilla-pdf/web/l10n.js - About 3 hrs to fix

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

            var FontInspector = (function FontInspectorClosure() {
              var fonts;
              var active = false;
              var fontAttribute = 'data-font-name';
              function removeSelection() {
            Severity: Minor
            Found in public/mozilla-pdf/web/debugger.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

              Method update has 79 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def update
              
                  groups= Array(params[:groups].is_a?(Hash) ? params[:groups].values : params[:groups])
              
                  users = Array(params[:users].is_a?(Hash) ? params[:users].values : params[:users]) 
              Severity: Major
              Found in app/controllers/permissions_controller.rb - About 3 hrs to fix

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

                (function checkTypedArrayCompatibility() {
                  if (typeof Uint8Array !== 'undefined') {
                    // Support: iOS<6.0
                    if (typeof Uint8Array.prototype.subarray === 'undefined') {
                        Uint8Array.prototype.subarray = function subarray(start, end) {
                Severity: Minor
                Found in public/mozilla-pdf/web/compatibility.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 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

                Method create has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create
                    
                    attr = params[:media_sets] || params[:media_set]
                    filter = params[:filter]
                    is_saved = true
                Severity: Minor
                Found in app/controllers/media_sets_controller.rb - 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
                  Severity
                  Category
                  Status
                  Source
                  Language