Showing 9 of 22 total issues
Function checkModel
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
checkModel(req, res, next) {
const modelName = req.params.model || req.params.parentModel
const user = req.user
const defaultRole = this.app.config.permissions.defaultRole
Function checkRoute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
checkRoute(req, res, next) {
const user = req.user
const defaultRole = this.app.config.permissions.defaultRole
const permissionsConfig = _.get(req.route, 'config.app.permissions')
Function config
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static config(app, Sequelize) {
return {
options: {
classMethods: {
associate: (models) => {
Function loadFixtures
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
loadFixtures: app => {
return Promise.all([
app.services.FootprintService.find('role', {}).then(roles => {
if (!roles || roles.length === 0) {
return lib.Utils.loadRoles(app)
- 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 deeply nested control flow statements. Open
Open
if (action === 'update' || action === 'destroy') {
return next({
message: 'Update and Destroy are not yet supported with permissions, please do your request manually',
statusCode: 400,
code: 'E_UNSUPPORTED'
Avoid deeply nested control flow statements. Open
Open
if (modelName === 'user') {
if (req.params.id === user.id) {
return next()
}
else {
Function checkModel
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
checkModel(req, res, next) {
const modelName = req.params.model || req.params.parentModel
const user = req.user
const defaultRole = this.app.config.permissions.defaultRole
- 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 deeply nested control flow statements. Open
Open
if (modelName === 'user') {
if (req.params.id === user.id) {
return next()
}
else {
Avoid too many return
statements within this function. Open
Open
return next()