pixelfed/pixelfed

View on GitHub

Showing 612 of 615 total issues

Method statusFirstOrFetch has 150 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function statusFirstOrFetch($url, $replyTo = false)
    {
        $url = self::validateUrl($url);
        if($url == false) {
            return;
Severity: Major
Found in app/Util/ActivityPub/Helpers.php - About 6 hrs to fix

    File InternalApiController.php has 409 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

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

          public function untagProfile(Request $request)
          {
              abort_if(!$request->user(), 403);
      
              $this->validate($request, [
      Severity: Major
      Found in app/Http/Controllers/MediaTagController.php and 1 other location - About 5 hrs to fix
      app/Http/Controllers/ComposeController.php on lines 275..306

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

      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

          public function searchUntag(Request $request)
          {
              abort_if(!$request->user(), 403);
      
              $this->validate($request, [
      Severity: Major
      Found in app/Http/Controllers/ComposeController.php and 1 other location - About 5 hrs to fix
      app/Http/Controllers/MediaTagController.php on lines 26..58

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

      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

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

          public function statusCreate(Request $request)
          {
              abort_if(!$request->user(), 403);
      
              $this->validate($request, [
      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

      Function settingsHomeStore has a Cognitive Complexity of 34 (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 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

      Profile has 38 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

        Method settingsHomeStore has 121 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function settingsHomeStore(Request $request)
            {
                $this->validate($request, [
                    'name' => 'nullable|string',
                    'short_description' => 'nullable',
        Severity: Major
        Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 4 hrs to fix

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

              public function homeTimelineApi(Request $request)
              {
                  if(!Auth::check()) {
                      return abort(403);
                  }
          Severity: Major
          Found in app/Http/Controllers/PublicApiController.php - About 4 hrs to fix

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

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

              File StatusController.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                Function handleDirectMessage has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function handleDirectMessage()
                    {
                        $activity = $this->payload['object'];
                        $actor = $this->actorFirstOrCreate($this->payload['actor']);
                        $profile = Profile::whereNull('domain')
                Severity: Minor
                Found in app/Util/ActivityPub/Inbox.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

                File Status.php has 350 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace App;
                
                use Auth, Cache, Hashids, Storage;
                Severity: Minor
                Found in app/Status.php - About 4 hrs to fix

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

                          if($max) {
                              $res = NotificationService::getMax($pid, $max, $limit);
                              $ids = NotificationService::getRankedMaxId($pid, $max, $limit);
                              if(!empty($ids)) {
                                  $maxId = max($ids);
                  Severity: Major
                  Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 4 hrs to fix
                  app/Http/Controllers/Api/BaseApiController.php on lines 75..89

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

                  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

                          if($max) {
                              $res = NotificationService::getMax($pid, $max, $limit);
                              $ids = NotificationService::getRankedMaxId($pid, $max, $limit);
                              if(!empty($ids)) {
                                  $maxId = max($ids);
                  Severity: Major
                  Found in app/Http/Controllers/Api/BaseApiController.php and 1 other location - About 4 hrs to fix
                  app/Http/Controllers/Api/ApiV1Controller.php on lines 1304..1318

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

                  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

                  Status has 34 functions (exceeds 20 allowed). Consider refactoring.
                  Open

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

                    Method statusCreate has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

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

                          public function handle()
                          {
                              $user = $this->user;
                      
                              DB::transaction(function() use ($user) {
                      Severity: Major
                      Found in app/Jobs/DeletePipeline/DeleteAccountPipeline.php - About 4 hrs to fix

                        Method handleDirectMessage has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function handleDirectMessage()
                            {
                                $activity = $this->payload['object'];
                                $actor = $this->actorFirstOrCreate($this->payload['actor']);
                                $profile = Profile::whereNull('domain')
                        Severity: Major
                        Found in app/Util/ActivityPub/Inbox.php - About 4 hrs to fix

                          Function store has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function store(Request $request)
                              {
                                  $this->validate($request, [
                                      'caption' => 'nullable|string|max:'.config('pixelfed.max_caption_length', 500),
                                      'media.*'   => 'required',
                          Severity: Minor
                          Found in app/Http/Controllers/ComposeController.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

                          Severity
                          Category
                          Status
                          Source
                          Language