pixelfed/pixelfed

View on GitHub

Showing 1,329 of 1,562 total issues

Function publicTimelineApi has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function publicTimelineApi(Request $request)
    {
        $this->validate($request,[
          'page'        => 'nullable|integer|max:40',
          'min_id'      => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
Severity: Minor
Found in app/Http/Controllers/PublicApiController.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 networkTimelineApi has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function networkTimelineApi(Request $request)
    {
        if(!$request->user()) {
            return response('', 403);
        }
Severity: Minor
Found in app/Http/Controllers/PublicApiController.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 browse has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function browse(Request $request)
    {
        $this->validate($request, [
            'a' => 'nullable|string|in:inbox,sent,filtered',
            'page' => 'nullable|integer|min:1|max:99'
Severity: Minor
Found in app/Http/Controllers/DirectMessageController.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 app.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require('./polyfill');
window._ = require('lodash');
window.Popper = require('popper.js').default;
window.pixelfed = window.pixelfed || {};
window.$ = window.jQuery = require('jquery');
Severity: Minor
Found in resources/assets/js/app.js - About 2 hrs to fix

    File landing.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require('./polyfill');
    import Vue from 'vue';
    window.Vue = Vue;
    import VueRouter from "vue-router";
    import Vuex from "vuex";
    Severity: Minor
    Found in resources/assets/js/landing.js - About 2 hrs to fix

      Method handleVerb has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handleVerb()
          {
              $verb = (string) $this->payload['type'];
              switch ($verb) {
      
      
      Severity: Major
      Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

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

            public function handle()
            {
                $profile = null;
                $headers = $this->headers;
                $payload = json_decode($this->payload, true, 8);
        Severity: Major
        Found in app/Jobs/InboxPipeline/DeleteWorker.php - About 2 hrs to fix

          Method getJson has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getJson($url, $verifyCheck = true, $ttl = 3600, $allowRedirects = true)
              {
                  $vc = $verifyCheck ? 'vc1:' : 'vc0:';
                  $ar = $allowRedirects ? 'ar1:' : 'ar0';
                  $key = self::CACHE_KEY.sha1($url).':'.$vc.$ar.$ttl;
          Severity: Major
          Found in app/Services/FetchCacheService.php - About 2 hrs to fix

            Method directoryStore has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function directoryStore(Request $request)
                {
                    $this->validate($request, [
                        'location' => 'string|min:1|max:53',
                        'summary' => 'string|nullable|max:140',
            Severity: Major
            Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 2 hrs to fix

              Method showEmbed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function showEmbed(Request $request, $username, int $id)
                  {
                      if (! (bool) config_cache('instance.embed.post')) {
                          $res = view('status.embed-removed');
              
              
              Severity: Major
              Found in app/Http/Controllers/StatusController.php - About 2 hrs to fix

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

                    public function transform(Status $status)
                    {
                        $pid = request()->user()->profile_id;
                        $taggedPeople = MediaTagService::get($status->id);
                        $poll = $status->type === 'poll' ? PollService::get($status->id, $pid) : null;
                Severity: Major
                Found in app/Transformer/Api/StatusTransformer.php - About 2 hrs to fix

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

                      public function handle()
                      {
                          $old_memory_limit = ini_get('memory_limit');
                          ini_set('memory_limit', '256M');
                          $path = storage_path('app/cities.json');
                  Severity: Major
                  Found in app/Console/Commands/ImportCities.php - About 2 hrs to fix

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

                        public function handle()
                        {
                            $enabled = (bool) config_cache('pixelfed.cloud_storage');
                            if(!$enabled) {
                                $this->error('Cloud storage not enabled. Exiting...');
                    Severity: Major
                    Found in app/Console/Commands/CloudMediaMigrate.php - About 2 hrs to fix

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

                          public function handle(): void
                          {
                              if ($this->batch()->cancelled()) {
                                  return;
                              }

                        Method getVerifyCredentials has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function getVerifyCredentials($key, $secret, $region, $bucket, $endpoint)
                            {
                                $client = new S3Client([
                                    'version' => 'latest',
                                    'region' => $region,
                        Severity: Minor
                        Found in app/Services/FilesystemService.php - About 2 hrs to fix

                          Consider simplifying this complex logical expression.
                          Open

                                      if(
                                          !$json ||
                                          !isset($json['id']) ||
                                          !isset($json['type']) ||
                                          $json['type'] !== 'Emoji' ||
                          Severity: Critical
                          Found in app/Services/CustomEmojiService.php - About 2 hrs to fix

                            Method getRequirements has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function getRequirements()
                                {
                                    abort_if(file_exists(base_path('.env')), 404);
                                    $reqs = [];
                            
                            
                            Severity: Minor
                            Found in app/Http/Controllers/InstallController.php - About 2 hrs to fix

                              Method updateConfiguration has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function updateConfiguration(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 2 hrs to fix

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

                                    public function handle()
                                    {
                                        $status = $this->status;
                                        $actor = $status->profile;
                                        $reply = Status::find($status->in_reply_to_id);
                                Severity: Minor
                                Found in app/Jobs/StatusPipeline/StatusReplyPipeline.php - About 1 hr to fix

                                  Method remoteAnnounceDeliver has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function remoteAnnounceDeliver()
                                      {
                                          if (config('app.env') !== 'production' || (bool) config_cache('federation.activitypub.enabled') == false) {
                                              $status->delete();
                                  
                                  
                                  Severity: Minor
                                  Found in app/Jobs/SharePipeline/UndoSharePipeline.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language