haraka/haraka-plugin-elasticsearch

View on GitHub

Showing 15 of 16 total issues

Function populate_conn_properties has a Cognitive Complexity of 24 (exceeds 6 allowed). Consider refactoring.
Open

exports.populate_conn_properties = function (conn, res) {
let conn_res = res
 
if (this.cfg.top_level_names?.connection) {
if (!res[this.cfg.top_level_names.connection]) {
Severity: Minor
Found in index.js - About 3 hrs to fix

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

this.es
.create({
index: this.getIndexName('transaction'),
id: utils.uuid(),
document: doc,
Severity: Major
Found in index.js and 2 other locations - About 2 hrs to fix
index.js on lines 198..209
index.js on lines 226..237

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

this.es
.create({
index: this.getIndexName('transaction'),
id: utils.uuid(),
document: doc,
Severity: Major
Found in index.js and 2 other locations - About 2 hrs to fix
index.js on lines 198..209
index.js on lines 254..265

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

this.es
.create({
index: this.getIndexName('transaction'),
id: utils.uuid(),
document: doc,
Severity: Major
Found in index.js and 2 other locations - About 2 hrs to fix
index.js on lines 226..237
index.js on lines 254..265

Function prune_empty has a Cognitive Complexity of 17 (exceeds 6 allowed). Consider refactoring.
Open

exports.prune_empty = function (pi) {
// remove undefined keys and empty strings, arrays, or objects
for (const e in pi) {
const val = pi[e]
if (val === undefined || val === null) {
Severity: Minor
Found in index.js - About 2 hrs to fix

Function prune_noisy has 67 lines of code (exceeds 45 allowed). Consider refactoring.
Open

exports.prune_noisy = function (res, pi) {
if (res[pi].human) delete res[pi].human
if (res[pi].human_html) delete res[pi].human_html
if (res[pi]._watch_saw) delete res[pi]._watch_saw
 
 
Severity: Major
Found in index.js - About 1 hr to fix

    Function populate_conn_properties has 60 lines of code (exceeds 45 allowed). Consider refactoring.
    Open

    exports.populate_conn_properties = function (conn, res) {
    let conn_res = res
     
    if (this.cfg.top_level_names?.connection) {
    if (!res[this.cfg.top_level_names.connection]) {
    Severity: Major
    Found in index.js - About 1 hr to fix

      Function load_es_ini has a Cognitive Complexity of 14 (exceeds 6 allowed). Consider refactoring.
      Open

      exports.load_es_ini = function () {
      this.cfg = this.config.get(
      'elasticsearch.ini',
      {
      booleans: [
      Severity: Minor
      Found in index.js - About 1 hr to fix

      Function prune_noisy has a Cognitive Complexity of 12 (exceeds 6 allowed). Consider refactoring.
      Open

      exports.prune_noisy = function (res, pi) {
      if (res[pi].human) delete res[pi].human
      if (res[pi].human_html) delete res[pi].human_html
      if (res[pi]._watch_saw) delete res[pi]._watch_saw
       
       
      Severity: Minor
      Found in index.js - About 1 hr to fix

      Function populate_message has a Cognitive Complexity of 11 (exceeds 6 allowed). Consider refactoring.
      Open

      exports.populate_message = function (pir, connection) {
      pir.message = {
      bytes: connection.transaction.data_bytes,
      envelope: {
      sender: '',
      Severity: Minor
      Found in index.js - About 1 hr to fix

      Function get_plugin_results has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
      Open

      exports.get_plugin_results = function (connection) {
      let name
       
      // make a copy of the result store, so subsequent changes don't alter the original (by reference)
      const pir = JSON.parse(JSON.stringify(connection.results.get_all()))
      Severity: Minor
      Found in index.js - About 55 mins to fix

      Avoid deeply nested control flow statements.
      Open

      if (Object.keys(val).length === 0) delete pi[e]
      Severity: Major
      Found in index.js - About 45 mins to fix

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

        if (this.cfg.ignore_hosts) {
        if (this.cfg.ignore_hosts[connection.remote.host]) return next()
        }
        Severity: Minor
        Found in index.js and 1 other location - About 30 mins to fix
        index.js on lines 146..148

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

        if (this.cfg.ignore_hosts) {
        if (this.cfg.ignore_hosts[connection.remote.host]) return next()
        }
        Severity: Minor
        Found in index.js and 1 other location - About 30 mins to fix
        index.js on lines 109..111

        Function prune_redundant_txn has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
        Open

        exports.prune_redundant_txn = function (res, name) {
        switch (name) {
        case 'local':
        case 'remote':
        case 'reset':
        Severity: Minor
        Found in index.js - About 25 mins to fix
        Severity
        Category
        Status
        Source
        Language