GrafiteInc/Scaffold

View on GitHub

Showing 43 of 43 total issues

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

            Route::prefix('notifications')->group(function () {
                Route::get('/', [NotificationsController::class, 'index'])->name('user.notifications');
                Route::post('{uuid}/read', [NotificationsController::class, 'read'])->name('user.notifications.read');
                Route::delete('{uuid}/delete', [NotificationsController::class, 'delete'])->name('user.notifications.destroy');
                Route::delete('clear', [NotificationsController::class, 'deleteAll'])->name('user.notifications.clear');
Severity: Major
Found in routes/web.php and 1 other location - About 2 hrs to fix
routes/web.php on lines 150..155

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

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

            Route::prefix('billing')->group(function () {
                Route::get('', [BillingController::class, 'index'])->name('user.billing');
                Route::post('subscribe', [BillingController::class, 'subscribe'])->name('user.billing.subscribe');
                Route::get('subscribe/success', [BillingController::class, 'success'])->name('user.billing.subscribe.success');
                Route::get('subscribe/cancelled', [BillingController::class, 'cancelled'])->name('user.billing.subscribe.cancelled');
Severity: Major
Found in routes/web.php and 1 other location - About 2 hrs to fix
routes/web.php on lines 137..142

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

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

Function ajax has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.ajax = (_event) => {
    let _originalContent = null;
    _event.preventDefault();

    let _form = _event.target.closest('form');
Severity: Major
Found in resources/js/script-components/ajax-forms.js - About 2 hrs to fix

    Function jsonToTable has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function jsonToTable($data)
        {
            $table = '<table class="table table-responsive table-borderless">';
    
            foreach ($data as $key => $value) {
    Severity: Minor
    Found in app/Models/Activity.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

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

        public function collectData()
        {
            $registrations = User::where('created_at', '<', now())
                ->where('created_at', '>', now()->subDays(30))
                ->get()
    Severity: Major
    Found in app/View/Charts/RegistrationThirtyDays.php and 1 other location - About 2 hrs to fix
    app/View/Charts/ActivityThirtyDays.php on lines 25..44

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

    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

        public function collectData()
        {
            $activities = Activity::where('created_at', '<', now())
                ->where('created_at', '>', now()->subDays(30))
                ->get()
    Severity: Major
    Found in app/View/Charts/ActivityThirtyDays.php and 1 other location - About 2 hrs to fix
    app/View/Charts/RegistrationThirtyDays.php on lines 16..35

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

    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 js has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function js()
        {
            return <<<'JS'
                    let _this = this;
    
    
    Severity: Minor
    Found in app/View/Components/Global/Notifications.php - About 1 hr to fix

      Method boot has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function boot()
          {
              // Gateway for determining if user is admin
              Gate::define('admin', function ($user) {
                  return $user->hasRole('admin');
      Severity: Minor
      Found in app/Providers/AuthServiceProvider.php - About 1 hr to fix

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

        window.Livewire.on('refresh', () => {
            setTimeout(() => {
                window.FormsJS();
                window.turnOnTooltips();
                window.turnOnPopovers();
        Severity: Major
        Found in resources/js/script-components/livewire-events.js and 1 other location - About 1 hr to fix
        resources/js/script-components/livewire-events.js on lines 1..7

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

        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

        window.Livewire.on('loadMore', () => {
            setTimeout(() => {
                window.FormsJS();
                window.turnOnTooltips();
                window.turnOnPopovers();
        Severity: Major
        Found in resources/js/script-components/livewire-events.js and 1 other location - About 1 hr to fix
        resources/js/script-components/livewire-events.js on lines 9..15

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

        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

                    Route::prefix('invites')->group(function () {
                        Route::get('/', [InvitesController::class, 'index'])->name('user.invites');
                        Route::post('{invite}/accept', [InvitesController::class, 'accept'])->name('user.invites.accept');
                        Route::post('{invite}/reject', [InvitesController::class, 'reject'])->name('user.invites.reject');
                    });
        Severity: Major
        Found in routes/web.php and 1 other location - About 1 hr to fix
        routes/api.php on lines 21..25

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

        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

            Route::prefix('users')->group(function () {
                Route::get('me', [UsersController::class, 'me'])->name('.users.me');
                Route::put('update', [UsersController::class, 'update'])->name('.users.update');
                Route::delete('destroy', [UsersController::class, 'destroy'])->name('.users.destroy');
            });
        Severity: Major
        Found in routes/api.php and 1 other location - About 1 hr to fix
        routes/web.php on lines 144..148

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

        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 create has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create($model, $email, $message)
            {
                $user = User::where('email', $email)->first();
                $token = Str::uuid();
                $from = auth()->user();
        Severity: Minor
        Found in app/Services/InviteService.php - About 1 hr to fix

          Method js has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function js()
              {
                  return <<<'JS'
                      document.getElementById('confirmationModalConfirmButton').addEventListener('click', function (event) {
                          window.submitConfirmationForm(event);
          Severity: Minor
          Found in app/View/Components/Global/ConfirmationModal.php - About 1 hr to fix

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

                public static function handle($request)
                {
                    if ($request->two_factor_platform !== $request->user()->two_factor_platform) {
                        $request->user()->update([
                            'two_factor_code' => null,
            Severity: Minor
            Found in app/Actions/ProcessUserTwoFactorSettings.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 handle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function handle($request)
                {
                    if ($request->two_factor_platform !== $request->user()->two_factor_platform) {
                        $request->user()->update([
                            'two_factor_code' => null,
            Severity: Minor
            Found in app/Actions/ProcessUserTwoFactorSettings.php - About 1 hr to fix

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

                  protected function schedule(Schedule $schedule)
                  {
                      $schedule->command('mission-control:report')->everyFiveMinutes()
                          ->runInBackground()
                          ->appendOutputTo(storage_path('logs/scheduler.log'));
              Severity: Minor
              Found in app/Console/Kernel.php - About 1 hr to fix

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

                    public function jsonToTable($data)
                    {
                        $table = '<table class="table table-responsive table-borderless">';
                
                        foreach ($data as $key => $value) {
                Severity: Minor
                Found in app/Models/Activity.php - About 1 hr to fix

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

                  <?php
                  
                  use Illuminate\Database\Migrations\Migration;
                  use Illuminate\Database\Schema\Blueprint;
                  use Illuminate\Support\Facades\Schema;
                  database/migrations/2023_04_29_035625_add_recovery_codes_to_users.php on lines 1..28

                  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
                  
                  use Illuminate\Database\Migrations\Migration;
                  use Illuminate\Database\Schema\Blueprint;
                  use Illuminate\Support\Facades\Schema;
                  database/migrations/2023_04_29_023537_add_two_factor_confirmed_at_to_users.php on lines 1..28

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language