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;
- Read upRead up
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;
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');
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;
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; }
- Read upRead up
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; }
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;
- Read upRead up
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 {
Avoid deeply nested control flow statements. Open
if (net_utils.is_private_ip(host)) {
results.add(plugin, {skip: 'private IP' });
continue;
}
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;
}
Avoid deeply nested control flow statements. Open
else if ( ip_format === 'ip6') {
if (arpa.length < 32) continue; // Only full IP addresses
host = arpa.join('.');
}
Avoid deeply nested control flow statements. Open
if (arpa.length < 4) continue; // Only full IP addresses
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) {
- Read upRead up
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"