Showing 22 of 22 total issues
Function bounce_spf
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.bounce_spf = function (next, connection) {
if (!this.cfg.check.bounce_spf) return next()
if (!this.has_null_sender(connection)) return next()
const txn = connection?.transaction
File index.js
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
// bounce tests
const tlds = require('haraka-tld')
const { SPF } = require('haraka-plugin-spf')
const net_utils = require('haraka-net-utils')
Function non_local_msgid
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.non_local_msgid = function (next, connection) {
if (!this.cfg.check.non_local_msgid) return next()
if (!this.has_null_sender(connection)) return next()
const transaction = 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!matches.length) {
connection.loginfo(this, 'no Message-ID matches')
transaction.results.add(this, { fail: 'Message-ID' })
if (!this.cfg.reject.non_local_msgid) return next()
return next(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 75.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (domains.length === 0) {
connection.loginfo(this, 'no domain(s) parsed from Message-ID headers')
transaction.results.add(this, { fail: 'Message-ID parseable' })
if (!this.cfg.reject.non_local_msgid) return next()
return next(DENY, `bounce with invalid Message-ID, I didn't send it.`)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 75.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function non_local_msgid
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.non_local_msgid = function (next, connection) {
if (!this.cfg.check.non_local_msgid) return next()
if (!this.has_null_sender(connection)) return next()
const transaction = connection?.transaction
Function bounce_spf
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
exports.bounce_spf = function (next, connection) {
if (!this.cfg.check.bounce_spf) return next()
if (!this.has_null_sender(connection)) return next()
const txn = 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
Function single_recipient
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.single_recipient = function (next, connection) {
if (!this?.cfg?.check?.single_recipient) return next()
if (!this.has_null_sender(connection)) return next()
const { transaction, relaying, remote } = connection
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (let i = 0, l = body.children.length; i < l; i++) {
// Recure to any MIME children
find_message_id_headers(headers, body.children[i], connection, self)
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (let i = 0, l = body.children.length; i < l; i++) {
// Recurse in any MIME children
find_received_headers(ips, body.children[i], connection, self)
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid too many return
statements within this function. Open
if (!this.cfg.reject.non_local_msgid) return next()
Avoid too many return
statements within this function. Open
return next()
Avoid too many return
statements within this function. Open
if (!this.cfg.reject.single_recipient) return next()
Avoid too many return
statements within this function. Open
return next(DENY, 'bounce with non-empty Return-Path (RFC 3834)')
Avoid too many return
statements within this function. Open
if (!this.cfg.reject.non_local_msgid) return next()
Avoid too many return
statements within this function. Open
if (!this.cfg.reject.bounce_spf) return run_cb()
Avoid too many return
statements within this function. Open
return next(DENY, `bounce with invalid Message-ID, I didn't send it.`)
Avoid too many return
statements within this function. Open
return next(
DENY,
`bounce Message-ID without valid domain, I didn't send it.`,
)
Avoid too many return
statements within this function. Open
return next(
DENY,
`bounce without Message-ID in headers, unable to verify that I sent it`,
)
Function single_recipient
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.single_recipient = function (next, connection) {
if (!this?.cfg?.check?.single_recipient) return next()
if (!this.has_null_sender(connection)) return next()
const { transaction, relaying, remote } = connection
- 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"