Showing 79 of 79 total issues
Function addCart
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function addCart (req, res) {
const { errors, isValid } = validateCartInput(req.body)
const { errorEmail, isValidEmail } = validateEmail(req.body)
if (!isValid) {
return res.status(400).json(errors)
Function getSalesHistory
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getSalesHistory (req, res) {
try {
const seller = req.decodedToken.sub
const store = await Store.findOne({ seller })
Function authenticate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
OAuth2Strategy.prototype.authenticate = function (req, options) {
options = options || {}
var self = this
if (req.query && req.query.error) {
- 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 authenticate
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
OAuth2Strategy.prototype.authenticate = function (req, options) {
options = options || {}
var self = this
if (req.query && req.query.error) {
Function getCart
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getCart (req, res) {
try {
const cartId = req.params.cart_id
const cart = await Cart.findById({ _id: cartId })
if (!cart) {
Function editStore
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function editStore (req, res) {
const { sub } = req.decodedToken
const { errors, isValid } = validateEditInput(req.body)
const { ownerName, currency, imageUrl, storeName, address } = req.body
Function recover
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function recover (req, res) {
try {
const { errors, isValid } = validateRecoverPhone(req.body)
if (!isValid) {
Consider simplifying this complex logical expression. Open
if (req.query && req.query.code) {
var code = req.query.code
// NOTE: The module oauth (0.9.5), which is a dependency, automatically adds
// a 'type=web_server' parameter to the percent-encoded data sent in
Function createStore
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createStore (req, res) {
const { storeName } = req.body
const { sub: sellerId } = req.decodedToken
const { errors, isValid } = validateCreateStoreInput(req.body)
Function updatePhone
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updatePhone (req, res) {
const { sub } = req.decodedToken
const { errors, isValid } = validatePhone(req.body)
if (!isValid) {
Function resetPassword
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function resetPassword (req, res) {
try {
const { errors, isValid } = validatePasswordResetInput(req.body)
if (!isValid) {
return res.status(400).json(errors)
Function submitCart
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function submitCart (req, res) {
const { errors, isValid } = validateCartInput(req.body)
if (!isValid) {
return res.status(400).json(errors)
}
Function validateProductInput
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateProductInput (data) {
const errors = {}
// Convert empty fields to an empty string so we can use validator functions
let { name, description, price, stock } = data
name = name || ''
Function register
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function register (req, res) {
const { errors, isValid } = validateRegisterInput(req.body)
if (!isValid) {
return res.status(400).json(errors)
}
Function validateProductInput
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function validateProductInput (data) {
const errors = {}
// Convert empty fields to an empty string so we can use validator functions
let { name, description, price, stock } = data
name = name || ''
- 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 editProduct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function editProduct (req, res) {
const { errors, isValid } = validateProductData(req.body)
const productId = req.params.product_id
if (!isValid) {
Function validateCartInput
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateCartInput (data) {
const errors = {}
// Convert empty fields to an empty string so we can use validator functions
let { agreedPrice, total } = data
- 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 validateCreateStoreInput
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateCreateStoreInput (data) {
const errors = {}
// Convert empty fields to an empty string so we can use validator functions
data.ownerName = !isEmpty(data.ownerName) ? data.ownerName : ''
data.currency = !isEmpty(data.currency) ? data.currency : ''
- 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 validateEditInput
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateEditInput (data) {
const errors = {}
// Convert empty fields to an empty string so we can use validator functions
data.ownerName = !isEmpty(data.ownerName) ? data.ownerName : ''
- 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 getOneStore
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function getOneStore (req, res) {
try {
let seller = ''
const sellerId = req.decodedToken ? req.decodedToken.sub : null
const store_id = req.params.store_id ? req.params.store_id : null
- 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"