File plugins.js
has 488 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict';
// load all defined plugins
// node built-ins
const fs = require('fs');
Function run_next_hook
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
plugins.run_next_hook = (hook, object, params) => {
if (client_disconnected(object) && !is_required_hook(hook)) {
object.logdebug(`aborting ${hook} hook`);
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 run_next_hook
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
plugins.run_next_hook = (hook, object, params) => {
if (client_disconnected(object) && !is_required_hook(hook)) {
object.logdebug(`aborting ${hook} hook`);
return;
}
Function callback
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function callback (retval, msg) {
if (timeout_id) clearTimeout(timeout_id);
object.current_hook = null;
if (cancelled) return; // This hook has been cancelled
Function log_run_item
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function log_run_item (item, hook, retval, object, params, msg) {
if (!item) return;
if (hook === 'log') return;
let log = 'logdebug';
- 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 _compile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_compile () {
const pp = this.plugin_path;
const code = this._get_code(pp);
if (!code) return;
Function load_plugins
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
plugins.load_plugins = override => {
logger.loginfo('Loading plugins');
let plugin_list;
if (override) {
if (!Array.isArray(override)) override = [ override ];
Function run_hooks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
plugins.run_hooks = (hook, object, params) => {
if (client_disconnected(object) && !is_required_hook(hook)) {
object.logdebug(`aborting ${hook} hook`);
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_denyfn
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function get_denyfn (object, hook, params, retval, msg, respond_method) {
Function log_run_item
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function log_run_item (item, hook, retval, object, params, msg) {
Avoid too many return
statements within this function. Open
return plugins.run_next_hook(hook, object, params);
Avoid too many return
statements within this function. Open
return 0;
Avoid too many return
statements within this function. Open
return require(path.join(path.dirname(this.plugin_path), module));
Function _get_code
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_get_code (pp) {
if (this.hasPackageJson) {
let packageDir = path.dirname(pp);
if (/^win(32|64)/.test(process.platform)) {
- 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"