Showing 17 of 41 total issues
Function meRouter
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Authenticator.prototype.meRouter = function() {
var meRouter = express.Router();
meRouter.use( function(req, res, next) {
if ( !req.rem.identity ) {
Function REMResource
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var REMResource = function(name, opt, parent) {
this.router = express.Router();
this.name = name;
this.options = new REMOptions(this, opt, parent);
this.permissions = new PermissionsManager(this);
Function handler
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handler = function(req, res) {
if ( !_.isObject( req.body ) ) {
res.status(400).send("Invalid request body.");
}
if ( !req.rem.db.findOne || !req.rem.db.update ) {
Function handler
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handler = function(req, res) {
if ( !_.isObject( req.body ) ) {
res.status(400).send("Invalid request body.");
}
if ( !req.rem.db.findOne || !req.rem.db.update ) {
Function create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
LoginHelper.prototype.create = function( login, password, misc, callback ) {
return this.lookup( { login: login } )
.bind(this)
.then( function() {
throw new LoginAlreadyExistsError();
Function lookup
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
LoginHelper.prototype.lookup = function( candidate, with_sensitive, callback ) {
var query = {};
if ( candidate._id ) {
query._id = candidate._id;
}
Function handler
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handler = function(req, res) {
if ( !_.isObject( req.body ) ) {
res.status(400).send("Invalid request body.");
}
if ( !req.rem.db.insert ) {
Function update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function( login, old_password, new_password, misc, callback ) {
var identity = null;
return this.check( login, old_password )
.bind(this)
Function parse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
JWT.prototype.parse = function( token, callback ) {
return BPromise.try( function() {
return jwt.decode( token, this.secret );
}.bind(this) )
.bind(this)
Function createRouter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
REM.prototype.createRouter = function() {
var router = express.Router();
router.use( function(req, res, next) {
req.rem = {};
Function parse
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
JWT.prototype.parse = function( token, callback ) {
return BPromise.try( function() {
return jwt.decode( token, this.secret );
}.bind(this) )
.bind(this)
- 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 apply
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
PermissionsManager.prototype.apply = function(action, req, res, next) {
var anonymous = !req.rem.identity;
var permissions = ( anonymous )? this.anonymous_permissions : this.defaults;
if ( _.isArray(permissions) && _.contains( permissions, action ) ) {
return next();
- 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 check
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
LoginHelper.prototype.check = function( login, password, callback ) {
var identity = null;
return this.lookup( { login: login }, true )
.bind(this)
.catch( function( err ) {
Function update
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function( login, old_password, new_password, misc, callback ) {
Function _create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
NeDBEngine.prototype._create = function( name, file ) {
if ( !file && this.options.createCollection ) {
return this.options.createCollection( name );
}
else {
- 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 REMResource
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var REMResource = function(name, opt, parent) {
this.router = express.Router();
this.name = name;
this.options = new REMOptions(this, opt, parent);
this.permissions = new PermissionsManager(this);
- 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 LoginHelper
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
var LoginHelper = function(options, resources) {
this.authority = _.clone( options.login_authority || { resource: 'users' } );
if ( !this.authority.resource ) {
throw new Error( "Bad login authority " + JSON.stringify( this.authority ) );
}
- 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"