Showing 17 of 20 total issues
File index.js
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// node built-ins
const http = require('http');
Function get_options
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
exports.get_options = function (connection) {
// https://rspamd.com/doc/architecture/protocol.html
// https://github.com/vstakhov/rspamd/blob/master/rules/http_headers.lua
const options = {
- 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_milter_headers
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.do_milter_headers = function (connection, data) {
if (!this.cfg.rmilter_headers.enabled) return;
if (!data.milter) 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 get_options
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_options = function (connection) {
// https://rspamd.com/doc/architecture/protocol.html
// https://github.com/vstakhov/rspamd/blob/master/rules/http_headers.lua
const options = {
Function hook_data_post
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.hook_data_post = function (next, connection) {
const plugin = this;
if (!connection.transaction) return next();
if (!plugin.should_check(connection)) return next();
Function add_headers
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
exports.add_headers = function (connection, data) {
const cfg = this.cfg;
if (!this.wants_headers_added(data)) 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 load_rspamd_ini
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.load_rspamd_ini = function () {
const plugin = this;
plugin.cfg = plugin.config.get('rspamd.ini', {
booleans: [
Function get_clean
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_clean = function (data, connection) {
const clean = { symbols: {} };
if (data.symbols) {
Object.keys(data.symbols).forEach(key => {
Function do_milter_headers
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.do_milter_headers = function (connection, data) {
if (!this.cfg.rmilter_headers.enabled) return;
if (!data.milter) return;
Function add_headers
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.add_headers = function (connection, data) {
const cfg = this.cfg;
if (!this.wants_headers_added(data)) return;
Function get_clean
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
exports.get_clean = function (data, connection) {
const clean = { symbols: {} };
if (data.symbols) {
Object.keys(data.symbols).forEach(key => {
- 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 req
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const req = http.request(plugin.get_options(connection), (res) => {
let rawData = '';
res.on('data', (chunk) => { rawData += chunk; });
Function load_rspamd_ini
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
exports.load_rspamd_ini = function () {
const plugin = this;
plugin.cfg = plugin.config.get('rspamd.ini', {
booleans: [
- 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 should_check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
exports.should_check = function (connection) {
let result = true; // default
if (this.cfg.check.authenticated == false && connection.notes.auth_user) {
- 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 wants_reject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
exports.wants_reject = function (connection, data) {
if (data.action !== 'reject') return false;
if (connection.notes.auth_user) {
- 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 {
data,
'log' : this.get_clean(data, connection),
};
Function hook_data_post
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
exports.hook_data_post = function (next, connection) {
const plugin = this;
if (!connection.transaction) return next();
if (!plugin.should_check(connection)) 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"