Showing 56 of 60 total issues
Function handle_buf
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
handle_buf(buf) {
const self = this
// Abort any further processing if the headers
// did not contain any DKIM-Signature fields.
if (this._in_body && this._no_signatures_found) {
- 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 dkim.js
has 635 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
const crypto = require('crypto')
const dns = require('dns')
const { Stream } = require('stream')
Function constructor
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
constructor(header, header_idx, cb, opts) {
this.cb = cb
this.sig = header
this.sig_md5 = md5(header)
this.run_cb = false
- 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 end
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
end() {
if (this.run_cb) return
const bh = this.bh.digest('base64')
this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`)
Function handle_buf
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
handle_buf(buf) {
const self = this
// Abort any further processing if the headers
// did not contain any DKIM-Signature fields.
if (this._in_body && this._no_signatures_found) {
Function constructor
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(header, header_idx, cb, opts) {
this.cb = cb
this.sig = header
this.sig_md5 = md5(header)
this.run_cb = false
Function end
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
end() {
if (this.run_cb) return
const bh = this.bh.digest('base64')
this.debug(`${this.identity}: bodyhash=${this.fields.bh} computed=${bh}`)
- 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 275 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
const fs = require('fs')
const path = require('path')
Function write
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
write(buf) {
/*
** BODY (simple canonicalization)
*/
- 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 dkim_verify
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.dkim_verify = function (next, connection) {
if (!this.cfg.verify.enabled) return next()
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 get_sender_domain
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
exports.get_sender_domain = function (connection) {
const txn = connection?.transaction
if (!txn) return
// fallback: use Envelope FROM when header parsing fails
- 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 get_sign_properties
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_sign_properties = function (connection, done) {
if (!connection.transaction) return
const domain = this.get_sender_domain(connection)
Function get_sender_domain
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_sender_domain = function (connection) {
const txn = connection?.transaction
if (!txn) return
// fallback: use Envelope FROM when header parsing fails
Function dkim_verify
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.dkim_verify = function (next, connection) {
if (!this.cfg.verify.enabled) return next()
const txn = connection?.transaction
if (!txn) return next()
Function canonicalize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static canonicalize(bufin) {
const tmp = []
const len = bufin.length
let last_chunk_idx = 0
let idx_wsp = 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"
Further reading
Function write
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
write(buf) {
/*
** BODY (simple canonicalization)
*/
Function end
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
end(buf) {
this.writable = false
// Add trailing CRLF if we have data left over
if (this.buffer.ar.length) {
Function callback
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function callback(err, result) {
self.pending--
if (result) {
const results = {
identity: result.identity,
Function verifier
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
(err, result, results) => {
if (err) {
txn.results.add(this, { err })
return next()
}
Function canonicalize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static canonicalize(bufin) {
const tmp = []
const len = bufin.length
let last_chunk_idx = 0
let idx_wsp = 0