NodeBB/NodeBB

View on GitHub
src/plugins/hooks.js

Summary

Maintainability
A
3 hrs
Test Coverage

Function fireStaticHook has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

async function fireStaticHook(hook, hookList, params) {
    if (!Array.isArray(hookList) || !hookList.length) {
        return;
    }
    // don't bubble errors from these hooks, so bad plugins don't stop startup
Severity: Minor
Found in src/plugins/hooks.js - About 1 hr to fix

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 register has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

Hooks.register = function (id, data) {
    if (!data.hook || !data.method) {
        winston.warn(`[plugins/${id}] registerHook called with invalid data.hook/method`, data);
        return;
    }
Severity: Minor
Found in src/plugins/hooks.js - About 55 mins to fix

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 fireResponseHook has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

async function fireResponseHook(hook, hookList, params) {
    if (!Array.isArray(hookList) || !hookList.length) {
        return;
    }
    for (const hookObj of hookList) {
Severity: Minor
Found in src/plugins/hooks.js - About 35 mins to fix

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 fireFilterHook has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
Open

async function fireFilterHook(hook, hookList, params) {
    if (!Array.isArray(hookList) || !hookList.length) {
        return params;
    }

Severity: Minor
Found in src/plugins/hooks.js - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status