pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Function verifySignature has a Cognitive Complexity of 22 (exceeds 5 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: Minor
Found in app/Jobs/InboxPipeline/DeleteWorker.php - About 3 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 get has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function get(Status $status)
    {
        if($status->uri || $status->scope != 'public') {
            return;
        }
Severity: Major
Found in app/Util/Sentiment/Bouncer.php - About 3 hrs to fix

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

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

      Method formStore has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function formStore(Request $request)
          {
              $this->validate($request, [
                  'report'  => 'required|alpha_dash',
                  'type'    => 'required|alpha_dash',
      Severity: Major
      Found in app/Http/Controllers/ReportController.php - About 3 hrs to fix

        Method statusFavouritedBy has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method apiActivityLog has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function apiActivityLog(Request $request, $id)
              {
                  $record = CuratedRegister::findOrFail($id);
          
                  $res = collect([
          Severity: Major
          Found in app/Http/Controllers/AdminCuratedRegisterController.php - About 3 hrs to fix

            Method redirect has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function redirect(Request $request)
                {
                    abort_unless((
                        config_cache('pixelfed.open_registration') &&
                        config('remote-auth.mastodon.enabled')
            Severity: Major
            Found in app/Http/Controllers/RemoteAuthController.php - About 3 hrs to fix

              AccountController has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class AccountController extends Controller
              {
                  protected $filters = [
                      'user.mute',
                      'user.block',
              Severity: Minor
              Found in app/Http/Controllers/AccountController.php - About 3 hrs to fix

                Method statusReplies has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method thread has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function thread(Request $request)
                      {
                          $this->validate($request, [
                              'pid' => 'required'
                          ]);
                  Severity: Major
                  Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

                    Method settingsApiUpdateStorageType has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function settingsApiUpdateStorageType($request)
                        {
                            $this->validate($request, [
                                'primary_disk' => 'required|in:local,cloud',
                                'update_disk' => 'sometimes',
                    Severity: Major
                    Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

                      Method block has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function block(Request $request)
                          {
                              $this->validate($request, [
                                  'type' => 'required|string|in:user',
                                  'item' => 'required|integer|min:1',
                      Severity: Major
                      Found in app/Http/Controllers/AccountController.php - About 2 hrs to fix

                        Method statusRebloggedBy has 74 lines of code (exceeds 25 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: Major
                        Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

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

                              public function handle()
                              {
                                  $this->info('Pixelfed Avatar Storage Manager');
                                  $this->line(' ');
                                  $segments = [
                          Severity: Major
                          Found in app/Console/Commands/AvatarStorage.php - About 2 hrs to fix

                            File AdminCuratedRegisterController.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            namespace App\Http\Controllers;
                            
                            use App\Mail\CuratedRegisterAcceptUser;
                            Severity: Minor
                            Found in app/Http/Controllers/AdminCuratedRegisterController.php - About 2 hrs to fix

                              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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language