Showing 51 of 68 total issues
Function check_host
has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring. Open
async check_host(ip, domain, mail_from) {
domain = domain.toLowerCase()
mail_from = mail_from ? mail_from.toLowerCase() : `postmaster@${domain}`
this.ipaddr = ipaddr.parse(ip)
this.ip_ver = this.ipaddr.kind()
- 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
File spf.js
has 562 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
// spf
const dns = require('node:dns/promises')
const net = require('node:net')
Function mech_mx
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
async mech_mx(qualifier, args) {
this.count++
// Parse any arguments
let cm
let cidr4
- 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 expand_macros
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
expand_macros(str) {
const macro = /%{([slodipvh])((?:(?:\d+)?r?)?)?([-.+,/_=])?}/gi
let match
while ((match = macro.exec(str))) {
// match[1] = macro-letter
- 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 check_host
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
async check_host(ip, domain, mail_from) {
domain = domain.toLowerCase()
mail_from = mail_from ? mail_from.toLowerCase() : `postmaster@${domain}`
this.ipaddr = ipaddr.parse(ip)
this.ip_ver = this.ipaddr.kind()
Function hook_mail
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
exports.hook_mail = async function (next, connection, params) {
const plugin = this
const txn = connection?.transaction
if (!txn) return next()
- 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 hook_mail
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_mail = async function (next, connection, params) {
const plugin = this
const txn = connection?.transaction
if (!txn) return next()
Function mech_mx
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
async mech_mx(qualifier, args) {
this.count++
// Parse any arguments
let cm
let cidr4
Function return_results
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
exports.return_results = function (
next,
connection,
spf,
scope,
- 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
File index.js
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
// spf
const SPF = require('./lib/spf').SPF
const net_utils = require('haraka-net-utils')
const DSN = require('haraka-dsn')
Function mech_a
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
async mech_a(qualifier, args) {
this.count++
// Parse any arguments
let cm
let cidr4
- 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 mech_ptr
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
async mech_ptr(qualifier, args) {
this.count++
let dm
let domain = this.domain
if (args && (dm = /^:([^/ ]+)/.exec(args))) {
- 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 mech_a
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
async mech_a(qualifier, args) {
this.count++
// Parse any arguments
let cm
let cidr4
Function load_spf_ini
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.load_spf_ini = function () {
this.nu = net_utils // so tests can set public_ip
this.SPF = SPF
this.cfg = this.config.get(
Function expand_macros
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
expand_macros(str) {
const macro = /%{([slodipvh])((?:(?:\d+)?r?)?)?([-.+,/_=])?}/gi
let match
while ((match = macro.exec(str))) {
// match[1] = macro-letter
Function mech_ptr
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
async mech_ptr(qualifier, args) {
this.count++
let dm
let domain = this.domain
if (args && (dm = /^:([^/ ]+)/.exec(args))) {
Function helo_spf
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.helo_spf = async function (next, connection, helo) {
const plugin = this
// bypass auth'ed or relay'ing hosts if told to
const skip_reason = this.skip_hosts(connection)
Function return_results
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.return_results = function (
next,
connection,
spf,
scope,
Function ch_cb
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ch_cb(err, result, ip) {
if (timer) clearTimeout(timer)
if (timeout) return
if (err) {
connection.logerror(plugin, err)
Function load_spf_ini
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
exports.load_spf_ini = function () {
this.nu = net_utils // so tests can set public_ip
this.SPF = SPF
this.cfg = this.config.get(
- 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"