pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Function accountNotifications has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in app/Http/Controllers/Api/ApiV1Controller.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 scopeCheck has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function scopeCheck(Profile $profile, Status $status)
    {
        if($profile->is_private == true && Auth::check() == false) {
            abort(404);
        }
Severity: Minor
Found in app/Http/Controllers/PublicApiController.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 accountToId has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function accountToId(Request $request)
    {
        abort_unless((
            config_cache('pixelfed.open_registration') &&
            config('remote-auth.mastodon.enabled')
Severity: Minor
Found in app/Http/Controllers/RemoteAuthController.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 mediaUpload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function mediaUpload(Request $request)
    {
        $this->validate($request, [
            'file'      => function() {
                return [
Severity: Minor
Found in app/Http/Controllers/DirectMessageController.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 parseStreamUrl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function parseStreamUrl($url)
    {
        $name = null;
        $key = null;
        $query = parse_url($url, PHP_URL_QUERY);
Severity: Minor
Found in app/Http/Controllers/LiveStreamController.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 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle()
    {
        $ids = AccountStatService::getAllPostCountIncr();
        if(!$ids || !count($ids)) {
            return;
Severity: Minor
Found in app/Console/Commands/AccountPostCountStatUpdate.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

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

    public function handle()
    {
        $pid = $this->profileId;
        $type = $this->followType;

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

        public function handle()
        {
            $media = $this->media;
            $path = $media->media_path;
            $thumb = $media->thumbnail_path;
    Severity: Minor
    Found in app/Jobs/MediaPipeline/MediaDeletePipeline.php - About 1 hr to fix

      Method headerBlurhash has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function headerBlurhash()
          {
              return Cache::rememberForever(self::CACHE_KEY_BANNER_BLURHASH, function() {
                  if(str_ends_with(config_cache('app.banner_image'), 'headers/default.jpg')) {
                      return 'UzJR]l{wHZRjM}R%XRkCH?X9xaWEjZj]kAjt';
      Severity: Minor
      Found in app/Services/InstanceService.php - About 1 hr to fix

        Method reports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function reports(Request $request)
            {
                $filter = $request->input('filter') == 'closed' ? 'closed' : 'open';
                $page = $request->input('page') ?? 1;
        
        
        Severity: Minor
        Found in app/Http/Controllers/Admin/AdminReportController.php - About 1 hr to fix

          Method handleReportAction has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleReportAction(Report $report, $action)
              {
                  $item = $report->reported();
                  $report->admin_seen = Carbon::now();
          
          
          Severity: Minor
          Found in app/Http/Controllers/Admin/AdminReportController.php - About 1 hr to fix

            Method getConfiguration has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getConfiguration(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 avatarUrl has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function avatarUrl()
                  {
                      $url = Cache::remember('avatar:'.$this->id, 1209600, function () {
                          $avatar = $this->avatar;
              
              
              Severity: Minor
              Found in app/Profile.php - About 1 hr to fix

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

                    public function handle()
                    {
                        $action = select(
                            'What action do you want to perform?',
                            [
                Severity: Minor
                Found in app/Console/Commands/InstanceManager.php - About 1 hr to fix

                  Function toBlob has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      canvas_proto.toBlob = function(callback, type /*, ...args*/) {
                            if (!type) {
                              type = "image/png";
                          } if (this.mozGetAsFile) {
                              callback(this.mozGetAsFile("canvas", type));
                  Severity: Minor
                  Found in resources/assets/js/polyfill.js - About 1 hr to fix

                    Method handleAnnounceActivity has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function handleAnnounceActivity()
                        {
                            $actor = $this->actorFirstOrCreate($this->payload['actor']);
                            $activity = $this->payload['object'];
                    
                    
                    Severity: Minor
                    Found in app/Util/ActivityPub/Inbox.php - About 1 hr to fix

                      Method generate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function generate(Media $media)
                          {
                              if(!in_array($media->mime, ['image/png', 'image/jpeg', 'video/mp4'])) {
                                  return self::DEFAULT_HASH;
                              }
                      Severity: Minor
                      Found in app/Util/Media/Blurhash.php - About 1 hr to fix

                        Method mentionedUsernameExists has 34 lines of code (exceeds 25 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 1 hr to fix

                          Method emailUpdate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function emailUpdate(Request $request)
                              {
                                  $this->validate($request, [
                                      'email'   => 'required|email|unique:users,email',
                                  ]);
                          Severity: Minor
                          Found in app/Http/Controllers/Settings/HomeSettings.php - About 1 hr to fix

                            Method exportStatuses has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function exportStatuses(Request $request)
                                {
                                    $this->validate($request, [
                                        'type' => 'required|string|in:ap,api'
                                    ]);
                            Severity: Minor
                            Found in app/Http/Controllers/Settings/ExportSettings.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language