Showing 87 of 87 total issues
Function addCart
has 65 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 recover
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function recover(req, res) {
try {
const { errors, isValid } = validateRecoverPhone(req.body);
if (!isValid) {
Function submitCart
has 34 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 createStore
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function createStore(req, res) {
const { businessName } = req.body;
const { sub: sellerId } = req.decodedToken;
try {
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 validateProductInput
has 31 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 { productName, description, price, stock } = data;
productName = productName || '';
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 register
has 29 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 editProduct
has 28 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 editStore
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function editStore(req, res) {
const { sub } = req.decodedToken;
const { businessName } = req.body;
// find seller / store
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 { productName, description, price, stock } = data;
productName = productName || '';
- 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 updatePhone
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updatePhone(req, res) {
const { sub } = req.decodedToken;
const { errors, isValid } = req.body;
if (!isValid) {
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"
Further reading
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 updatePhone
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function updatePhone(req, res) {
const { sub } = req.decodedToken;
const { errors, isValid } = req.body;
if (!isValid) {
- 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 7 (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.businessName = !isEmpty(data.businessName) ? data.businessName : '';
- 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"