marusoft/Auto-Mart

View on GitHub

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;
Severity: Major
Found in server/controllers/carControllers.js - About 4 hrs to fix

    Function validateCarsDetails has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static validateCarsDetails(req, res, next) {
        let {
          state,
          status,
          price,
    Severity: Major
    Found in server/middlewares/carsValidation.js - About 4 hrs to fix

      Function validateCarsDetails has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        static validateCarsDetails(req, res, next) {
          let {
            state,
            status,
            price,
      Severity: Minor
      Found in server/middlewares/carsValidation.js - About 3 hrs to fix

      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;
      Severity: Minor
      Found in server/controllers/carControllers.js - About 2 hrs to fix

      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,
      Severity: Major
      Found in server/controllers/orderControllers.js - About 2 hrs to fix

        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 *`;
        Severity: Minor
        Found in server/controllers/carControllers.js - About 1 hr to fix

          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);
          
          
          Severity: Minor
          Found in server/controllers/orderControllers.js - About 1 hr to fix

            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 {
            Severity: Minor
            Found in server/controllers/carControllers.js - About 1 hr to fix

              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;
              
              
              Severity: Minor
              Found in server/middlewares/usersValidator.js - About 1 hr to fix

                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';
                Severity: Minor
                Found in server/controllers/carControllers.js - About 1 hr to fix

                  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',
                  Severity: Minor
                  Found in server/middlewares/usersValidator.js - About 1 hr to fix

                    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';
                    Severity: Minor
                    Found in server/controllers/flagController.js - About 1 hr to fix

                      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;
                      
                      
                      
                      Severity: Minor
                      Found in server/middlewares/flagValidation.js - About 1 hr to fix

                        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;
                        Severity: Minor
                        Found in server/middlewares/authUser.js - About 1 hr to fix

                          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,
                          Severity: Minor
                          Found in server/controllers/orderControllers.js - About 55 mins to fix

                          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;
                          
                          
                          
                          Severity: Minor
                          Found in server/middlewares/flagValidation.js - About 45 mins to fix

                          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';
                          Severity: Minor
                          Found in server/controllers/carControllers.js - About 25 mins to fix

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language