visavi/rotor

View on GitHub

Showing 512 of 512 total issues

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

        Route::controller(AdminVoteController::class)
            ->prefix('votes')
            ->group(function () {
                Route::get('/', 'index');
                Route::get('/history', 'history');
Severity: Major
Found in routes/web.php and 1 other location - About 1 hr to fix
routes/web.php on lines 563..572

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

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

    public function end(int $id): RedirectResponse
    {
        /** @var Photo $photo */
        $photo = Photo::query()->find($id);

Severity: Major
Found in app/Http/Controllers/PhotoController.php and 2 other locations - About 1 hr to fix
app/Http/Controllers/Load/DownController.php on lines 484..498
app/Http/Controllers/OfferController.php on lines 305..319

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

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

    public function end(int $id): RedirectResponse
    {
        /** @var Offer $offer */
        $offer = Offer::query()->find($id);

Severity: Major
Found in app/Http/Controllers/OfferController.php and 2 other locations - About 1 hr to fix
app/Http/Controllers/Load/DownController.php on lines 484..498
app/Http/Controllers/PhotoController.php on lines 342..356

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

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

    public function edit(int $id, Request $request, Validator $validator): View|RedirectResponse
    {
        if (! $user = getUser()) {
            abort(403, __('main.not_authorized'));
        }
Severity: Minor
Found in app/Http/Controllers/ArticleController.php - About 1 hr to fix

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

        public function edit(int $id, Request $request, Validator $validator)
        {
            if (! $user = getUser()) {
                abort(403, __('main.not_authorized'));
            }
    Severity: Minor
    Found in app/Http/Controllers/BoardController.php - About 1 hr to fix

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

          public function create(Request $request, Validator $validator, Flood $flood)
          {
              if (! $user = getUser()) {
                  abort(403, __('main.not_authorized'));
              }
      Severity: Minor
      Found in app/Http/Controllers/PhotoController.php - About 1 hr to fix

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

            public function edit(int $id, Request $request, Validator $validator): View|RedirectResponse
            {
                $places = PaidAdvert::PLACES;
        
                /** @var PaidAdvert $advert */
        Severity: Minor
        Found in app/Http/Controllers/Admin/PaidAdvertController.php - About 1 hr to fix

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

                      $validator->equal($request->input('_token'), csrf_token(), __('validator.token'))
                          ->length($title, 3, 50, ['title' => __('validator.text')])
                          ->length($text, 5, 1000, ['text' => __('validator.text')])
                          ->in($type, Offer::TYPES, ['type' => __('offers.type_invalid')]);
          Severity: Major
          Found in app/Http/Controllers/Admin/OfferController.php and 1 other location - About 1 hr to fix
          app/Http/Controllers/OfferController.php on lines 150..153

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

          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

                      $validator->equal($request->input('_token'), csrf_token(), __('validator.token'))
                          ->length($title, 3, 50, ['title' => __('validator.text')])
                          ->length($text, 5, 1000, ['text' => __('validator.text')])
                          ->in($type, Offer::TYPES, ['type' => __('offers.type_invalid')]);
          Severity: Major
          Found in app/Http/Controllers/OfferController.php and 1 other location - About 1 hr to fix
          app/Http/Controllers/Admin/OfferController.php on lines 80..83

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

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

              public function edit(Request $request, Validator $validator): View|RedirectResponse
              {
                  $user = getUserByLogin($request->input('user'));
          
                  if (! $user) {
          Severity: Minor
          Found in app/Http/Controllers/Admin/UserController.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

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

              public function index(string $login, Request $request, Validator $validator)
              {
                  $vote = $request->input('vote');
                  $user = getUserByLogin($login);
          
          
          Severity: Minor
          Found in app/Http/Controllers/RatingController.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

          Function statAdverts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function statAdverts(): array
              {
                  return Cache::remember('paidAdverts', 3600, static function () {
                      $data = self::query()->where('deleted_at', '>', SITETIME)->orderBy('created_at')->get();
          
          
          Severity: Minor
          Found in app/Models/PaidAdvert.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 create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function create(Request $request, Validator $validator): View|RedirectResponse
              {
                  $places = PaidAdvert::PLACES;
                  $advert = new PaidAdvert();
                  $place = $request->input('place');
          Severity: Minor
          Found in app/Http/Controllers/Admin/PaidAdvertController.php - About 1 hr to fix

            Method index has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function index(Request $request, Validator $validator)
                {
                    $user = getUser();
            
                    if ($user->newchat !== statsNewChat()) {
            Severity: Minor
            Found in app/Http/Controllers/Admin/ChatController.php - About 1 hr to fix

              Method actionTopic has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function actionTopic(int $id, Request $request): RedirectResponse
                  {
                      $page = int($request->input('page', 1));
              
                      /** @var Topic $topic */
              Severity: Minor
              Found in app/Http/Controllers/Admin/ForumController.php - About 1 hr to fix

                Method dialogues has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function dialogues(Request $request): Response
                    {
                        /** @var User $user */
                        $user = $request->attributes->get('user');
                
                
                Severity: Minor
                Found in app/Http/Controllers/ApiController.php - About 1 hr to fix

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

                          {title: translate.editor.link, name: '<i class="fa fa-link"></i>', className: 'bb-link', key: 'L', openWith: '<a href="[![' + translate.editor.link + ':!:https://]!]"(!( title="[![Title]!]")!)>', closeWith: '</a>', placeHolder: translate.editor.link_text},
                  Severity: Major
                  Found in public/assets/js/markitup-set.js and 1 other location - About 1 hr to fix
                  public/assets/js/markitup-set.js on lines 18..18

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

                  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

                          {title: translate.editor.link, name: '<i class="fa fa-link"></i>', className: 'bb-link', key: 'L', openWith: '[url=[![' + translate.editor.link + ':!:https://]!]]', closeWith: '[/url]', placeHolder: translate.editor.link_text},
                  Severity: Major
                  Found in public/assets/js/markitup-set.js and 1 other location - About 1 hr to fix
                  public/assets/js/markitup-set.js on lines 118..118

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

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

                      public function edit(int $id, Request $request, Validator $validator)
                      {
                          $vote = Vote::query()->where('id', $id)->first();
                  
                          if (! $vote) {
                  Severity: Minor
                  Found in app/Http/Controllers/Admin/VoteController.php - About 1 hr to fix

                    Method createSticker has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function createSticker(Request $request, Validator $validator)
                        {
                            $cid = int($request->input('cid'));
                    
                            $categories = StickersCategory::query()->get();
                    Severity: Minor
                    Found in app/Http/Controllers/Admin/StickerController.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language