pixelfed/pixelfed

View on GitHub

Showing 1,557 of 1,560 total issues

Function avatarUrl has a Cognitive Complexity of 11 (exceeds 5 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

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

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

mix.sass('resources/assets/sass/app.scss', 'public/css')
.sass('resources/assets/sass/appdark.scss', 'public/css')
.sass('resources/assets/sass/admin.scss', 'public/css')
.sass('resources/assets/sass/portfolio.scss', 'public/css')
.sass('resources/assets/sass/spa.scss', 'public/css')
Severity: Major
Found in webpack.mix.js and 1 other location - About 1 hr to fix
webpack.mix.js on lines 18..24

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

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

    public function handle(): void
    {
        $sid = $this->sid;
        $status = StatusService::get($sid, false);

Severity: Minor
Found in app/Jobs/HomeFeedPipeline/FeedInsertRemotePipeline.php - About 1 hr to fix

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

        public function handle(): void
        {
            $depCheck = Cache::rememberForever('video-pipeline:hls:depcheck', function() {
                $bin = config('laravel-ffmpeg.ffmpeg.binaries');
                $output = shell_exec($bin . ' -version');
    Severity: Minor
    Found in app/Jobs/VideoPipeline/VideoHlsPipeline.php - About 1 hr to fix

      Function decode_base64 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          , decode_base64 = function(base64) {
              var
                    len = base64.length
                  , buffer = new Uint8Array(len / 4 * 3 | 0)
                  , i = 0
      Severity: Minor
      Found in resources/assets/js/polyfill.js - About 1 hr to fix

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

            public function handle()
            {
                $username = $this->username;
                $headers = $this->headers;
        
        
        Severity: Minor
        Found in app/Jobs/InboxPipeline/InboxValidator.php - About 1 hr to fix

          Method settings has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function settings(Request $request)
              {
                  $cloud_storage = ConfigCacheService::get('pixelfed.cloud_storage');
                  $cloud_disk = config('filesystems.cloud');
                  $cloud_ready = ! empty(config('filesystems.disks.'.$cloud_disk.'.key')) && ! empty(config('filesystems.disks.'.$cloud_disk.'.secret'));
          Severity: Minor
          Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 1 hr to fix

            Method mimeTypeCheck has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function mimeTypeCheck($mimes)
                {
                    $allowed = explode(',', config_cache('pixelfed.media_types'));
                    $count = count($mimes);
                    $photos = 0;
            Severity: Minor
            Found in app/Http/Controllers/StatusController.php - About 1 hr to fix

              Method instanceEdit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function instanceEdit(Request $request, $id)
                  {
                      $this->validate($request, [
                          'action' => [
                              'required',
              Severity: Minor
              Found in app/Http/Controllers/Admin/AdminInstanceController.php - About 1 hr to fix

                Method cropPhoto has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function cropPhoto(Request $request)
                    {
                        abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                
                        $this->validate($request, [
                Severity: Minor
                Found in app/Http/Controllers/StoryComposeController.php - About 1 hr to fix

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

                      public function store(ProfileMigrationStoreRequest $request)
                      {
                          abort_if((bool) config_cache('federation.activitypub.enabled') === false, 404);
                          $acct = WebfingerService::rawGet($request->safe()->acct);
                          if (! $acct) {
                  Severity: Minor
                  Found in app/Http/Controllers/ProfileMigrationController.php - About 1 hr to fix

                    Method instances has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function instances(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 statusById has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Method updateFeatures has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function updateFeatures(Request $request)
                            {
                                abort_if(! $request->user(), 404);
                                abort_if(! $request->user()->is_admin, 404);
                                $pid = $request->user()->profile_id;
                        Severity: Minor
                        Found in app/Http/Controllers/DiscoverController.php - About 1 hr to fix

                          Method notifications has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function notifications(Request $request)
                              {
                                  abort_if(!$request->user(), 403);
                          
                                  $pid = $request->user()->profile_id;
                          Severity: Minor
                          Found in app/Http/Controllers/Api/BaseApiController.php - About 1 hr to fix

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

                                public function store(Request $request)
                                {
                                    abort_if(!$request->user(), 403);
                            
                                    $this->validate($request, [
                            Severity: Minor
                            Found in app/Http/Controllers/Api/V1/DomainBlockController.php - About 1 hr to fix

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

                                  public static function deleteByProfileId($profileId)
                                  {
                                      $res = Redis::zrange(self::CACHE_KEY, 0, '-1');
                                      if(!$res) {
                                          return;
                              Severity: Major
                              Found in app/Services/PublicTimelineService.php and 1 other location - About 1 hr to fix
                              app/Services/NetworkTimelineService.php on lines 73..91

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

                              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

                                      foreach ($map as $key => $value) {
                                          if(!isset($data[$value]) && !isset($data[substr($value, 1)])) {
                                              $map[$key] = false;
                                              continue;
                                          }
                              Severity: Major
                              Found in app/Services/UserRoleService.php and 1 other location - About 1 hr to fix
                              app/Services/UserRoleService.php on lines 220..226

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

                              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

                                  public static function deleteByProfileId($profileId)
                                  {
                                      $res = Redis::zrange(self::CACHE_KEY, 0, '-1');
                                      if(!$res) {
                                          return;
                              Severity: Major
                              Found in app/Services/NetworkTimelineService.php and 1 other location - About 1 hr to fix
                              app/Services/PublicTimelineService.php on lines 73..91

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

                              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

                                      foreach ($map as $key => $value) {
                                          if(!isset($data[$value]) && !isset($data[substr($value, 1)])) {
                                              $res[$key] = false;
                                              continue;
                                          }
                              Severity: Major
                              Found in app/Services/UserRoleService.php and 1 other location - About 1 hr to fix
                              app/Services/UserRoleService.php on lines 181..187

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

                              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