pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Function timelineHome has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public function timelineHome(Request $request)
    {
        abort_if(! $request->user() || ! $request->user()->token(), 403);
        abort_unless($request->user()->tokenCan('read'), 403);

Severity: Minor
Found in app/Http/Controllers/Api/ApiV1Controller.php - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method autospamHandle has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function autospamHandle(Request $request)
    {
        abort_if(!$request->user() || !$request->user()->token(), 404);

        abort_unless($request->user()->is_admin == 1, 404);
Severity: Major
Found in app/Http/Controllers/Api/AdminApiController.php - About 5 hrs to fix

    Method updateSpam has 124 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function updateSpam(Request $request, $id)
        {
            $this->validate($request, [
                'action' => 'required|in:dismiss,approve,dismiss-all,approve-all,delete-account,mark-spammer',
            ]);
    Severity: Major
    Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 hrs to fix

      Method reportsHandleStatusAction has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function reportsHandleStatusAction($report, $action)
          {
              switch ($action) {
                  case 'ignore':
                      Report::whereObjectId($report->object_id)
      Severity: Major
      Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 hrs to fix

        Function reportsHandleProfileAction has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function reportsHandleProfileAction($report, $action)
            {
                switch ($action) {
                    case 'ignore':
                        Report::whereObjectId($report->object_id)
        Severity: Minor
        Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

                if (config('autospam.live_filters.enabled')) {
                    $filters = config('autospam.live_filters.filters');
                    if (! empty($filters) && isset($res['content']) && ! empty($res['content']) && strlen($filters) > 3) {
                        $filters = array_map('trim', explode(',', $filters));
                        $content = $res['content'];
        Severity: Major
        Found in app/Util/ActivityPub/Helpers.php and 1 other location - About 4 hrs to fix
        app/Util/ActivityPub/Inbox.php on lines 200..215

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

        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(config('autospam.live_filters.enabled')) {
                    $filters = config('autospam.live_filters.filters');
                    if(!empty($filters) && isset($activity['content']) && !empty($activity['content']) && strlen($filters) > 3) {
                        $filters = array_map('trim', explode(',', $filters));
                        $content = $activity['content'];
        Severity: Major
        Found in app/Util/ActivityPub/Inbox.php and 1 other location - About 4 hrs to fix
        app/Util/ActivityPub/Helpers.php on lines 311..326

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

        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

        File DiscoverController.php has 370 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Http\Controllers;
        
        use App\Hashtag;
        Severity: Minor
        Found in app/Http/Controllers/DiscoverController.php - About 4 hrs to fix

          Method transform has 122 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function transform(Status $status)
              {
                  $mentions = $status->mentions->map(function ($mention) {
                      $webfinger = $mention->emailUrl();
                      $name = Str::startsWith($webfinger, '@') ? 
          Severity: Major
          Found in app/Transformer/ActivityPub/Verb/CreateNote.php - About 4 hrs to fix

            Method handleDirectMessage has 119 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function handleDirectMessage()
                {
                    $activity = $this->payload['object'];
                    $actor = $this->actorFirstOrCreate($this->payload['actor']);
                    $profile = Profile::whereNull('domain')
            Severity: Major
            Found in app/Util/ActivityPub/Inbox.php - About 4 hrs to fix

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

                  protected function createEdit($status, $activity)
                  {
                      $cleaned = isset($activity['content']) ? Purify::clean($activity['content']) : null;
                      $spoiler_text = isset($activity['summary']) ? Purify::clean($activity['summary']) : null;
                      $sensitive = isset($activity['sensitive']) ? $activity['sensitive'] : null;
              Severity: Major
              Found in app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php and 1 other location - About 4 hrs to fix
              app/Services/Status/UpdateStatusService.php on lines 122..136

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

              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 static function createEdit(Status $status, $attributes)
                  {
                      $cleaned = isset($attributes['status']) ? Purify::clean($attributes['status']) : null;
                      $spoiler_text = isset($attributes['spoiler_text']) ? Purify::clean($attributes['spoiler_text']) : null;
                      $sensitive = isset($attributes['sensitive']) ? $attributes['sensitive'] : null;
              Severity: Major
              Found in app/Services/Status/UpdateStatusService.php and 1 other location - About 4 hrs to fix
              app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.php on lines 157..171

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

              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

                      Route::group(['prefix' => 'direct'], function () use($middleware) {
                          Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
                          Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware);
                          Route::delete('thread/message', 'DirectMessageController@delete')->middleware($middleware);
                          Route::post('thread/mute', 'DirectMessageController@mute')->middleware($middleware);
              Severity: Major
              Found in routes/api.php and 3 other locations - About 4 hrs to fix
              routes/api.php on lines 242..251
              routes/api.php on lines 274..283
              routes/api.php on lines 304..313

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

              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

                          Route::group(['prefix' => 'direct'], function () use($middleware) {
                              Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
                              Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware);
                              Route::delete('thread/message', 'DirectMessageController@delete')->middleware($middleware);
                              Route::post('thread/mute', 'DirectMessageController@mute')->middleware($middleware);
              Severity: Major
              Found in routes/api.php and 3 other locations - About 4 hrs to fix
              routes/api.php on lines 138..147
              routes/api.php on lines 242..251
              routes/api.php on lines 304..313

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

              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

                          Route::group(['prefix' => 'accounts'], function () use($middleware) {
                              Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware);
                              Route::delete('avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware);
                              Route::get('{id}/posts', 'Api\ApiV1Dot1Controller@accountPosts')->middleware($middleware);
                              Route::post('change-password', 'Api\ApiV1Dot1Controller@accountChangePassword')->middleware($middleware);
              Severity: Major
              Found in routes/api.php and 3 other locations - About 4 hrs to fix
              routes/api.php on lines 138..147
              routes/api.php on lines 274..283
              routes/api.php on lines 304..313

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

              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

                          Route::group(['prefix' => 'stories'], function () use($middleware) {
                              Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware);
                              Route::get('self-carousel', 'Stories\StoryApiV1Controller@selfCarousel')->middleware($middleware);
                              Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware);
                              Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware);
              Severity: Major
              Found in routes/api.php and 3 other locations - About 4 hrs to fix
              routes/api.php on lines 138..147
              routes/api.php on lines 242..251
              routes/api.php on lines 274..283

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

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

                  public function userAdminAction(Request $request)
                  {
                      abort_if(!$request->user() || !$request->user()->token(), 404);
              
                      abort_unless($request->user()->is_admin == 1, 404);
              Severity: Minor
              Found in app/Http/Controllers/Api/AdminApiController.php - About 4 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function handleDirectMessage has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function handleDirectMessage()
                  {
                      $activity = $this->payload['object'];
                      $actor = $this->actorFirstOrCreate($this->payload['actor']);
                      $profile = Profile::whereNull('domain')
              Severity: Minor
              Found in app/Util/ActivityPub/Inbox.php - About 4 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method transform has 114 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function transform(Status $status)
                  {
              
                      $mentions = $status->mentions->map(function ($mention) {
                          $webfinger = $mention->emailUrl();
              Severity: Major
              Found in app/Transformer/ActivityPub/Verb/Note.php - About 4 hrs to fix

                File SearchApiV2Service.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace App\Services;
                
                use App\Hashtag;
                Severity: Minor
                Found in app/Services/SearchApiV2Service.php - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language