antimalware/manul

View on GitHub
src/log_analyzer/js/zip.js

Summary

Maintainability
F
5 days
Test Coverage

File zip.js has 677 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 Copyright (c) 2013 Gildas Lormeau. All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
Severity: Major
Found in src/log_analyzer/js/zip.js - About 1 day to fix

    Function createZipWriter has 120 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function createZipWriter(writer, onerror, dontDeflate) {
            var worker, files = {}, filenames = [], datalength = 0;
    
            function terminate(callback, message) {
                if (worker)
    Severity: Major
    Found in src/log_analyzer/js/zip.js - About 4 hrs to fix

      Function createZipReader has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function createZipReader(reader, onerror) {
              function Entry() {
              }
      
              Entry.prototype.getData = function(writer, onend, onprogress, checkCrc32) {
      Severity: Major
      Found in src/log_analyzer/js/zip.js - About 4 hrs to fix

        Function add has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    add : function(name, reader, onend, onprogress, options) {
                        var header, filename, date;
        
                        function writeHeader(callback) {
                            var data;
        Severity: Major
        Found in src/log_analyzer/js/zip.js - About 2 hrs to fix

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

              function launchWorkerProcess(worker, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
                  var chunkIndex = 0, index, outputSize;
          
                  function onflush() {
                      worker.removeEventListener(MESSAGE_EVENT, onmessage, false);
          Severity: Minor
          Found in src/log_analyzer/js/zip.js - About 1 hr to fix

            Function getData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    Entry.prototype.getData = function(writer, onend, onprogress, checkCrc32) {
                        var that = this, worker;
            
                        function terminate(callback, param) {
                            if (worker)
            Severity: Minor
            Found in src/log_analyzer/js/zip.js - About 1 hr to fix

              Function getEntries has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          getEntries : function(callback) {
                              if (reader.size < 22) {
                                  onerror(ERR_BAD_FORMAT);
                                  return;
                              }
              Severity: Minor
              Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                Function launchProcess has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function launchProcess(process, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
                        var chunkIndex = 0, index, outputSize = 0;
                
                        function step() {
                            var outputData;
                Severity: Minor
                Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                  Function launchProcess has 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      function launchProcess(process, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
                  Severity: Major
                  Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                    Function launchWorkerProcess has 10 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        function launchWorkerProcess(worker, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
                    Severity: Major
                    Found in src/log_analyzer/js/zip.js - About 1 hr to fix

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

                                  close : function(callback) {
                                      var data, length = 0, index = 0, indexFilename, file;
                                      for (indexFilename = 0; indexFilename < filenames.length; indexFilename++) {
                                          file = files[filenames[indexFilename]];
                                          length += 46 + file.filename.length + file.comment.length;
                      Severity: Minor
                      Found in src/log_analyzer/js/zip.js - About 1 hr to fix

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

                                function step() {
                                    var outputData;
                                    index = chunkIndex * CHUNK_SIZE;
                                    if (index < size)
                                        reader.readUint8Array(offset + index, Math.min(CHUNK_SIZE, size - index), function(inputData) {
                        Severity: Minor
                        Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                          Function inflate has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              function inflate(reader, writer, offset, size, computeCrc32, onend, onprogress, onreaderror, onwriteerror) {
                          Severity: Major
                          Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                            Function copy has 9 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                function copy(reader, writer, offset, size, computeCrc32, onend, onprogress, onreaderror, onwriteerror) {
                            Severity: Major
                            Found in src/log_analyzer/js/zip.js - About 1 hr to fix

                              Function deflate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  function deflate(reader, writer, level, onend, onprogress, onreaderror, onwriteerror) {
                              Severity: Major
                              Found in src/log_analyzer/js/zip.js - About 50 mins to fix

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

                                    function readCommonHeader(entry, data, index, centralDirectory, onerror) {
                                Severity: Minor
                                Found in src/log_analyzer/js/zip.js - About 35 mins to fix

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

                                              add : function(name, reader, onend, onprogress, options) {
                                  Severity: Minor
                                  Found in src/log_analyzer/js/zip.js - About 35 mins to fix

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

                                            function writeUint8Array(array, callback) {
                                                blob = new Blob([ blob, appendABViewSupported ? array : array.buffer ], {
                                                    type : TEXT_PLAIN
                                                });
                                                callback();
                                    Severity: Minor
                                    Found in src/log_analyzer/js/zip.js and 1 other location - About 35 mins to fix
                                    src/log_analyzer/js/zip.js on lines 270..275

                                    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

                                            function writeUint8Array(array, callback) {
                                                blob = new Blob([ blob, appendABViewSupported ? array : array.buffer ], {
                                                    type : contentType
                                                });
                                                callback();
                                    Severity: Minor
                                    Found in src/log_analyzer/js/zip.js and 1 other location - About 35 mins to fix
                                    src/log_analyzer/js/zip.js on lines 204..209

                                    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 (data) {
                                                        outputSize += data.length;
                                                        writer.writeUint8Array(data, function() {
                                                            onappend(false, data);
                                                            onflush();
                                    Severity: Minor
                                    Found in src/log_analyzer/js/zip.js and 1 other location - About 35 mins to fix
                                    src/log_analyzer/js/zip.js on lines 301..307

                                    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 (message.onappend) {
                                                    outputSize += data.length;
                                                    writer.writeUint8Array(data, function() {
                                                        onappend(false, data);
                                                        step();
                                    Severity: Minor
                                    Found in src/log_analyzer/js/zip.js and 1 other location - About 35 mins to fix
                                    src/log_analyzer/js/zip.js on lines 309..316

                                    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

                                    There are no issues that match your filters.

                                    Category
                                    Status