pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Function storeStatus has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public static function storeStatus($url, $profile, $activity)
    {
        $originalUrl = $url;
        $id = isset($activity['id']) ? self::pluckval($activity['id']) : self::pluckval($activity['url']);
        $url = isset($activity['url']) && is_string($activity['url']) ? self::pluckval($activity['url']) : self::pluckval($id);
Severity: Minor
Found in app/Util/ActivityPub/Helpers.php - About 2 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 warmCache has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public static function warmCache($id, $force = false, $limit = 100, $returnIds = false)
    {
        if(self::count($id) == 0 || $force == true) {
            Redis::del(self::CACHE_KEY . $id);
            $following = Cache::remember('profile:following:'.$id, 1209600, function() use($id) {
Severity: Minor
Found in app/Services/HomeTimelineService.php - About 2 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 store has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function store(Request $request)
    {
        abort_unless(config('import.instagram.enabled'), 404);
        $this->checkPermissions($request);

Severity: Minor
Found in app/Http/Controllers/ImportPostController.php - About 2 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 accountBlockById has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

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

        public function handle()
        {
            $totalUserCount = Profile::whereNotNull('user_id')->count();
            $totalInstanceCount = Instance::count();
            $this->info('Found ' . $totalUserCount . ' local accounts and ' . $totalInstanceCount . ' remote instances');
    Severity: Major
    Found in app/Console/Commands/SendUpdateActor.php - About 2 hrs to fix

      File ApiV2Controller.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Http\Controllers\Api;
      
      use Illuminate\Http\Request;
      Severity: Minor
      Found in app/Http/Controllers/Api/ApiV2Controller.php - About 2 hrs to fix

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

            public function handle()
            {
                $status = $this->status;
                $profile = $status->profile;
        
        
        Severity: Major
        Found in app/Jobs/StatusPipeline/StatusActivityPubDeliver.php - About 2 hrs to fix

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

              public function handle(): void
              {
                  $spamExists = Storage::exists(AutospamService::MODEL_SPAM_PATH);
                  if($spamExists) {
                      $spam = json_decode(Storage::get(AutospamService::MODEL_SPAM_PATH), true);
          Severity: Major
          Found in app/Jobs/AutospamPipeline/AutospamUpdateCachedDataPipeline.php - About 2 hrs to fix

            Method searchLocation has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function searchLocation(Request $request)
                {
                    abort_if(! $request->user(), 403);
                    $this->validate($request, [
                        'q' => 'required|string|max:100',
            Severity: Major
            Found in app/Http/Controllers/ComposeController.php - About 2 hrs to fix

              Method storeText has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function storeText(Request $request)
                  {
                      abort_unless(config('exp.top'), 404);
                      $this->validate($request, [
                          'caption' => 'nullable|string|max:'.config_cache('pixelfed.max_caption_length', 500),
              Severity: Major
              Found in app/Http/Controllers/ComposeController.php - About 2 hrs to fix

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

                        if($type === 'followers') {
                            $key = 'follow-warm-cache/' . $pid . '/followers.json';
                            if(!Storage::exists($key)) {
                                return;
                            }
                app/Jobs/FollowPipeline/FollowServiceWarmCacheLargeIngestPipeline.php on lines 66..80

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

                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($type === 'following') {
                            $key = 'follow-warm-cache/' . $pid . '/following.json';
                            if(!Storage::exists($key)) {
                                return;
                            }
                app/Jobs/FollowPipeline/FollowServiceWarmCacheLargeIngestPipeline.php on lines 50..64

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

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

                    public function handle()
                    {
                        if(config_cache('pixelfed.import.instagram.enabled') != true) {
                            return;
                        }
                Severity: Major
                Found in app/Jobs/ImportPipeline/ImportInstagram.php - About 2 hrs to fix

                  Method roleData has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function roleData()
                      {
                          return [
                              'account-force-private' => [
                                  'title' => 'Force Private Account',
                  Severity: Major
                  Found in app/Services/UserRoleService.php - About 2 hrs to fix

                    Method instance has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function instance(Request $request)
                        {
                            $res = Cache::remember('api:v1:instance-data-response-v1', 1800, function () {
                                $contact = Cache::remember('api:v1:instance-data:contact', 604800, function () {
                                    if (config_cache('instance.admin.pid')) {
                    Severity: Major
                    Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                      Method getProfiles has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function getProfiles()
                          {
                              $tag = $this->term;
                              $remoteKey = $this->cacheKey.'profiles:remote:'.$this->hash;
                              $key = $this->cacheKey.'profiles:'.$this->hash;
                      Severity: Major
                      Found in app/Http/Controllers/SearchController.php - About 2 hrs to fix

                        Identical blocks of code found in 3 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/SharePipeline/SharePipeline.php and 2 other locations - About 2 hrs to fix
                        app/Jobs/SharePipeline/UndoSharePipeline.php on lines 108..124
                        app/Jobs/StatusPipeline/StatusDelete.php on lines 190..206

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

                        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

                                $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/SharePipeline/UndoSharePipeline.php and 2 other locations - About 2 hrs to fix
                        app/Jobs/SharePipeline/SharePipeline.php on lines 122..138
                        app/Jobs/StatusPipeline/StatusDelete.php on lines 190..206

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

                        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

                                $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/StatusDelete.php and 2 other locations - About 2 hrs to fix
                        app/Jobs/SharePipeline/SharePipeline.php on lines 122..138
                        app/Jobs/SharePipeline/UndoSharePipeline.php on lines 108..124

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

                        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

                                if ($author && $res->hasPages()) {
                                    $links = '';
                        
                                    if ($res->onFirstPage()) {
                                        if ($res->nextPageUrl()) {
                        Severity: Major
                        Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 2 hrs to fix
                        app/Http/Controllers/Api/ApiV1Controller.php on lines 3157..3177

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

                        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