Marre-86/ecommerce

View on GitHub

Showing 15 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
                $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
    
                $table->string('model_type');
                $table->unsignedBigInteger($columnNames['model_morph_key']);
    database/migrations/2023_05_25_071325_create_permission_tables.php on lines 77..98

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
                $table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
    
                $table->string('model_type');
                $table->unsignedBigInteger($columnNames['model_morph_key']);
    database/migrations/2023_05_25_071325_create_permission_tables.php on lines 53..75

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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