x249/node-api

View on GitHub

Showing 6 of 6 total issues

Function newUserCheck has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export const newUserCheck: RouteHandlerFunc = (
    req: Request,
    res: Response,
    next: NextFunction,
) => {
Severity: Minor
Found in lib/middleware/checks/users.ts - 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 authenticateUser has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const authenticateUser: AuthenticateUserType = async (
    params: AuthUserParams,
) => {
    try {
        const user: DBUserInterface | null = await User.findOne({
Severity: Minor
Found in lib/controllers/users/index.ts - About 1 hr to fix

    Function handleHelmet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const handleHelmet: RouterMiddleware = (router: Router) => {
        const maxAge = 30;
        router.use(helmet()); // sane defaults
        router.use(
            helmet.permittedCrossDomainPolicies({
    Severity: Minor
    Found in lib/middleware/common.ts - About 1 hr to fix

      Function newUser has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const newUser: NewUserType = async (params: NewUserParams) => {
          const usernameTaken = await User.findOne({
              username: params.username,
          })
              .lean()
      Severity: Minor
      Found in lib/controllers/users/index.ts - About 1 hr to fix

        Function authenticateUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const authenticateUser: AuthenticateUserType = async (
            params: AuthUserParams,
        ) => {
            try {
                const user: DBUserInterface | null = await User.findOne({
        Severity: Minor
        Found in lib/controllers/users/index.ts - 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

        Function authUserCheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const authUserCheck: RouteHandlerFunc = (
            req: Request,
            res: Response,
            next: NextFunction,
        ) => {
        Severity: Minor
        Found in lib/middleware/checks/users.ts - 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

        Severity
        Category
        Status
        Source
        Language