Showing 529 of 529 total issues

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

(function() {

  i18n.date = {
    L: "DD/MM/YYYY",
    XL: "dddd DD/MM/YYYY",
Severity: Major
Found in app/assets/javascripts/i18n/formats/en-GB.js and 5 other locations - About 1 day to fix
app/assets/javascripts/i18n/formats/en-US.js on lines 2..66
app/assets/javascripts/i18n/formats/gsw-CH.js on lines 2..66
app/assets/javascripts/i18n/locale/en-GB.js on lines 3..67
app/assets/javascripts/i18n/locale/en-US.js on lines 3..67
app/assets/javascripts/i18n/locale/gsw-CH.js on lines 3..67

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

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

(function() {

  i18n.date = {
    L: "MM/DD/YYYY",
    XL: "dddd MM/DD/YYYY",
Severity: Major
Found in app/assets/javascripts/i18n/formats/en-US.js and 5 other locations - About 1 day to fix
app/assets/javascripts/i18n/formats/en-GB.js on lines 2..66
app/assets/javascripts/i18n/formats/gsw-CH.js on lines 2..66
app/assets/javascripts/i18n/locale/en-GB.js on lines 3..67
app/assets/javascripts/i18n/locale/en-US.js on lines 3..67
app/assets/javascripts/i18n/locale/gsw-CH.js on lines 3..67

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

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

(function() {

  i18n.date = {
    L: "DD.MM.YYYY",
    XL: "dddd DD.MM.YYYY",
Severity: Major
Found in app/assets/javascripts/i18n/locale/gsw-CH.js and 5 other locations - About 1 day to fix
app/assets/javascripts/i18n/formats/en-GB.js on lines 2..66
app/assets/javascripts/i18n/formats/en-US.js on lines 2..66
app/assets/javascripts/i18n/formats/gsw-CH.js on lines 2..66
app/assets/javascripts/i18n/locale/en-GB.js on lines 3..67
app/assets/javascripts/i18n/locale/en-US.js on lines 3..67

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

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

  function getPluralRules(lang) {
    var locales2rules = {
      'af': 3,
      'ak': 4,
      'am': 4,
Severity: Major
Found in public/mozilla-pdf/web/l10n.js - About 1 day to fix

    File l10n.js has 779 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Copyright (c) 2011-2013 Fabien Cazenave, Mozilla.
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to
    Severity: Major
    Found in public/mozilla-pdf/web/l10n.js - About 1 day to fix

      Function WorkerTransportClosure has 356 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var WorkerTransport = (function WorkerTransportClosure() {
        function WorkerTransport(workerInitializedCapability, workerReadyCapability,
                                 pdfDataRangeTransport, progressCallback) {
          this.pdfDataRangeTransport = pdfDataRangeTransport;
      
      
      Severity: Major
      Found in public/mozilla-pdf/core/pdf.js - About 1 day to fix

        Function WebGLUtilsClosure has 347 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var WebGLUtils = (function WebGLUtilsClosure() {
          function loadShader(gl, code, shaderType) {
            var shader = gl.createShader(shaderType);
            gl.shaderSource(shader, code);
            gl.compileShader(shader);
        Severity: Major
        Found in public/mozilla-pdf/core/pdf.js - About 1 day to fix

          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

          Consider simplifying this complex logical expression.
          Open

              elsif request.format.to_sym == :json or
                    (request[:controller] == "media_resources" and request[:action] == "image") or 
                    (request[:controller] == "media_resources" and request[:action] == "show") or
                    (request[:controller] == "media_resources" and request[:action] == "index") or
                    (request[:controller] == "media_resources" and request[:action] == "browse") or
          Severity: Critical
          Found in app/controllers/application_controller.rb - About 1 day to fix

            Function StepperClosure has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
            Open

            var Stepper = (function StepperClosure() {
              // Shorter way to create element and optionally set textContent.
              function c(tag, textContent) {
                var d = document.createElement(tag);
                if (textContent) {
            Severity: Minor
            Found in public/mozilla-pdf/web/debugger.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 AnnotationClosure has 269 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var Annotation = (function AnnotationClosure() {
              // 12.5.5: Algorithm: Appearance streams
              function getTransformMatrix(rect, bbox, matrix) {
                var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
                var minX = bounds[0];
            Severity: Major
            Found in public/mozilla-pdf/core/pdf.js - About 1 day to fix

              Function PromiseClosure has 248 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              (function PromiseClosure() {
                if (globalScope.Promise) {
                  // Promises existing in the DOM/Worker, checking presence of all/resolve
                  if (typeof globalScope.Promise.all !== 'function') {
                    globalScope.Promise.all = function (iterable) {
              Severity: Major
              Found in public/mozilla-pdf/core/pdf.js - About 1 day to fix

                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

                  File debugger.js has 552 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/debugger.js - About 1 day to fix

                    Method login_from_session has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def login_from_session
                        user = nil
                    
                        if session[:user_id]
                    
                    
                    Severity: Minor
                    Found in app/controllers/application_controller.rb - 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

                    Method the_messy_before_filter has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def the_messy_before_filter 
                        if [:edit_multiple, :update_multiple, :remove_multiple].include? request[:action].to_sym
                          begin
                            if !params[:media_set_id].blank?
                              action = case request[:action].to_sym
                    Severity: Minor
                    Found in app/controllers/media_entries_controller.rb - 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 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

                      Method process_metadata has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def process_metadata meta_arr
                            meta_arr.each do |tag_array_entry|
                              tag_array_entry.each do |entry_key, entry_value|
                      
                                if entry_key =~ /^XMP-(expressionmedia|mediapro):UserFields/
                      Severity: Minor
                      Found in app/models/media_resource_modules/meta_data_extraction.rb - About 7 hrs to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                              function WorkerTransport_setupMessageHandler(messageHandler) {
                              this.messageHandler = messageHandler;
                        
                              function updatePassword(password) {
                                messageHandler.send('UpdatePassword', password);
                        Severity: Major
                        Found in public/mozilla-pdf/core/pdf.js - About 7 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language