Showing 28 of 79 total issues
File SwaggerService.js
has 1298 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @Author: Matteo Zambon <Matteo>
* @Date: 2017-04-13 06:55:18
* @Last modified by: Matteo
* @Last modified time: 2017-07-30 01:06:47
Function getPathModelByIdAndRelation
has 146 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPathModelByIdAndRelation(paths, config, doc, modelName, modelRelation) {
const pathItem = {}
const pathId = standardBasePath +
'/' +
modelName.toLowerCase() +
Function getBasePath
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
getBasePath(config) {
if (config.swagger.basePath) {
return config.swagger.basePath
}
else if (config.footprints && config.footprints.prefix) {
- 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
exports
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
module.exports = class SwaggerService extends Service {
// Example
extractExampleDirective (propertyExample) {
Function getPathModelByIdAndRelationById
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPathModelByIdAndRelationById(paths, config, doc, modelName, modelRelation) {
const pathItem = {}
const pathId = standardBasePath +
'/' +
modelName.toLowerCase() +
Function genPropertyExample
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
genPropertyExample (propertyExample, modelExample, withRel) {
let example = null
if (typeof propertyExample === 'string') {
const directive = this.extractExampleDirective(propertyExample)
- 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
Function getResponses
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
getResponses(config, doc) {
const responses = {}
responses['x-GenericSuccess'] = {
description: 'Generic Successful Response',
Function getPathModel
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPathModel(paths, config, doc, modelName) {
const pathItem = {}
const pathId = standardBasePath + '/' + modelName.toLowerCase()
pathItem.get = {}
Function getDefinitionModel
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
getDefinitionModel(config, doc, models, modelName) {
modelRelations[modelName] = []
modelPopulates[modelName] = []
// Get Models
Function getPathModelById
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPathModelById(paths, config, doc, modelName) {
const pathItem = {}
const pathId = standardBasePath + '/' + modelName.toLowerCase() + '/{id}'
pathItem.get = {}
Function getDefinitionModel
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
getDefinitionModel(config, doc, models, modelName) {
modelRelations[modelName] = []
modelPopulates[modelName] = []
// Get Models
- 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
Function genResponseObject
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
genResponseObject(httpCode, responseName, description) {
const responseObject = {}
switch (httpCode) {
case '200':
Function getDefinitions
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
getDefinitions(config, doc) {
const definitions = {}
definitions['x-any'] = {
'properties': {}
Function parseDefinitionModelProperty
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseDefinitionModelProperty(property) {
property.type = property.type.toLowerCase()
if (property.type === 'integer') {
property.type = 'integer'
Function genPropertyExample
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
genPropertyExample (propertyExample, modelExample, withRel) {
let example = null
if (typeof propertyExample === 'string') {
const directive = this.extractExampleDirective(propertyExample)
Function getBasePath
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
getBasePath(config) {
if (config.swagger.basePath) {
return config.swagger.basePath
}
else if (config.footprints && config.footprints.prefix) {
Function parseDefinitionModelProperty
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
parseDefinitionModelProperty(property) {
property.type = property.type.toLowerCase()
if (property.type === 'integer') {
property.type = 'integer'
- 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
Function getModelCriteria
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
getModelCriteria(config, doc, modelName, keepId) {
const definition = doc.definitions[modelName]
const criterias = []
Function getPathLocalRegister
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPathLocalRegister(paths, config) {
const pathItem = {}
const localStrategy = config.passport.strategies.local
let usernameField = 'username'
Function getModelCriteria
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getModelCriteria(config, doc, modelName, keepId) {
const definition = doc.definitions[modelName]
const criterias = []
- 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"