Showing 13 of 47 total issues
Function create
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
walletV2.create = function(attrs) {
return Promise.resolve(attrs)
.then(validate.present("username"))
.then(validate.present("walletId"))
Function update
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
wallets.update = signedJson.action(function(req, res, next) {
var body = req.verified.body;
/*
* This method handles two situations:
*
Function create
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
wallets.create = [rejectSpammedCreates, function(req, res, next) {
var walletToSubmit = _.pick(req.body, [
'id',
'authToken',
'mainData',
Function enable
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
totp.enable = signedJson.action(function(req, res, next) {
var body = req.verified.body;
walletV2.getByWalletId(req.verified.username, req.verified.walletId)
.then(function (wallet) {
Function create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
wallets.create = function(req, res, next) {
var attrs = _.pick(req.body, [
"username",
"walletId",
"salt",
Function create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
wallet.create = function(params) {
return Promise.resolve(params)
.tap(function(p) {
if(p.authToken === "success") {
throw new errors.DuplicateRecord();
Function middleware
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
signedJson.middleware = function(req, res, next) {
var authHeader = req.headers.authorization;
signedJson.parseAuthorizationHeader(authHeader)
.bind({})
Function hash
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
validate.hash = function (prop, options) {
if(!options) {
options = {};
}
Function update
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
wallet.update = function(id, authToken, changes) {
return wallet.get(id).then(function(w) {
// if we couldn't find a wallet, fail
Function replace
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
wallet.replace = function(oldId, oldAuthToken, newId, newAuthToken) {
return Promise.all([
wallet.get(oldId),
wallet.get(newId)
])
- 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
return db('wallets')
.where('id', oldWallet.id)
.del();
Function update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
wallet.update = function(id, authToken, changes) {
return wallet.get(id).then(function(w) {
// if we couldn't find a wallet, fail
- 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 showRecovery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
wallets.showRecovery = [lockoutByIP, function(req, res, next) {
return fail(res, {"code": "maintenance"});
return walletV2.get(req.body.username)
.then(function checkRecoveryId(wallet) {
- 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"