cattr-app/server-application

View on GitHub

Showing 177 of 177 total issues

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

    private function solve(string $captchaToken = ''): void
    {
        if (!$this->captchaEnabled()) {
            return;
        }
Severity: Minor
Found in app/Helpers/Recaptcha.php - About 1 hr to fix

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

        public function login(LoginRequest $request): JsonResponse
        {
            $credentials = $request->only(['email', 'password', 'recaptcha']);
    
            $this->recaptcha->check($credentials);
    Severity: Minor
    Found in app/Http/Controllers/AuthController.php - About 1 hr to fix

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

          public function handle(): int
          {
              if (!$this->option('force') && !$this->confirm('Are you sure want to drop data for your Cattr instance?')) {
                  return 0;
              }
      Severity: Minor
      Found in app/Console/Commands/ResetCommand.php - About 1 hr to fix

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

                    ProjectReportExport::init(
                        $request->input('users', User::all()->pluck('id')->toArray()),
                        $request->input('projects', Project::all()->pluck('id')->toArray()),
                        Carbon::parse($request->input('start_at'))->setTimezone($companyTimezone),
                        Carbon::parse($request->input('end_at'))->setTimezone($companyTimezone),
        app/Http/Controllers/Api/Reports/ProjectReportController.php on lines 42..48

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

        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

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

                    ProjectReportExport::init(
                        $request->input('users', User::all()->pluck('id')->toArray()),
                        $request->input('projects', Project::all()->pluck('id')->toArray()),
                        Carbon::parse($request->input('start_at'))->setTimezone($companyTimezone),
                        Carbon::parse($request->input('end_at'))->setTimezone($companyTimezone),
        app/Http/Controllers/Api/Reports/ProjectReportController.php on lines 24..30

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

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

            public function _rules(): array
            {
                return [
                    'id' => 'required|int',
                    'full_name' => 'sometimes|required|string',
        Severity: Minor
        Found in app/Http/Requests/User/EditUserRequest.php - About 1 hr to fix

          Function createStatusDialog has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createStatusDialog(type) {
              const statusTitles = {
                  info: '信息',
                  success: '成功',
                  warning: '警告',
          Severity: Minor
          Found in resources/frontend/core/components/global/CustomModal/dialog.js - About 1 hr to fix

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

                final public function hasProjectRole(Role|array $role, int $projectId): bool
                {
                    $self = $this;
                    $roles = Cache::store('octane')->remember(
                        "role_project_$self->id",
            Severity: Minor
            Found in app/Traits/HasRole.php - About 1 hr to fix

              Function defultCallback has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const defultCallback = action => {
                  if (currentModal) {
                      const callback = currentModal.callback;
                      if (typeof callback === 'function') {
                          if (instance.showInput) {
              Severity: Minor
              Found in resources/frontend/core/components/global/CustomModal/dialog.js - About 1 hr to fix

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

                <?php
                
                use Illuminate\Support\Facades\Schema;
                use Illuminate\Database\Schema\Blueprint;
                use Illuminate\Database\Migrations\Migration;
                database/migrations/2018_10_08_072020_add_task_priority.php on lines 1..34

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

                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\Support\Facades\Schema;
                use Illuminate\Database\Schema\Blueprint;
                use Illuminate\Database\Migrations\Migration;
                Severity: Minor
                Found in database/migrations/2018_10_08_072020_add_task_priority.php and 1 other location - About 1 hr to fix
                database/migrations/2018_04_05_093510_add_mouse_and_keyboard_counters_to_time_interval.php on lines 1..34

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

                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

                class MakeDescriptionNullable extends Migration
                {
                    /**
                     * Run the migrations.
                     *
                database/migrations/2022_11_08_163202_make_tracked_app_title_nullable.php on lines 7..32

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

                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

                return new class extends Migration
                {
                    /**
                     * Run the migrations.
                     *
                database/migrations/2019_04_26_084335_make_description_nullable.php on lines 7..32

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

                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 showNextModal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                const showNextModal = () => {
                    initInstance();
                    instance.action = '';
                
                    if (!instance.visible && modalQueue.length) {
                Severity: Minor
                Found in resources/frontend/core/components/global/CustomModal/dialog.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 ru has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    ru: function (choice, choicesLength) {
                        // this === VueI18n instance, so the locale property also exists here
                
                        if (choice === 0) {
                            return 0;
                Severity: Minor
                Found in resources/frontend/core/i18n/pluralizationRules.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 hasProjectRole has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    final public function hasProjectRole(Role|array $role, int $projectId): bool
                    {
                        $self = $this;
                        $roles = Cache::store('octane')->remember(
                            "role_project_$self->id",
                Severity: Minor
                Found in app/Traits/HasRole.php - 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 thin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function thin($force = false): void
                    {
                        if ((!$force && !self::needThinning()) || Cache::store('octane')->get('thinning_now')) {
                            return;
                        }
                Severity: Minor
                Found in app/Helpers/StorageCleaner.php - 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

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

                        {
                            label: 'field.screenshots_interval',
                            key: 'screenshots_interval',
                            render: (h, { currentValue }) => {
                                return h('span', i18n.t('field.minutes', { value: currentValue }));
                Severity: Minor
                Found in resources/frontend/core/modules/Users/sections/users.js and 1 other location - About 55 mins to fix
                resources/frontend/core/modules/Users/sections/users.js on lines 282..288

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

                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

                        {
                            label: 'field.computer_time_popup',
                            key: 'computer_time_popup',
                            render: (h, { currentValue }) => {
                                return h('span', i18n.t('field.minutes', { value: currentValue }));
                Severity: Minor
                Found in resources/frontend/core/modules/Users/sections/users.js and 1 other location - About 55 mins to fix
                resources/frontend/core/modules/Users/sections/users.js on lines 275..281

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

                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
                
                return [
                
                    /*
                Severity: Minor
                Found in resources/lang/en/emails.php and 1 other location - About 55 mins to fix
                resources/lang/ru/emails.php on lines 1..36

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

                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