acharkizakaria/haraka-plugin-accounting-files

View on GitHub

Showing 30 of 30 total issues

File index.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// accounting_files
//------------
// documentation via: `haraka -h accounting_files`
 
//var outbound = require("./outbound");
Severity: Minor
Found in index.js - About 4 hrs to fix

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

    if ( type == 'delivered' ){
    //Set new paths to the notes
    server.notes.delivered_file_path = path.join( server.notes.delivered_dir_path, "d." + dateFormat(new Date(), "yyyy-mm-dd-HHMMss") + "." + server.notes.files_extension);
    createFileIfNotExist(server.notes.delivered_file_path, server.notes.delivered_fields); //Create delivered file
     
     
    Severity: Major
    Found in index.js and 2 other locations - About 4 hrs to fix
    index.js on lines 365..380
    index.js on lines 373..380

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

    else if ( type == 'deferred' ){
    //Set new paths to the notes
    server.notes.deferred_file_path = path.join( server.notes.deferred_dir_path, "t." + dateFormat(new Date(), "yyyy-mm-dd-HHMMss") + "." + server.notes.files_extension);
    createFileIfNotExist(server.notes.deferred_file_path, server.notes.deferred_fields); //Create deferred file
     
     
    Severity: Major
    Found in index.js and 2 other locations - About 4 hrs to fix
    index.js on lines 357..380
    index.js on lines 373..380

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

    else if ( type == 'bounce' ){
    //Set new paths to the notes
    server.notes.bounce_file_path = path.join( server.notes.bounce_dir_path, "b." + dateFormat(new Date(), "yyyy-mm-dd-HHMMss") + "." + server.notes.files_extension);
    createFileIfNotExist(server.notes.bounce_file_path, server.notes.bounce_fields); //Create bounce file
     
     
    Severity: Major
    Found in index.js and 2 other locations - About 4 hrs to fix
    index.js on lines 357..380
    index.js on lines 365..380

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

    exports.bounce = function (next, hmail, error) {
    var plugin = this;
    var todo = hmail.todo;
    var header = hmail.notes.header;
    var rcpt_to = todo.rcpt_to[0];
    Severity: Major
    Found in index.js - About 2 hrs to fix

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

      exports.init_plugin = function (next) {
      var context = this;
      var acct_path = cfg.main.path || path.join(process.env.HARAKA, "accounting_files");
      var separator = cfg.main.separator || " ";
      var files_extension = cfg.main.extension || "tsv";
      Severity: Major
      Found in index.js - About 2 hrs to fix

        Function deferred has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.deferred = function (next, hmail, params) {
        var plugin = this;
        var todo = hmail.todo;
        var header = hmail.notes.header;
        var rcpt_to = todo.rcpt_to[0];
        Severity: Major
        Found in index.js - About 2 hrs to fix

          Function delivered has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.delivered = function (next, hmail, params) {
          var plugin = this;
          var todo = hmail.todo;
          var header = hmail.notes.header;
          var rcpt_to = todo.rcpt_to[0];
          Severity: Major
          Found in index.js - About 2 hrs to fix

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

            exports.init_plugin = function (next) {
            var context = this;
            var acct_path = cfg.main.path || path.join(process.env.HARAKA, "accounting_files");
            var separator = cfg.main.separator || " ";
            var files_extension = cfg.main.extension || "tsv";
            Severity: Minor
            Found in index.js - About 1 hr to fix

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

            fs.rename(filename, archive_to_path + "/" + file_base_name, function (err) {
            if (err) {
            context.loginfo("Can't move file '" + file_base_name + "' " + err);
            throw err;
            } else {
            Severity: Major
            Found in index.js and 1 other location - About 1 hr to fix
            index.js on lines 441..448

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

            fs.rename(from_dir + "/" + filename, to_dir + "/" + filename, function (_err) {
            if (_err) {
            context.loginfo("Can't archive file '" + filename + "' " + _err);
            throw _err;
            } else {
            Severity: Major
            Found in index.js and 1 other location - About 1 hr to fix
            index.js on lines 480..487

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

            var addRecord = function (filename, fields, fields_values, type, context) {
            Severity: Minor
            Found in index.js - About 35 mins to fix

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

              case (field.match(/^custom_/) || {}).input :
              fields_values[field] = header.get(field) || " - ";
              break;
              Severity: Minor
              Found in index.js and 2 other locations - About 30 mins to fix
              index.js on lines 168..170
              index.js on lines 299..301

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

              case (field.match(/^custom_/) || {}).input :
              fields_values[field] = header.get(field) || " - ";
              break;
              Severity: Minor
              Found in index.js and 2 other locations - About 30 mins to fix
              index.js on lines 168..170
              index.js on lines 232..234

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

              case (field.match(/^custom_/) || {}).input :
              fields_values[field] = header.get(field) || " - ";
              break;
              Severity: Minor
              Found in index.js and 2 other locations - About 30 mins to fix
              index.js on lines 232..234
              index.js on lines 299..301

              'error' is defined but never used.
              Open

              exports.bounce = function (next, hmail, error) {
              Severity: Minor
              Found in index.js by eslint

              'exports' is not defined.
              Open

              exports.deferred = function (next, hmail, params) {
              Severity: Minor
              Found in index.js by eslint

              'exports' is not defined.
              Open

              exports.register = function () {
              Severity: Minor
              Found in index.js by eslint

              'exports' is not defined.
              Open

              exports.shutdown = function () {
              Severity: Minor
              Found in index.js by eslint

              'exports' is not defined.
              Open

              exports.delivered = function (next, hmail, params) {
              Severity: Minor
              Found in index.js by eslint
              Severity
              Category
              Status
              Source
              Language