pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

    public function handle()
    {
        $duplicates = DB::table('profiles')
            ->whereNull('domain')
            ->select('username', DB::raw('COUNT(*) as "count"'))
Severity: Minor
Found in app/Console/Commands/FixDuplicateProfiles.php - About 1 hr to fix

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

        public static function get()
        {
            $res = Cache::remember('api:nodeinfo', 900, function () {
                $activeHalfYear = self::activeUsersHalfYear();
                $activeMonth = self::activeUsersMonthly();
    Severity: Minor
    Found in app/Util/Site/Nodeinfo.php - About 1 hr to fix

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

          public function fanoutDelete($status)
          {
              $profile = $status->profile;
      
              if (! $profile) {
      Severity: Minor
      Found in app/Jobs/StatusPipeline/StatusDelete.php - About 1 hr to fix

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

            public static function get($url, $validateUrl = true)
            {
                if($validateUrl === true) {
                    if(!Helpers::validateUrl($url)) {
                        return 0;
        Severity: Minor
        Found in app/Services/ActivityPubFetchService.php - About 1 hr to fix

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

              public function storeReport(Request $request)
              {
                  abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
          
                  $this->validate($request, [
          Severity: Minor
          Found in app/Http/Controllers/StoryComposeController.php - About 1 hr to fix

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

                public function getRssFeed(Request $request, $username)
                {
                    $user = User::whereUsername($username)->first();
            
                    if(!$user) {
            Severity: Minor
            Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

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

                  public function modReportHandle(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 1 hr to fix

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

                    public function remoteDeliver($dm)
                    {
                        $profile = $dm->author;
                        $url = $dm->recipient->sharedInbox ?? $dm->recipient->inbox_url;
                
                
                Severity: Minor
                Found in app/Http/Controllers/DirectMessageController.php - About 1 hr to fix

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

                          $rules = Cache::remember('api:v1:instance-data:rules', 604800, function () {
                              return config_cache('app.rules') ?
                                  collect(json_decode(config_cache('app.rules'), true))
                                      ->map(function ($rule, $key) {
                                          $id = $key + 1;
                  Severity: Major
                  Found in app/Services/LandingService.php and 2 other locations - About 1 hr to fix
                  app/Http/Controllers/Api/ApiV1Controller.php on lines 1619..1631
                  app/Http/Controllers/Api/ApiV2Controller.php on lines 61..72

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

                              $rules = Cache::remember('api:v1:instance-data:rules', 604800, function () {
                                  return config_cache('app.rules') ?
                                      collect(json_decode(config_cache('app.rules'), true))
                                          ->map(function ($rule, $key) {
                                              $id = $key + 1;
                  Severity: Major
                  Found in app/Http/Controllers/Api/ApiV1Controller.php and 2 other locations - About 1 hr to fix
                  app/Http/Controllers/Api/ApiV2Controller.php on lines 61..72
                  app/Services/LandingService.php on lines 36..48

                  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

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

                          } else if ($max_id) {
                              $res = DirectMessage::select('*')
                              ->where('id', '<', $max_id)
                              ->where(function($q) use($pid,$uid) {
                                  return $q->where([['from_id',$pid],['to_id',$uid]
                  Severity: Major
                  Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/DirectMessageController.php on lines 421..449

                  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

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

                          if($min_id) {
                              $res = DirectMessage::select('*')
                              ->where('id', '>', $min_id)
                              ->where(function($q) use($pid,$uid) {
                                  return $q->where([['from_id',$pid],['to_id',$uid]
                  Severity: Major
                  Found in app/Http/Controllers/DirectMessageController.php and 1 other location - About 1 hr to fix
                  app/Http/Controllers/DirectMessageController.php on lines 431..449

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

                          $rules = Cache::remember('api:v1:instance-data:rules', 604800, function () {
                              return config_cache('app.rules') ?
                                  collect(json_decode(config_cache('app.rules'), true))
                                  ->map(function($rule, $key) {
                                      $id = $key + 1;
                  Severity: Major
                  Found in app/Http/Controllers/Api/ApiV2Controller.php and 2 other locations - About 1 hr to fix
                  app/Http/Controllers/Api/ApiV1Controller.php on lines 1619..1631
                  app/Services/LandingService.php on lines 36..48

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

                      public static function decode (string $blurhash, int $width, int $height, float $punch = 1.0, bool $linear = false): array {
                          if (empty($blurhash) || strlen($blurhash) < 6) {
                              throw new InvalidArgumentException("Blurhash string must be at least 6 characters");
                          }
                  
                  
                  Severity: Minor
                  Found in app/Util/Blurhash/Blurhash.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 handle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle()
                      {
                          $username = $this->username;
                          $headers = $this->headers;
                  
                  
                  Severity: Minor
                  Found in app/Jobs/InboxPipeline/InboxValidator.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 handle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handle(): void
                      {
                          if(!config('exp.cached_home_timeline')) {
                              return;
                          }
                  Severity: Minor
                  Found in app/Jobs/HomeFeedPipeline/FeedRemoveDomainPipeline.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 importNoteAttachment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function importNoteAttachment($data, Status $status)
                      {
                          if (self::verifyAttachments($data) == false) {
                              // \Log::info('importNoteAttachment::failedVerification.', [$data['id']]);
                              $status->viewType();
                  Severity: Minor
                  Found in app/Util/ActivityPub/Helpers.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 profileUpdateOrCreate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function profileUpdateOrCreate($url)
                      {
                          $res = self::fetchProfileFromUrl($url);
                          if (! $res || isset($res['id']) == false) {
                              return;
                  Severity: Minor
                  Found in app/Util/ActivityPub/Helpers.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 updateImmediateAttributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function updateImmediateAttributes($status, $activity)
                      {
                          if (isset($activity['content'])) {
                              $status->caption = strip_tags($activity['content']);
                              $status->rendered = Purify::clean($activity['content']);
                  Severity: Minor
                  Found in app/Jobs/StatusPipeline/StatusRemoteUpdatePipeline.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 get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function get($domain)
                      {
                          $version = config('pixelfed.version');
                          $appUrl = config('app.url');
                          $headers = [
                  Severity: Minor
                  Found in app/Services/NodeinfoService.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

                  Severity
                  Category
                  Status
                  Source
                  Language