visavi/rotor

View on GitHub

Showing 512 of 512 total issues

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

    public function handle(Request $request, Closure $next)
    {
        if ($this->isBanned($request)) {
            return redirect('ipban');
        }
Severity: Minor
Found in app/Http/Middleware/CheckAccessSite.php - About 1 hr to fix

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

        public function edit(int $id, Request $request, Validator $validator)
        {
            /** @var Notice $notice */
            $notice = Notice::query()->find($id);
    
    
    Severity: Minor
    Found in app/Http/Controllers/Admin/NoticeController.php - About 1 hr to fix

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

          public function edit(Request $request, Validator $validator)
          {
              $path = $this->path;
              $file = $path ? '/' . $this->file : $this->file;
              $writable = is_writable(resource_path('views/' . $path . $file . '.blade.php'));
      Severity: Minor
      Found in app/Http/Controllers/Admin/FileController.php - About 1 hr to fix

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

            private static function parsePhpModules(): array
            {
                ob_start();
                phpinfo(INFO_MODULES);
                $s = ob_get_clean();
        Severity: Minor
        Found in app/Http/Controllers/InstallController.php - About 1 hr to fix

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

              public function createDialogue(User $user, ?User $author, string $text, bool $withAuthor)
              {
                  $authorId = $author->id ?? 0;
          
                  $message = self::query()->create([
          Severity: Minor
          Found in app/Models/Message.php - About 1 hr to fix

            Method getLevelByKey has 26 lines of code (exceeds 25 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 1 hr to fix

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

              function statsPhotos(): string
              {
                  return Cache::remember('statPhotos', 900, static function () {
                      $stat = Photo::query()->count();
                      $totalNew = Photo::query()->where('created_at', '>', strtotime('-1 day', SITETIME))->count();
              Severity: Major
              Found in app/helpers.php and 3 other locations - About 1 hr to fix
              app/helpers.php on lines 520..531
              app/helpers.php on lines 631..639
              app/helpers.php on lines 684..695

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

              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

              function statsBlog(): string
              {
                  return Cache::remember('statArticles', 900, static function () {
                      $stat = Article::query()->count();
                      $totalNew = Article::query()->where('created_at', '>', strtotime('-1 day', SITETIME))->count();
              Severity: Major
              Found in app/helpers.php and 3 other locations - About 1 hr to fix
              app/helpers.php on lines 505..513
              app/helpers.php on lines 520..531
              app/helpers.php on lines 684..695

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

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

                      Route::controller(StatusController::class)
                          ->prefix('status')
                          ->group(function () {
                              Route::get('/', 'index');
                              Route::match(['get', 'post'], '/create', 'create');
              Severity: Major
              Found in routes/web.php and 4 other locations - About 1 hr to fix
              routes/web.php on lines 662..669
              routes/web.php on lines 882..889
              routes/web.php on lines 892..899
              routes/web.php on lines 910..917

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

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

                      Route::controller(PaidAdvertController::class)
                          ->prefix('paid-adverts')
                          ->group(function () {
                              Route::get('/', 'index');
                              Route::match(['get', 'post'], '/create', 'create');
              Severity: Major
              Found in routes/web.php and 4 other locations - About 1 hr to fix
              routes/web.php on lines 662..669
              routes/web.php on lines 820..827
              routes/web.php on lines 882..889
              routes/web.php on lines 892..899

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

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

                      Route::controller(NoticeController::class)
                          ->prefix('notices')
                          ->group(function () {
                              Route::get('/', 'index');
                              Route::match(['get', 'post'], '/create', 'create');
              Severity: Major
              Found in routes/web.php and 4 other locations - About 1 hr to fix
              routes/web.php on lines 662..669
              routes/web.php on lines 820..827
              routes/web.php on lines 892..899
              routes/web.php on lines 910..917

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

              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

              function statsNews(): string
              {
                  return Cache::remember('statNews', 300, static function () {
                      $total = News::query()->count();
              
              
              Severity: Major
              Found in app/helpers.php and 3 other locations - About 1 hr to fix
              app/helpers.php on lines 505..513
              app/helpers.php on lines 631..639
              app/helpers.php on lines 684..695

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

              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

              function statsChat(): string
              {
                  return Cache::remember('statChat', 3600, static function () {
                      $total = Chat::query()->count();
              
              
              Severity: Major
              Found in app/helpers.php and 3 other locations - About 1 hr to fix
              app/helpers.php on lines 505..513
              app/helpers.php on lines 520..531
              app/helpers.php on lines 631..639

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

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

                      Route::controller(AdminBanController::class)
                          ->prefix('bans')
                          ->group(function () {
                              Route::get('/', 'index');
                              Route::match(['get', 'post'], '/edit', 'edit');
              Severity: Major
              Found in routes/web.php and 4 other locations - About 1 hr to fix
              routes/web.php on lines 820..827
              routes/web.php on lines 882..889
              routes/web.php on lines 892..899
              routes/web.php on lines 910..917

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

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

                      Route::controller(AdminFileController::class)
                          ->prefix('files')
                          ->group(function () {
                              Route::get('/', 'index');
                              Route::match(['get', 'post'], '/edit', 'edit');
              Severity: Major
              Found in routes/web.php and 4 other locations - About 1 hr to fix
              routes/web.php on lines 662..669
              routes/web.php on lines 820..827
              routes/web.php on lines 882..889
              routes/web.php on lines 910..917

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

              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

                      $users = User::query()
                          ->when($type === 'admins', static function (Builder $query) {
                              return $query->whereIn('level', User::ADMIN_GROUPS);
                          })
                          ->when($type === 'birthdays', static function (Builder $query) {
              Severity: Minor
              Found in app/Http/Controllers/User/ListController.php and 1 other location - About 1 hr to fix
              app/Http/Controllers/User/ListController.php on lines 46..54

              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

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

                          $position = User::query()
                              ->when($type === 'admins', static function (Builder $query) {
                                  return $query->whereIn('level', User::ADMIN_GROUPS);
                              })
                              ->when($type === 'birthdays', static function (Builder $query) {
              Severity: Minor
              Found in app/Http/Controllers/User/ListController.php and 1 other location - About 1 hr to fix
              app/Http/Controllers/User/ListController.php on lines 34..42

              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

                  public function allComments(): View
                  {
                      $comments = Comment::query()
                          ->select('comments.*', 'title', 'count_comments')
                          ->where('relate_type', News::$morphName)
              Severity: Minor
              Found in app/Http/Controllers/NewsController.php and 1 other location - About 55 mins to fix
              app/Http/Controllers/Load/NewController.php on lines 31..42

              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

                  public function comments(): View
                  {
                      $comments = Comment::query()
                          ->select('comments.*', 'title', 'count_comments')
                          ->where('relate_type', Down::$morphName)
              Severity: Minor
              Found in app/Http/Controllers/Load/NewController.php and 1 other location - About 55 mins to fix
              app/Http/Controllers/NewsController.php on lines 230..241

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

                  public function editPost(int $id, Request $request, Validator $validator)
                  {
                      $page = int($request->input('page'));
              
                      if (! $user = getUser()) {
              Severity: Minor
              Found in app/Http/Controllers/Forum/TopicController.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

              Severity
              Category
              Status
              Source
              Language