visavi/rotor

View on GitHub

Showing 512 of 512 total issues

Function delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete(Request $request, Validator $validator): RedirectResponse
    {
        if (! is_writable(resource_path('views/' . $this->path))) {
            abort(200, __('admin.files.directory_not_writable', ['dir' => $this->path]));
        }
Severity: Minor
Found in app/Http/Controllers/Admin/FileController.php - About 45 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 edit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function edit(int $id, Request $request, Validator $validator)
    {
        if (! isAdmin(User::BOSS)) {
            abort(403, __('errors.forbidden'));
        }
Severity: Minor
Found in app/Http/Controllers/Admin/BoardController.php - About 45 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 install has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function install(Request $request): RedirectResponse
    {
        $moduleName = $request->input('module');
        $enable = int($request->input('enable'));
        $update = int($request->input('update'));
Severity: Minor
Found in app/Http/Controllers/Admin/ModuleController.php - About 45 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

Avoid deeply nested control flow statements.
Open

                        if ($files->isNotEmpty()) {
                            foreach ($files as $file) {
                                $file->delete();
                            }
                        }
Severity: Major
Found in app/Http/Controllers/Admin/UserController.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ($files->isNotEmpty()) {
                                foreach ($files as $file) {
                                    $file->delete();
                                }
                            }
    Severity: Major
    Found in app/Http/Controllers/Admin/UserController.php - About 45 mins to fix

      Function index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function index(Request $request, Validator $validator)
          {
              $login = $request->input('user');
      
              if ($request->isMethod('post')) {
      Severity: Minor
      Found in app/Http/Controllers/ContactController.php - About 45 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function index(Request $request, Validator $validator)
          {
              $login = $request->input('user');
      
              if ($request->isMethod('post')) {
      Severity: Minor
      Found in app/Http/Controllers/IgnoreController.php - About 45 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 getLevelByKey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getLevelByKey(string $level): string
          {
              switch ($level) {
                  case self::BOSS:
                      $status = __('main.boss');
      Severity: Minor
      Found in app/Models/User.php - About 45 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 auth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function auth(string $login, string $password, bool $remember = true)
          {
              if (! empty($login) && ! empty($password)) {
                  $user = getUserByLoginOrEmail($login);
      
      
      Severity: Minor
      Found in app/Models/User.php - About 45 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 generateLogin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function generateLogin($network, string $delimiter = '-'): ?string
          {
              $firstName = ucfirst(Str::slug($network->first_name, $delimiter));
              $lastName = ucfirst(Str::slug($network->last_name, $delimiter));
              $firstLetter = $firstName[0];
      Severity: Minor
      Found in app/Models/Social.php - About 45 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

      Avoid deeply nested control flow statements.
      Open

                                  if ($ans->exists) {
                                      $ans->update(['answer' => $answer]);
                                  } elseif ($countAnswers < 10) {
                                      $ans->fill(['answer' => $answer])->save();
                                      $countAnswers++;
      Severity: Major
      Found in app/Http/Controllers/Forum/TopicController.php - About 45 mins to fix

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

                return response()->json([
                    'success' => true,
                    'data'    => $messages,
                    'links'   => [
                        'next' => $dialogues->nextPageUrl(),
        Severity: Major
        Found in app/Http/Controllers/ApiController.php and 3 other locations - About 45 mins to fix
        app/Http/Controllers/ApiController.php on lines 223..237
        app/Http/Controllers/ApiController.php on lines 277..291
        app/Http/Controllers/ApiController.php on lines 325..339

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

        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 4 locations. Consider refactoring.
        Open

                return response()->json([
                    'success' => true,
                    'data'    => $data,
                    'links'   => [
                        'next' => $topics->nextPageUrl(),
        Severity: Major
        Found in app/Http/Controllers/ApiController.php and 3 other locations - About 45 mins to fix
        app/Http/Controllers/ApiController.php on lines 152..166
        app/Http/Controllers/ApiController.php on lines 223..237
        app/Http/Controllers/ApiController.php on lines 325..339

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

        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 4 locations. Consider refactoring.
        Open

                return response()->json([
                    'success' => true,
                    'data'    => $msg,
                    'links'   => [
                        'next' => $messages->nextPageUrl(),
        Severity: Major
        Found in app/Http/Controllers/ApiController.php and 3 other locations - About 45 mins to fix
        app/Http/Controllers/ApiController.php on lines 152..166
        app/Http/Controllers/ApiController.php on lines 277..291
        app/Http/Controllers/ApiController.php on lines 325..339

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

        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 4 locations. Consider refactoring.
        Open

                return response()->json([
                    'success' => true,
                    'data'    => $data,
                    'links'   => [
                        'next' => $posts->nextPageUrl(),
        Severity: Major
        Found in app/Http/Controllers/ApiController.php and 3 other locations - About 45 mins to fix
        app/Http/Controllers/ApiController.php on lines 152..166
        app/Http/Controllers/ApiController.php on lines 223..237
        app/Http/Controllers/ApiController.php on lines 277..291

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

        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 3 locations. Consider refactoring.
        Open

        <?php
        
        return [
            'create_advert' => 'Post',
            'expires'       => 'Expires',
        Severity: Major
        Found in resources/lang/en/adverts.php and 2 other locations - About 45 mins to fix
        resources/lang/ru/adverts.php on lines 1..30
        resources/lang/ua/adverts.php on lines 1..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 95.

        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 3 locations. Consider refactoring.
        Open

        <?php
        
        return [
            'create_advert' => 'Розмістити',
            'expires'       => 'Закінчується',
        Severity: Major
        Found in resources/lang/ua/adverts.php and 2 other locations - About 45 mins to fix
        resources/lang/en/adverts.php on lines 1..30
        resources/lang/ru/adverts.php on lines 1..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 95.

        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 3 locations. Consider refactoring.
        Open

        <?php
        
        return [
            'create_advert' => 'Разместить',
            'expires'       => 'Истекает',
        Severity: Major
        Found in resources/lang/ru/adverts.php and 2 other locations - About 45 mins to fix
        resources/lang/en/adverts.php on lines 1..30
        resources/lang/ua/adverts.php on lines 1..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 95.

        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

                    if (
                        $post
                        && $post->created_at + 600 > SITETIME
                        && $user->id === $post->user_id
                        && $countFiles + $post->files->count() <= setting('maxfiles')
        Severity: Minor
        Found in app/Http/Controllers/Forum/TopicController.php and 1 other location - About 40 mins to fix
        app/Http/Controllers/Admin/ChatController.php on lines 42..60

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

        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

                        if ($post
                            && $post->created_at + 1800 > SITETIME
                            && $user->id === $post->user_id
                            && (utfStrlen($msg) + utfStrlen($post->text) <= 1500)
                        ) {
        Severity: Minor
        Found in app/Http/Controllers/Admin/ChatController.php and 1 other location - About 40 mins to fix
        app/Http/Controllers/Forum/TopicController.php on lines 165..213

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

        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