Function upgrade_connection
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.upgrade_connection = function (next, connection, params) {
if (!connection.tls.advertised) return next();
/* Watch for STARTTLS directive from client. */
if (params[0].toUpperCase() !== 'STARTTLS') return next();
Function emit_upgrade_msg
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
exports.emit_upgrade_msg = function (conn, verified, verifyErr, cert, cipher) {
let msg = 'secured:';
if (cipher) {
msg += ` cipher=${cipher.name} version=${cipher.version}`;
}
- 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 advertise_starttls
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.advertise_starttls = function (next, connection) {
// if no TLS setup incomplete/invalid, don't advertise
if (!tls_socket.tls_valid) {
this.logerror('no valid TLS config');
Function upgrade_connection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
exports.upgrade_connection = function (next, connection, params) {
if (!connection.tls.advertised) return next();
/* Watch for STARTTLS directive from client. */
if (params[0].toUpperCase() !== 'STARTTLS') 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 emit_upgrade_msg
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
exports.emit_upgrade_msg = function (conn, verified, verifyErr, cert, cipher) {
Function advertise_starttls
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.advertise_starttls = function (next, connection) {
// if no TLS setup incomplete/invalid, don't advertise
if (!tls_socket.tls_valid) {
this.logerror('no valid TLS config');
- 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 too many return
statements within this function. Open
return enable_tls();
Avoid too many return
statements within this function. Open
if (connection.local.port === 587) return enable_tls();