SockDrawer/SockBot

View on GitHub
providers/nodebb/notification.js

Summary

Maintainability
C
1 day
Test Coverage

Function bindNotification has 172 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.bindNotification = function bindNotification(forum) {

    const mentionTester = new RegExp(`(^|\\s)@${forum.username}(\\s|$)`, 'i');

    /**
Severity: Major
Found in providers/nodebb/notification.js - About 6 hrs to fix

Function bindNotification has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

exports.bindNotification = function bindNotification(forum) {

    const mentionTester = new RegExp(`(^|\\s)@${forum.username}(\\s|$)`, 'i');

    /**
Severity: Minor
Found in providers/nodebb/notification.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 notifyHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function notifyHandler(data) {
        const notification = Notification.parse(data);
        return evalBlacklist(notification)
            .then(() => {
                forum.emit('log', `Notification ${notification.id}: ${notification.label} received`);
Severity: Minor
Found in providers/nodebb/notification.js - About 1 hr to fix

Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        constructor(payload) {
            payload = utils.parseJSON(payload);
            const body = string(payload.bodyLong || '').unescapeHTML().s;
            let type = 'notification';
            if (/^\[\[\w+:user_posted_to/i.test(payload.bodyShort)) {
Severity: Minor
Found in providers/nodebb/notification.js - About 1 hr to fix

There are no issues that match your filters.

Category
Status