pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method getHashtags has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getHashtags(Request $request)
    {
        $user = $request->user();
        abort_if(! config('instance.discover.tags.is_public') && ! $user, 403);

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

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

            if(isset($bodyDecoded['object'])
                && is_array($bodyDecoded['object'])
                && isset($bodyDecoded['object']['attributedTo'])
            ) {
                $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']);
    Severity: Major
    Found in app/Jobs/InboxPipeline/InboxValidator.php and 2 other locations - About 2 hrs to fix
    app/Jobs/InboxPipeline/DeleteWorker.php on lines 138..153
    app/Jobs/InboxPipeline/InboxWorker.php on lines 106..121

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

    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

            if(isset($bodyDecoded['object'])
                && is_array($bodyDecoded['object'])
                && isset($bodyDecoded['object']['attributedTo'])
            ) {
                $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']);
    Severity: Major
    Found in app/Jobs/InboxPipeline/DeleteWorker.php and 2 other locations - About 2 hrs to fix
    app/Jobs/InboxPipeline/InboxValidator.php on lines 125..140
    app/Jobs/InboxPipeline/InboxWorker.php on lines 106..121

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

    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

            if(isset($bodyDecoded['object'])
                && is_array($bodyDecoded['object'])
                && isset($bodyDecoded['object']['attributedTo'])
            ) {
                $attr = Helpers::pluckval($bodyDecoded['object']['attributedTo']);
    Severity: Major
    Found in app/Jobs/InboxPipeline/InboxWorker.php and 2 other locations - About 2 hrs to fix
    app/Jobs/InboxPipeline/DeleteWorker.php on lines 138..153
    app/Jobs/InboxPipeline/InboxValidator.php on lines 125..140

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

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

        protected function fetchAvatar($avatar, $local = false, $skipRecentCheck = false)
        {
            $queue = random_int(1, 15) > 5 ? 'mmo' : 'low';
            $url = $avatar->remote_url;
            $driver = $local ? 'local' : config('filesystems.cloud');
    Severity: Major
    Found in app/Services/MediaStorageService.php - About 2 hrs to fix

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

          public function transform(Profile $profile)
          {
              $res = [
                  '@context' => [
                      'https://w3id.org/security/v1',
      Severity: Major
      Found in app/Transformer/ActivityPub/ProfileTransformer.php - About 2 hrs to fix

        Function mentionedUsernameExists has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function mentionedUsernameExists($username)
            {
                $key = 'pf:services:autolink:userexists:' . hash('sha256', $username);
        
                return Cache::remember($key, 3600, function() use($username) {
        Severity: Minor
        Found in app/Services/AutolinkService.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 handle has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handle(): void
            {
                $payload = $this->payload;
        
                if(empty($payload) || !isset($payload['actor'])) {
        Severity: Minor
        Found in app/Jobs/ProfilePipeline/HandleUpdateActivity.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 import has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function import($url, $id = false)
            {
                if((bool) config_cache('federation.custom_emoji.enabled') == false) {
                    return;
                }
        Severity: Minor
        Found in app/Services/CustomEmojiService.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

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

                        $timeline = Status::select(
                                    'id',
                                    'profile_id',
                                    'type',
                                    'scope',
        Severity: Major
        Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 2 hrs to fix
        app/Http/Controllers/PublicApiController.php on lines 285..324

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

        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

                        $timeline = Status::select(
                                    'id',
                                    'uri',
                                    'caption',
                                    'rendered',
        Severity: Major
        Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 2 hrs to fix
        app/Http/Controllers/PublicApiController.php on lines 251..278

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

        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 help.blade.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        @extends('site.partial.template')
        
        @section('section')
        
          <div class="title">
        Severity: Minor
        Found in resources/views/site/help.blade.php - About 2 hrs to fix

          Method encode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function encode(array $image, int $components_x = 4, int $components_y = 4, bool $linear = false): string {
                  if (($components_x < 1 || $components_x > 9) || ($components_y < 1 || $components_y > 9)) {
                      throw new InvalidArgumentException("x and y component counts must be between 1 and 9 inclusive.");
                  }
                  $height = count($image);
          Severity: Major
          Found in app/Util/Blurhash/Blurhash.php - About 2 hrs to fix

            Method verifySignature has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function verifySignature($headers, $profile, $payload)
                {
                    $body = $this->payload;
                    $bodyDecoded = $payload;
                    $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
            Severity: Major
            Found in app/Jobs/InboxPipeline/InboxValidator.php - About 2 hrs to fix

              Method verifySignature has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function verifySignature($headers, $payload)
                  {
                      $body = $this->payload;
                      $bodyDecoded = $payload;
                      $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
              Severity: Major
              Found in app/Jobs/InboxPipeline/InboxWorker.php - About 2 hrs to fix

                Method import has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function import($url, $id = false)
                    {
                        if((bool) config_cache('federation.custom_emoji.enabled') == false) {
                            return;
                        }
                Severity: Major
                Found in app/Services/CustomEmojiService.php - About 2 hrs to fix

                  Method react has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function react(Request $request)
                      {
                          abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                          $this->validate($request, [
                              'sid' => 'required',
                  Severity: Major
                  Found in app/Http/Controllers/StoryComposeController.php - About 2 hrs to fix

                    Method store has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function store(Request $request)
                        {
                            abort_unless(config('import.instagram.enabled'), 404);
                            $this->checkPermissions($request);
                    
                    
                    Severity: Major
                    Found in app/Http/Controllers/ImportPostController.php - About 2 hrs to fix

                      Method showAtomFeed has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function showAtomFeed(Request $request, $user)
                          {
                              abort_if(! config('federation.atom.enabled'), 404);
                      
                              $pid = AccountService::usernameToId($user);
                      Severity: Major
                      Found in app/Http/Controllers/ProfileController.php - About 2 hrs to fix

                        Method reportsHandleStoryAction has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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