Marre-86/ecommerce

View on GitHub

Showing 13 of 15 total issues

Method run has 218 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run(): void
    {
        Product::truncate();

        Product::create([
Severity: Major
Found in database/seeders/ProductsTableSeeder.php - About 1 day to fix

    Method up has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function up()
        {
            $tableNames = config('permission.table_names');
            $columnNames = config('permission.column_names');
            $teams = config('permission.teams');
    Severity: Major
    Found in database/migrations/2023_05_25_071325_create_permission_tables.php - About 3 hrs to fix

      Function destroy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function destroy(Category $category)
          {
              $category = Category::findOrFail($category->id);
      
              if ($category->products->isNotEmpty()) {
      Severity: Minor
      Found in app/Http/Controllers/CategoryController.php - 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 index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function index(Request $request)
          {
              $filter = $request->query('filter');
      
              if (is_array($filter)) {
      Severity: Minor
      Found in app/Http/Controllers/Api/V1/ProductController.php - 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

      Method run has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function run(): void
          {
              Category::truncate();
      
              Category::create([
      Severity: Minor
      Found in database/seeders/CategoriesTableSeeder.php - About 1 hr to fix

        Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run(): void
            {
                Order::truncate();
        
                Order::create([
        Severity: Minor
        Found in database/seeders/OrdersTableSeeder.php - About 1 hr to fix

          Method index has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function index(Request $request)
              {
                  $filter = $request->query('filter');
          
                  if (is_array($filter)) {
          Severity: Minor
          Found in app/Http/Controllers/Api/V1/ProductController.php - About 1 hr to fix

            Function up has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function up()
                {
                    $tableNames = config('permission.table_names');
                    $columnNames = config('permission.column_names');
                    $teams = config('permission.teams');
            Severity: Minor
            Found in database/migrations/2023_05_25_071325_create_permission_tables.php - About 1 hr 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

            Method update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function update(Request $request, Product $item)
                {
                    $item = Product::findOrFail($item->id);
            
                    $oldName = $item->name;
            Severity: Minor
            Found in app/Http/Controllers/ItemController.php - About 1 hr to fix

              Method store has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function store(Request $request)
                  {
                      $authorizationHeader = $request->header('Authorization');
              
                      \Cart::session(substr($authorizationHeader, 7));
              Severity: Minor
              Found in app/Http/Controllers/Api/V1/OrderController.php - About 1 hr to fix

                Function processFiles has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                function processFiles($folderPath)
                {
                
                    $jsonDataArray = [];
                
                
                Severity: Minor
                Found in app/helpers.php - About 1 hr 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

                Method updateCart has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function updateCart(Request $request)
                    {
                        $authorizationHeader = $request->header('Authorization');
                        \Cart::session(substr($authorizationHeader, 7));
                
                
                Severity: Minor
                Found in app/Http/Controllers/Api/V1/CartController.php - About 1 hr to fix

                  Method destroy has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function destroy(Category $category)
                      {
                          $category = Category::findOrFail($category->id);
                  
                          if ($category->products->isNotEmpty()) {
                  Severity: Minor
                  Found in app/Http/Controllers/CategoryController.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language