pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method buildListing has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function buildListing()
    {
        $res = config_cache('pixelfed.directory');
        if ($res) {
            $res = is_string($res) ? json_decode($res, true) : $res;
Severity: Major
Found in app/Http/Controllers/PixelfedDirectoryController.php - About 4 hrs to fix

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

        public function pinChatComment(Request $request)
        {
            abort_if(!config('livestreaming.enabled'), 400);
            abort_if(!$request->user(), 403);
    
    
    Severity: Major
    Found in app/Http/Controllers/LiveStreamController.php and 1 other location - About 4 hrs to fix
    app/Http/Controllers/LiveStreamController.php on lines 316..335

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

    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 unpinChatComment(Request $request)
        {
            abort_if(!config('livestreaming.enabled'), 400);
            abort_if(!$request->user(), 403);
    
    
    Severity: Major
    Found in app/Http/Controllers/LiveStreamController.php and 1 other location - About 4 hrs to fix
    app/Http/Controllers/LiveStreamController.php on lines 295..314

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

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

        public function statusRebloggedBy(Request $request, $id)
        {
            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 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

    File web.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofactor', 'localization'])->group(function () {
        Route::get('/', 'SiteController@home')->name('timeline.personal');
        Route::redirect('/home', '/')->name('home');
    Severity: Minor
    Found in routes/web.php - About 4 hrs to fix

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

              if ($count == 0) {
                  $filterCount = UserFilter::whereUserId($pid)
                      ->whereFilterType('mute')
                      ->get()
                      ->map(function ($rec) {
      Severity: Major
      Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 hrs to fix
      app/Http/Controllers/Api/ApiV1Controller.php on lines 1107..1122

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

      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 ($count == 0) {
                  $filterCount = UserFilter::whereUserId($pid)
                      ->whereFilterType('block')
                      ->get()
                      ->map(function ($rec) {
      Severity: Major
      Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 hrs to fix
      app/Http/Controllers/Api/ApiV1Controller.php on lines 2149..2164

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

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

          public function carousel(Request $request)
          {
              abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
              $pid = $request->user()->profile_id;
      
      
      Severity: Major
      Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 3 hrs to fix

        Method selfCarousel has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function selfCarousel(Request $request)
            {
                abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                $pid = $request->user()->profile_id;
        
        
        Severity: Major
        Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 3 hrs to fix

          Method handleStoryReplyActivity has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleStoryReplyActivity()
              {
                  if(!isset(
                      $this->payload['actor'],
                      $this->payload['id'],
          Severity: Major
          Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

            Method handleStoryReactionActivity has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function handleStoryReactionActivity()
                {
                    if(!isset(
                        $this->payload['actor'],
                        $this->payload['id'],
            Severity: Major
            Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

              Method checkPermissions has 98 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function checkPermissions($request, $abortOnFail = true)
                  {
                      $user = $request->user();
              
                      if($abortOnFail) {
              Severity: Major
              Found in app/Http/Controllers/ImportPostController.php - About 3 hrs to fix

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

                    public function handle()
                    {
                        if(!config('import.instagram.enabled')) {
                            return;
                        }
                Severity: Major
                Found in app/Console/Commands/TransformImports.php - About 3 hrs to fix

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

                      public function followerCount($short = false)
                      {
                          $count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() {
                              if($this->domain == null && $this->user->settings->show_profile_follower_count == false) {
                                  return 0;
                  Severity: Major
                  Found in app/Profile.php and 1 other location - About 3 hrs to fix
                  app/Profile.php on lines 68..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 160.

                  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 followingCount($short = false)
                      {
                          $count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() {
                              if($this->domain == null && $this->user->settings->show_profile_following_count == false) {
                                  return 0;
                  Severity: Major
                  Found in app/Profile.php and 1 other location - About 3 hrs to fix
                  app/Profile.php on lines 85..99

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

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

                      public function storeSettings(Request $request)
                      {
                          abort_if(!$request->user(), 403);
                  
                          $this->validate($request, [
                  Severity: Major
                  Found in app/Http/Controllers/PortfolioController.php - About 3 hrs to fix

                    Method timelineHashtag has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function timelineHashtag(Request $request, $hashtag)
                        {
                            abort_if(! $request->user() || ! $request->user()->token(), 403);
                            abort_unless($request->user()->tokenCan('read'), 403);
                    
                    
                    Severity: Major
                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix

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

                              $requests = function($audience) use ($client, $activity, $profile, $payload, $userAgent) {
                                  foreach($audience as $url) {
                                      $headers = HttpSignature::sign($profile, $url, $activity, [
                                          'Content-Type'    => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
                                          'User-Agent'    => $userAgent,
                      Severity: Major
                      Found in app/Jobs/StatusPipeline/StatusActivityPubDeliver.php and 3 other locations - About 3 hrs to fix
                      app/Console/Commands/UserAccountDelete.php on lines 91..109
                      app/Jobs/ProfilePipeline/ProfileMigrationDeliverMoveActivityPipeline.php on lines 108..126
                      app/Jobs/StatusPipeline/StatusLocalUpdateActivityPubDeliverPipeline.php on lines 97..115

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

                      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

                              Route::group(['prefix' => 'collections'], function () use($middleware) {
                                  Route::get('accounts/{id}', 'CollectionController@getUserCollections')->middleware($middleware);
                                  Route::get('items/{id}', 'CollectionController@getItems')->middleware($middleware);
                                  Route::get('view/{id}', 'CollectionController@getCollection')->middleware($middleware);
                                  Route::post('add', 'CollectionController@storeId')->middleware($middleware);
                      Severity: Major
                      Found in routes/api.php and 1 other location - About 3 hrs to fix
                      routes/api.php on lines 259..267

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

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

                              $requests = function ($audience) use ($client, $activity, $profile, $payload, $userAgent) {
                                  foreach ($audience as $url) {
                                      $headers = HttpSignature::sign($profile, $url, $activity, [
                                          'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
                                          'User-Agent' => $userAgent,
                      app/Console/Commands/UserAccountDelete.php on lines 91..109
                      app/Jobs/StatusPipeline/StatusActivityPubDeliver.php on lines 117..135
                      app/Jobs/StatusPipeline/StatusLocalUpdateActivityPubDeliverPipeline.php on lines 97..115

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

                      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