pixelfed/pixelfed

View on GitHub

Showing 1,326 of 1,561 total issues

Function settingsHomeStore has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public function settingsHomeStore(Request $request)
    {
        $this->validate($request, [
            'name' => 'nullable|string',
            'short_description' => 'nullable',
Severity: Minor
Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 6 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 store has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function store(Request $request)
    {
        $this->validate($request, [
            'caption' => 'nullable|string|max:'.config_cache('pixelfed.max_caption_length', 500),
            'media.*' => 'required',
Severity: Major
Found in app/Http/Controllers/ComposeController.php - About 5 hrs to fix

    Function handleDeleteActivity has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        public function handleDeleteActivity()
        {
            if(!isset(
                $this->payload['actor'],
                $this->payload['object']
    Severity: Minor
    Found in app/Util/ActivityPub/Inbox.php - About 5 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 StatusController.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace App\Http\Controllers;
    
    use App\AccountInterstitial;
    Severity: Minor
    Found in app/Http/Controllers/StatusController.php - About 5 hrs to fix

      File InternalApiController.php has 396 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace App\Http\Controllers;
      
      use Illuminate\Http\Request;
      Severity: Minor
      Found in app/Http/Controllers/InternalApiController.php - About 5 hrs to fix

        Method resolveQuery has 137 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function resolveQuery()
            {
                $default = [
                    'accounts' => [],
                    'hashtags' => [],
        Severity: Major
        Found in app/Services/SearchApiV2Service.php - About 5 hrs to fix

          Method homeTimelineApi has 134 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function homeTimelineApi(Request $request)
              {
                  if(!$request->user()) {
                      return response('', 403);
                  }
          Severity: Major
          Found in app/Http/Controllers/PublicApiController.php - About 5 hrs to fix

            Method publicTimelineApi has 132 lines of code (exceeds 25 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: Major
            Found in app/Http/Controllers/PublicApiController.php - About 5 hrs to fix

              Function timelinePublic has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function timelinePublic(Request $request)
                  {
                      $this->validate($request, [
                          'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                          'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
              Severity: Minor
              Found in app/Http/Controllers/Api/ApiV1Controller.php - About 5 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 AdminDirectoryController.php has 382 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace App\Http\Controllers\Admin;
              
              use App\Http\Controllers\PixelfedDirectoryController;
              Severity: Minor
              Found in app/Http/Controllers/Admin/AdminDirectoryController.php - About 5 hrs to fix

                Profile has 39 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Profile extends Model
                {
                    use HasSnowflakePrimary, SoftDeletes;
                
                    /**
                Severity: Minor
                Found in app/Profile.php - About 5 hrs to fix

                  Function handleFlagActivity has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleFlagActivity()
                      {
                          if(!isset(
                              $this->payload['id'],
                              $this->payload['type'],
                  Severity: Minor
                  Found in app/Util/ActivityPub/Inbox.php - About 5 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 timelineHome has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function timelineHome(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 5 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 127 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function get($key)
                      {
                          $cacheKey = self::CACHE_KEY.$key;
                          $ttl = now()->addHours(12);
                          if (! config('instance.enable_cc')) {
                  Severity: Major
                  Found in app/Services/ConfigCacheService.php - About 5 hrs to fix

                    Method autospamHandle has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function autospamHandle(Request $request)
                        {
                            abort_if(!$request->user() || !$request->user()->token(), 404);
                    
                            abort_unless($request->user()->is_admin == 1, 404);
                    Severity: Major
                    Found in app/Http/Controllers/Api/AdminApiController.php - About 5 hrs to fix

                      Method updateSpam has 124 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function updateSpam(Request $request, $id)
                          {
                              $this->validate($request, [
                                  'action' => 'required|in:dismiss,approve,dismiss-all,approve-all,delete-account,mark-spammer',
                              ]);
                      Severity: Major
                      Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 hrs to fix

                        Method reportsHandleStatusAction has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function reportsHandleStatusAction($report, $action)
                            {
                                switch ($action) {
                                    case 'ignore':
                                        Report::whereObjectId($report->object_id)
                        Severity: Major
                        Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 hrs to fix

                          Function reportsHandleProfileAction has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function reportsHandleProfileAction($report, $action)
                              {
                                  switch ($action) {
                                      case 'ignore':
                                          Report::whereObjectId($report->object_id)
                          Severity: Minor
                          Found in app/Http/Controllers/Admin/AdminReportController.php - About 4 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 transform has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function transform(Status $status)
                              {
                                  $mentions = $status->mentions->map(function ($mention) {
                                      $webfinger = $mention->emailUrl();
                                      $name = Str::startsWith($webfinger, '@') ? 
                          Severity: Major
                          Found in app/Transformer/ActivityPub/Verb/CreateNote.php - About 4 hrs to fix

                            File DiscoverController.php has 370 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            namespace App\Http\Controllers;
                            
                            use App\Hashtag;
                            Severity: Minor
                            Found in app/Http/Controllers/DiscoverController.php - About 4 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language