sant0ro/chocolatey

View on GitHub

Showing 90 of 91 total issues

Avoid using short method names like CreateChocolateyUsersMailRequestsTable::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        Schema::create('chocolatey_users_mail_requests', function (Blueprint $table) {
            $table->increments('id');
            $table->string('token', 255);

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Avoid using short method names like CreateChocolateyUsersPhotosLikesTable::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        Schema::create('chocolatey_users_photos_likes', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('photo_id');

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Avoid using short method names like CreateCacheTable::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        Schema::create('cache', function (Blueprint $table) {
            $table->string('key')->unique();
            $table->text('value');

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Avoid using short method names like CreateChocolateyShopHistoryTable::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        Schema::create('chocolatey_shop_history', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Avoid using short method names like CreateChocolateyShopPaymentCheckoutTable::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        Schema::create('chocolatey_shop_payment_checkout', function (Blueprint $table) {
            $table->increments('id');
            $table->string('category', 50)->default('online');

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Avoid using short method names like UsersMigration::up(). The configured minimum method name length is 3.
Open

    public function up()
    {
        DB::statement('ALTER TABLE users MODIFY mail varchar(255) NOT NULL;');
        DB::statement('ALTER TABLE users MODIFY username varchar(50) NOT NULL;');
    }

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

Source https://phpmd.org/rules/naming.html#shortmethodname

Method store has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function store(string $roomName, string $description, string $model, int $maxUsers, int $roomCategory, int $floorPaper, int $wallPaper, float $landscapePaper, int $ownerId, string $ownerName)
Severity: Major
Found in app/Models/Room.php - About 1 hr to fix

    Method store has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function store(int $userId, int $roomId, int $itemId, int $xPosition, int $yPosition, string $zPosition, int $rotation, string $extraData, string $wallPosition = ''): self
    Severity: Major
    Found in app/Models/RoomItem.php - About 1 hr to fix

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

          protected function createClubRoom(User $user): bool
          {
              $room = (new Room())->store("{$user->name}'s room", "{$user->name} has entered the building", 'model_h', 25, 12, 409, 1902, 0.0, $user->uniqueId, $user->name);
      
              $user->update(['home_room' => $room->id]);
      Severity: Minor
      Found in app/Helpers/Nux.php - About 1 hr to fix

        Method store has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function store(string $title, string $description, string $content, string $author, string $categories, string $imageUrl, string $thumbnailUrl): self
        Severity: Major
        Found in app/Models/Article.php - About 50 mins to fix

          Method store has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function store(int $userId, int $userStaffId, string $banReason, $banType = 'account', $banExpire = 0, $ipAddress = '', $machineId = ''): self
          Severity: Major
          Found in app/Models/Ban.php - About 50 mins to fix

            Avoid variables with short names like $e. Configured minimum length is 3.
            Open

                public function render($request, Exception $e)
            Severity: Minor
            Found in app/Exceptions/Handler.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            Avoid variables with short names like $e. Configured minimum length is 3.
            Open

                public function report(Exception $e)
            Severity: Minor
            Found in app/Exceptions/Handler.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

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

            <?php
            
            namespace App\Models;
            
            /**
            Severity: Minor
            Found in app/Models/PhotoLike.php and 1 other location - About 45 mins to fix
            app/Models/PhotoReportCategory.php on lines 1..49

            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 96.

            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

            <?php
            
            namespace App\Models;
            
            /**
            Severity: Minor
            Found in app/Models/PhotoReportCategory.php and 1 other location - About 45 mins to fix
            app/Models/PhotoLike.php on lines 1..49

            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 96.

            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 success has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function success(Request $request, string $paymentCategory, int $countryCode, int $shopItem, int $paymentMethod)
            Severity: Minor
            Found in app/Http/Controllers/ShopController.php - About 35 mins to fix

              Method store has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function store(string $itemName, string $countryCode, int $creditAmount, int $iconId, array $paymentMethods): self
              Severity: Minor
              Found in app/Models/ShopItem.php - About 35 mins to fix

                Method store has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function store(int $userId, int $firstQuestion, int $secondQuestion, string $firstAnswer, string $secondAnswer): self
                Severity: Minor
                Found in app/Models/UserSecurity.php - About 35 mins to fix

                  Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function get(string $token = '')
                      {
                          if ($this->mailModel == null && !empty($token)) {
                              $mailModel = MailModel::where('token', $token)->where('used', '0')->first();
                  
                  
                  Severity: Minor
                  Found in app/Helpers/Mail.php - About 35 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

                  The method createUser has a boolean flag argument $newUser, which is a certain sign of a Single Responsibility Principle violation.
                  Open

                      public function createUser(Request $request, array $userInfo, bool $newUser = false, bool $sendEmail = false): User

                  BooleanArgumentFlag

                  Since: 1.4.0

                  A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                  Example

                  class Foo {
                      public function bar($flag = true) {
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                  Severity
                  Category
                  Status
                  Source
                  Language