NodeBB/NodeBB

View on GitHub
src/api/users.js

Summary

Maintainability
B
6 hrs
Test Coverage

File users.js has 606 lines of code (exceeds 500 allowed). Consider refactoring.
Open

'use strict';

const path = require('path');
const fs = require('fs').promises;

Severity: Major
Found in src/api/users.js - About 4 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (!allowed ||
            ((
                data.searchBy === 'ip' ||
                data.searchBy === 'email' ||
                filters.includes('banned') ||
    Severity: Major
    Found in src/api/users.js - About 40 mins to fix

      Function invite has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

      usersAPI.invite = async (caller, { emails, groupsToJoin, uid }) => {
          if (!emails || !Array.isArray(groupsToJoin)) {
              throw new Error('[[error:invalid-data]]');
          }
      
      
      Severity: Minor
      Found in src/api/users.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 update has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

      usersAPI.update = async function (caller, data) {
          if (!caller.uid) {
              throw new Error('[[error:invalid-uid]]');
          }
      
      
      Severity: Minor
      Found in src/api/users.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