haraka/haraka-plugin-uribl

View on GitHub

Showing 13 of 15 total issues

Function do_lookups has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
Open

exports.do_lookups = function (connection, next, hosts, type) {
  const plugin = this;

  // Store the results in the correct place based on the lookup type
  const results = connection?.transaction?.results || connection?.results;
Severity: Minor
Found in index.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 do_lookups has 157 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.do_lookups = function (connection, next, hosts, type) {
  const plugin = this;

  // Store the results in the correct place based on the lookup type
  const results = connection?.transaction?.results || connection?.results;
Severity: Major
Found in index.js - About 6 hrs to fix

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

    // Look up URLs in SURBL
    
    const url       = require('url');
    const dns       = require('dns');
    const net       = require('net');
    Severity: Minor
    Found in index.js - About 4 hrs to fix

      Function lookup_header_zones has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.lookup_header_zones = function (next, connection) {
      
        const email_re = /<?[^@]+@([^> ]+)>?/;
        const plugin = this;
        const trans = connection.transaction;
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function extract_urls has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function extract_urls (urls, body, connection, self) {
          // extract from body.bodytext
          let match;
          if (!body || !body.bodytext) { return; }
        
        
        Severity: Minor
        Found in index.js - About 1 hr 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 extract_urls has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function extract_urls (urls, body, connection, self) {
          // extract from body.bodytext
          let match;
          if (!body || !body.bodytext) { return; }
        
        
        Severity: Minor
        Found in index.js - About 1 hr to fix

          Function lookup_header_zones has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.lookup_header_zones = function (next, connection) {
          
            const email_re = /<?[^@]+@([^> ]+)>?/;
            const plugin = this;
            const trans = connection.transaction;
          Severity: Minor
          Found in index.js - About 1 hr 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

          Avoid deeply nested control flow statements.
          Open

                else if (/^(?:1|true|yes|enabled|on)$/i.test(plugin.cfg[zone].strip_to_domain)) {
                  lookup = (tlds.split_hostname(host, 3))[1];
                }
                // Anything else..
                else {
          Severity: Major
          Found in index.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    if (net_utils.is_private_ip(host)) {
                      results.add(plugin, {skip: 'private IP' });
                      continue;
                    }
            Severity: Major
            Found in index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      if (/^(?:1|true|yes|enabled|on)$/i.test(plugin.cfg[zone].not_ipv6_compatible) || /^(?:1|true|yes|enabled|on)$/i.test(plugin.cfg[zone].no_ip_lookups)) {
                        results.add(plugin, {skip: `IP (${host}) not supported for ${zone}` });
                        continue;
                      }
              Severity: Major
              Found in index.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        else if ( ip_format === 'ip6') {
                          if (arpa.length < 32) continue; // Only full IP addresses
                          host = arpa.join('.');
                        }
                Severity: Major
                Found in index.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (arpa.length < 4) continue; // Only full IP addresses
                  Severity: Major
                  Found in index.js - About 45 mins to fix

                    Function check_excludes_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function check_excludes_list (host) {
                      host = host.split('.').reverse();
                      for (let i=0; i < host.length; i++) {
                        let check;
                        if (i === 0) {
                    Severity: Minor
                    Found in index.js - About 25 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language