zammad/zammad

View on GitHub
app/assets/javascripts/app/lib/base/exif.js

Summary

Maintainability
F
5 days
Test Coverage

File exif.js has 698 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {

    var debug = false;

    var root = this;
Severity: Major
Found in app/assets/javascripts/app/lib/base/exif.js - About 1 day to fix

    Function readTagValue has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) {
            var type = file.getUint16(entryOffset+2, !bigEnd),
                numValues = file.getUint32(entryOffset+4, !bigEnd),
                valueOffset = file.getUint32(entryOffset+8, !bigEnd) + tiffStart,
                offset,
    Severity: Major
    Found in app/assets/javascripts/app/lib/base/exif.js - About 3 hrs to fix

      Function readEXIFData has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function readEXIFData(file, start) {
              if (getStringFromDB(file, start, 4) != "Exif") {
                  if (debug) console.log("Not valid EXIF data! " + getStringFromDB(file, start, 4));
                  return false;
              }
      Severity: Major
      Found in app/assets/javascripts/app/lib/base/exif.js - About 3 hrs to fix

        Function getImageData has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function getImageData(img, callback) {
                function handleBinaryFile(binFile) {
                    var data = findEXIFinJPEG(binFile);
                    var iptcdata = findIPTCinJPEG(binFile);
                    img.exifdata = data || {};
        Severity: Minor
        Found in app/assets/javascripts/app/lib/base/exif.js - About 1 hr to fix

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

              function findIPTCinJPEG(file) {
                  var dataView = new DataView(file);
          
                  if (debug) console.log("Got file of length " + file.byteLength);
                  if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
          Severity: Minor
          Found in app/assets/javascripts/app/lib/base/exif.js - About 1 hr to fix

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

                function readIPTCData(file, startOffset, sectionLength){
                    var dataView = new DataView(file);
                    var data = {};
                    var fieldValue, fieldName, dataSize, segmentType, segmentSize;
                    var segmentStartPos = startOffset;
            Severity: Minor
            Found in app/assets/javascripts/app/lib/base/exif.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if(data[fieldName] instanceof Array) {
                                          data[fieldName].push(fieldValue);
                                      }
                                      else {
                                          data[fieldName] = [data[fieldName], fieldValue];
              Severity: Major
              Found in app/assets/javascripts/app/lib/base/exif.js - About 45 mins to fix

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

                    function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd) {
                Severity: Minor
                Found in app/assets/javascripts/app/lib/base/exif.js - About 35 mins to fix

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

                      function readTags(file, tiffStart, dirStart, strings, bigEnd) {
                  Severity: Minor
                  Found in app/assets/javascripts/app/lib/base/exif.js - About 35 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return vals;
                    Severity: Major
                    Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return vals;
                      Severity: Major
                      Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return vals;
                        Severity: Major
                        Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                              return file.getInt32(entryOffset + 8, !bigEnd);
                          Severity: Major
                          Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return tags;
                            Severity: Major
                            Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                  return file.getUint32(entryOffset + 8, !bigEnd);
                              Severity: Major
                              Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                    return vals;
                                Severity: Major
                                Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                      return vals;
                                  Severity: Major
                                  Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                        return val;
                                    Severity: Major
                                    Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                          return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset+4, !bigEnd);
                                      Severity: Major
                                      Found in app/assets/javascripts/app/lib/base/exif.js - About 30 mins to fix

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

                                                    case 4: // long, 32 bit int
                                                        if (numValues == 1) {
                                                            return file.getUint32(entryOffset + 8, !bigEnd);
                                                        } else {
                                                            vals = [];
                                        Severity: Major
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 3 hrs to fix
                                        app/assets/javascripts/app/lib/base/exif.js on lines 619..628

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

                                        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 9: // slong, 32 bit signed int
                                                        if (numValues == 1) {
                                                            return file.getInt32(entryOffset + 8, !bigEnd);
                                                        } else {
                                                            vals = [];
                                        Severity: Major
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 3 hrs to fix
                                        app/assets/javascripts/app/lib/base/exif.js on lines 588..597

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

                                        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 ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
                                                    if (debug) console.log("Not a valid JPEG");
                                                    return false; // not a valid jpeg
                                                }
                                        Severity: Major
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 1 hr to fix
                                        app/assets/javascripts/app/lib/base/exif.js on lines 437..440

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

                                        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 ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8)) {
                                                    if (debug) console.log("Not a valid JPEG");
                                                    return false; // not a valid jpeg
                                                }
                                        Severity: Major
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 1 hr to fix
                                        app/assets/javascripts/app/lib/base/exif.js on lines 397..400

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

                                        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

                                                if (element.addEventListener) {
                                                    element.addEventListener(event, handler, false);
                                                } else if (element.attachEvent) {
                                                    element.attachEvent("on" + event, handler);
                                                }
                                        Severity: Major
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 2 other locations - About 50 mins to fix
                                        app/assets/javascripts/app/lib/base/jquery.fineuploader-3.0.js on lines 24..28
                                        app/assets/javascripts/app/lib/base/jquery.fineuploader-3.0.js on lines 35..39

                                        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

                                            var EXIF = function(obj) {
                                                if (obj instanceof EXIF) return obj;
                                                if (!(this instanceof EXIF)) return new EXIF(obj);
                                                this.EXIFwrapped = obj;
                                            };
                                        Severity: Minor
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 50 mins to fix
                                        app/assets/javascripts/app/lib/core/underscore-1.8.3.js on lines 39..43

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

                                        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

                                                ExposureProgram : {
                                                    0 : "Not defined",
                                                    1 : "Manual",
                                                    2 : "Normal program",
                                                    3 : "Aperture priority",
                                        Severity: Minor
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 50 mins to fix
                                        app/frontend/apps/desktop/styles/tailwind.desktop.js on lines 34..44

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

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

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

                                            if (typeof exports !== 'undefined') {
                                                if (typeof module !== 'undefined' && module.exports) {
                                                    exports = module.exports = EXIF;
                                                }
                                                exports.EXIF = EXIF;
                                        Severity: Minor
                                        Found in app/assets/javascripts/app/lib/base/exif.js and 1 other location - About 50 mins to fix
                                        app/assets/javascripts/app/lib/core/underscore-1.8.3.js on lines 48..55

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

                                        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