pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Inbox has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Inbox
{
    protected $headers;
    protected $profile;
    protected $payload;
Severity: Minor
Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

    FixDuplicateProfiles has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FixDuplicateProfiles extends Command
    {
        /**
         * The name and signature of the console command.
         *
    Severity: Minor
    Found in app/Console/Commands/FixDuplicateProfiles.php - About 2 hrs to fix

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

          public function accountStatuses(Request $request, $id)
          {
              $this->validate($request, [
                  'only_media' => 'nullable',
                  'pinned' => 'nullable',
      Severity: Major
      Found in app/Http/Controllers/InternalApiController.php - About 2 hrs to fix

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

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

          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

            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

                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

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

                                      public function privacyStore(Request $request)
                                      {
                                          $settings = $request->user()->settings;
                                          $profile = $request->user()->profile;
                                          $fields = [
                                  Severity: Major
                                  Found in app/Http/Controllers/Settings/PrivacySettings.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language