Showing 17 of 17 total issues
Function ViewAllUnsoldCars
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async ViewAllUnsoldCars(req, res, next) {
const {
status, state, manufacturer, body_type,
} = req.query;
Function validateCarsDetails
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
static validateCarsDetails(req, res, next) {
let {
state,
status,
price,
Function validateCarsDetails
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
static validateCarsDetails(req, res, next) {
let {
state,
status,
price,
- 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 ViewAllUnsoldCars
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
static async ViewAllUnsoldCars(req, res, next) {
const {
status, state, manufacturer, body_type,
} = req.query;
- 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 updatePurchaseOrderPrice
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async updatePurchaseOrderPrice(req, res) {
const { price } = req.body;
if (!price || !/^\d+$/.test(price)) {
return res.status(400).json({
status: 400,
Function createCarSaleAD
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async createCarSaleAD(req, res) {
const { id } = req.user;
const sql = `INSERT INTO cars(owner, state, price, manufacturer, model, body_type, img_url)
VALUES($1, $2, $3, $4, $5, $6, $7) RETURNING *`;
Function CreateAPurchaseOrder
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async CreateAPurchaseOrder(req, res) {
const userid = req.user.id;
// const { car_id } = req.body;
const value = Number(req.body.car_id);
Function ViewASpecificCar
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async ViewASpecificCar(req, res) {
const { id } = req.params;
const findOneCarSql = 'SELECT * FROM cars WHERE id = $1';
const value = Number(id);
try {
Function ValidateUserSignUpInput
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async ValidateUserSignUpInput(req, res, next) {
let {
email, first_name, last_name, password, address,
} = req.body;
Function updateCarPrice
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async updateCarPrice(req, res) {
const { id } = req.params;
const val = Number(id);
const { price } = req.body;
const findACar = 'SELECT * FROM cars WHERE id = $1';
Function ValidateUserSignInInput
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async ValidateUserSignInInput(req, res, next) {
let { email, password } = req.body;
const constraint = {
email: 'required|email',
password: 'required',
Function flagPostedAdAsFraud
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async flagPostedAdAsFraud(req, res) {
const { car_id, reason, description } = req.body;
const value = Number(car_id);
const findCarToReport = 'SELECT * FROM cars WHERE id = $1';
Function validateFlagDetails
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static validateFlagDetails(req, res, next) {
// eslint-disable-next-line prefer-const
let { reason, description } = req.body;
Function verifyAdmin
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static verifyAdmin(req, res, next) {
const payload = UserAuthentication.verifyAuthHeader(req);
let error;
let status;
Function updatePurchaseOrderPrice
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async updatePurchaseOrderPrice(req, res) {
const { price } = req.body;
if (!price || !/^\d+$/.test(price)) {
return res.status(400).json({
status: 400,
- 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 validateFlagDetails
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static validateFlagDetails(req, res, next) {
// eslint-disable-next-line prefer-const
let { reason, description } = req.body;
- 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 updateCarPrice
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async updateCarPrice(req, res) {
const { id } = req.params;
const val = Number(id);
const { price } = req.body;
const findACar = 'SELECT * FROM cars WHERE id = $1';
- 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"