diaspora-orm/plugin-server

View on GitHub

Showing 7 of 62 total issues

File express.ts has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import bodyParser = require( 'body-parser' );
import chalk from 'chalk';
import express = require( 'express' );
import _ = require( 'lodash' );

Severity: Minor
Found in src/webservers/express.ts - About 4 hrs to fix

    Function prepareQueryHandling has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected prepareQueryHandling( apiNumber: EQueryPlurality ): IHookFunction<express.Request>{
            return async ( req, res, next, model ) => {
                const queryId = generateUUID();
                Diaspora.logger.verbose(
                    `Received ${chalk.bold.red( req.method )} request ${chalk.bold.yellow(
    Severity: Minor
    Found in src/webservers/express.ts - About 1 hr to fix

      Function configureList has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const configureList = <T extends object>( pickers: { [key: string]: T | boolean }, set: string[] ) => {
          const configurationObject: { [key: string]: T | undefined | boolean } = {};
      
          forEach( pickers, ( picker, key ) => {
              // If the key is a regex or a minimatch (check for `*`), this var will be set to a function
      Severity: Minor
      Found in src/utils.ts - About 1 hr to fix

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

            protected constructor( configHash: IConfigurationRaw, middleware: T ){
                // Get only models authorized
                const allModels = _.keys( Diaspora.models );
                const configuredModels = ( () => {
                    try {
        Severity: Minor
        Found in src/apiGenerator.ts - About 1 hr to fix

          Function constructor has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
          Open

              protected constructor( configHash: IConfigurationRaw, middleware: T ){
                  // Get only models authorized
                  const allModels = _.keys( Diaspora.models );
                  const configuredModels = ( () => {
                      try {
          Severity: Minor
          Found in src/apiGenerator.ts - About 45 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

          Avoid too many return statements within this function.
          Open

                          return ExpressApiGenerator.respondError( req, res, error );
          Severity: Major
          Found in src/webservers/express.ts - About 30 mins to fix

            Function castToDiasporaApiRequest has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                protected static async castToDiasporaApiRequest ( request: express.Request, diasporaApi: IDiasporaApiRequestDescriptorPreParse ): Promise<IDiasporaApiRequestDescriptor>{
                    const diasporaApiWithParsedQuery = _.assign( diasporaApi, ExpressApiGenerator.parseQuery( request.query ) );
                    if ( EQueryPlurality.SINGULAR === diasporaApiWithParsedQuery.number ) {
                        const id = _.get( request, 'params[1]' );
                        if ( !_.isNil( id ) ) {
            Severity: Minor
            Found in src/webservers/express.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