pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method report has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Major
Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 3 hrs to fix

    Method accountStatuses has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function accountStatuses(Request $request, $id)
        {
            $this->validate($request, [
                'only_media' => 'nullable',
                'pinned' => 'nullable',
    Severity: Major
    Found in app/Http/Controllers/PublicApiController.php - About 3 hrs to fix

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

              return collect([
                  [
                      'name' => 'ActivityPub Federation',
                      'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
                      'key' => 'federation.activitypub.enabled'
      Severity: Major
      Found in app/Http/Controllers/Api/AdminApiController.php and 1 other location - About 3 hrs to fix
      app/Http/Controllers/Api/AdminApiController.php on lines 430..464

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

      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

                      return collect([
                  [
                      'name' => 'ActivityPub Federation',
                      'description' => 'Enable activitypub federation support, compatible with Pixelfed, Mastodon and other platforms.',
                      'key' => 'federation.activitypub.enabled'
      Severity: Major
      Found in app/Http/Controllers/Api/AdminApiController.php and 1 other location - About 3 hrs to fix
      app/Http/Controllers/Api/AdminApiController.php on lines 365..399

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

      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 verifySignature has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function verifySignature($headers, $profile, $payload)
          {
              $body = $this->payload;
              $bodyDecoded = $payload;
              $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
      Severity: Minor
      Found in app/Jobs/InboxPipeline/InboxValidator.php - About 3 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 verifySignature has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function verifySignature($headers, $payload)
          {
              $body = $this->payload;
              $bodyDecoded = $payload;
              $signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
      Severity: Minor
      Found in app/Jobs/InboxPipeline/InboxWorker.php - About 3 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 storeSettings has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function storeSettings(Request $request)
          {
              abort_if(!$request->user(), 403);
      
              $this->validate($request, [
      Severity: Minor
      Found in app/Http/Controllers/PortfolioController.php - About 3 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 settingsApiUpdateStorageType has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function settingsApiUpdateStorageType($request)
          {
              $this->validate($request, [
                  'primary_disk' => 'required|in:local,cloud',
                  'update_disk' => 'sometimes',
      Severity: Minor
      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 3 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 privacyStore has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function privacyStore(Request $request)
          {
              $settings = $request->user()->settings;
              $profile = $request->user()->profile;
              $fields = [
      Severity: Minor
      Found in app/Http/Controllers/Settings/PrivacySettings.php - About 3 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

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

          public function settingsApiUpdateBrandingType($request)
          {
              $this->validate($request, [
                  'name' => 'required',
                  'short_description' => 'required',
      Severity: Major
      Found in app/Http/Controllers/Admin/AdminSettingsController.php and 1 other location - About 3 hrs to fix
      app/Http/Controllers/Admin/AdminSettingsController.php on lines 573..592

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

      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 settingsApiUpdateLandingType($request)
          {
              $this->validate($request, [
                  'current_admin' => 'required',
                  'show_directory' => 'required',
      Severity: Major
      Found in app/Http/Controllers/Admin/AdminSettingsController.php and 1 other location - About 3 hrs to fix
      app/Http/Controllers/Admin/AdminSettingsController.php on lines 629..648

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

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

          public function handle()
          {
              $activity = $this->activity;
              $activityId = $activity['id'];
              $activityActor = $activity['actor'];
      Severity: Major
      Found in app/Jobs/StoryPipeline/StoryFetch.php - About 3 hrs to fix

        File SettingsController.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Http\Controllers;
        
        use App\AccountLog;
        Severity: Minor
        Found in app/Http/Controllers/SettingsController.php - About 3 hrs to fix

          Installer has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Installer extends Command
          {
              /**
               * The name and signature of the console command.
               *
          Severity: Minor
          Found in app/Console/Commands/Installer.php - About 3 hrs to fix

            Method get has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function get()
                {
                    return Cache::remember(self::CACHE_KEY, 900, function () {
                        $hls = [
                            'enabled' => config('media.hls.enabled'),
            Severity: Major
            Found in app/Util/Site/Config.php - About 3 hrs to fix

              Method handleDeleteActivity has 79 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function handleDeleteActivity()
                  {
                      if(!isset(
                          $this->payload['actor'],
                          $this->payload['object']
              Severity: Major
              Found in app/Util/ActivityPub/Inbox.php - About 3 hrs to fix

                Method get has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function get($json = true)
                    {
                        $activeMonth = Nodeinfo::activeUsersMonthly();
                
                        $totalUsers = Cache::remember('api:nodeinfo:users', 43200, function () {
                Severity: Major
                Found in app/Services/LandingService.php - About 3 hrs to fix

                  Method apiRegister has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function apiRegister(Request $request)
                      {
                          $this->validate($request, [
                              'token' => 'required',
                              'username' => [
                  Severity: Major
                  Found in app/Http/Controllers/AdminInviteController.php - About 3 hrs to fix

                    Method mediaUpload has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method accountFollowersById has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function accountFollowersById(Request $request, $id)
                          {
                              abort_if(! $request->user() || ! $request->user()->token(), 403);
                              abort_unless($request->user()->tokenCan('read'), 403);
                      
                      
                      Severity: Major
                      Found in app/Http/Controllers/Api/ApiV1Controller.php - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language