Showing 5 of 5 total issues
Function registerService
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
registerService(service:any){
if(typeof service === 'function'){
throw new TypeError('A type is not allowed - only an object can be registered');
}
- Create a ticketCreate a ticket
Function collectAndConvertArgs
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
collectAndConvertArgs(req:express.Request, res: express.Response, next:express.NextFunction, service:Object, method:MethodDescription): any[]{
const args = [];
args.length = method.pathParams.length + method.headerParams.length + method.queryParams.length + method.contextParams.length;
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
Open
if(!allowed){
res.status(403).send('permission denied');
return;
}
- Create a ticketCreate a ticket
Function render
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
render(res: express.Response, value:any){
if ( typeof value === 'undefined' || value === null) {
if(this.isResponseParameterPresent()){
// do not send any reponse values if a HttpReponse Context param is provided to the service method.
return;
- Read upRead up
- Create a ticketCreate a ticket
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 convertRawParamToMethodParam
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
convertRawParamToMethodParam(service, method, pathParam, rawParam){
// try to figure out what the method signature expects
let paramTypes = Reflect.getMetadata('design:paramtypes', service, method.methodName);
if(paramTypes && paramTypes.length >= pathParam.index){
// this is a constructor function of the expected type
- Read upRead up
- Create a ticketCreate a ticket
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"