Showing 7 of 62 total issues
File express.ts
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import bodyParser = require( 'body-parser' );
import chalk from 'chalk';
import express = require( 'express' );
import _ = require( 'lodash' );
Function prepareQueryHandling
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
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(
Function configureList
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function constructor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected constructor( configHash: IConfigurationRaw, middleware: T ){
// Get only models authorized
const allModels = _.keys( Diaspora.models );
const configuredModels = ( () => {
try {
Function constructor
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
Open
protected constructor( configHash: IConfigurationRaw, middleware: T ){
// Get only models authorized
const allModels = _.keys( Diaspora.models );
const configuredModels = ( () => {
try {
- Read upRead up
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
Open
return ExpressApiGenerator.respondError( req, res, error );
Function castToDiasporaApiRequest
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
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 ) ) {
- Read upRead up
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"