pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

    public function accountFollowingById(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

    Function normalizeAudience has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function normalizeAudience($data, $localOnly = true)
        {
            if (! isset($data['to'])) {
                return;
            }
    Severity: Minor
    Found in app/Util/ActivityPub/Helpers.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 encode has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function encode(array $image, int $components_x = 4, int $components_y = 4, bool $linear = false): string {
            if (($components_x < 1 || $components_x > 9) || ($components_y < 1 || $components_y > 9)) {
                throw new InvalidArgumentException("x and y component counts must be between 1 and 9 inclusive.");
            }
            $height = count($image);
    Severity: Minor
    Found in app/Util/Blurhash/Blurhash.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 22 (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/DeleteWorker.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

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

        public static function get(Status $status)
        {
            if($status->uri || $status->scope != 'public') {
                return;
            }
    Severity: Major
    Found in app/Util/Sentiment/Bouncer.php - About 3 hrs to fix

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

          public function handle()
          {
              $res = $this->activity;
              $status = $this->status;
      
      
      Severity: Major
      Found in app/Jobs/StatusPipeline/StatusTagsPipeline.php - About 3 hrs to fix

        Method formStore has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function formStore(Request $request)
            {
                $this->validate($request, [
                    'report'  => 'required|alpha_dash',
                    'type'    => 'required|alpha_dash',
        Severity: Major
        Found in app/Http/Controllers/ReportController.php - About 3 hrs to fix

          Method statusFavouritedBy has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function statusFavouritedBy(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

            Method apiActivityLog has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function apiActivityLog(Request $request, $id)
                {
                    $record = CuratedRegister::findOrFail($id);
            
                    $res = collect([
            Severity: Major
            Found in app/Http/Controllers/AdminCuratedRegisterController.php - About 3 hrs to fix

              Method redirect has 76 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function redirect(Request $request)
                  {
                      abort_unless((
                          config_cache('pixelfed.open_registration') &&
                          config('remote-auth.mastodon.enabled')
              Severity: Major
              Found in app/Http/Controllers/RemoteAuthController.php - About 3 hrs to fix

                AccountController has 26 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class AccountController extends Controller
                {
                    protected $filters = [
                        'user.mute',
                        'user.block',
                Severity: Minor
                Found in app/Http/Controllers/AccountController.php - About 3 hrs to fix

                  Method statusReplies has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method thread has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function thread(Request $request)
                        {
                            $this->validate($request, [
                                'pid' => 'required'
                            ]);
                    Severity: Major
                    Found in app/Http/Controllers/DirectMessageController.php - About 3 hrs to fix

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

                          public function blockedUsersUpdate(Request $request)
                          {
                              $this->validate($request, [
                                  'profile_id' => 'required|integer|min:1',
                              ]);
                      Severity: Major
                      Found in app/Http/Controllers/Settings/PrivacySettings.php and 1 other location - About 2 hrs to fix
                      app/Http/Controllers/Settings/PrivacySettings.php on lines 107..125

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

                      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 mutedUsersUpdate(Request $request)
                          {
                              $this->validate($request, [
                                  'profile_id' => 'required|integer|min:1',
                              ]);
                      Severity: Major
                      Found in app/Http/Controllers/Settings/PrivacySettings.php and 1 other location - About 2 hrs to fix
                      app/Http/Controllers/Settings/PrivacySettings.php on lines 136..154

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

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

                          public function settingsApiUpdateStorageType($request)
                          {
                              $this->validate($request, [
                                  'primary_disk' => 'required|in:local,cloud',
                                  'update_disk' => 'sometimes',
                      Severity: Major
                      Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

                        Method block has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function block(Request $request)
                            {
                                $this->validate($request, [
                                    'type' => 'required|string|in:user',
                                    'item' => 'required|integer|min:1',
                        Severity: Major
                        Found in app/Http/Controllers/AccountController.php - About 2 hrs to fix

                          Method statusRebloggedBy has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

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

                                public function handle()
                                {
                                    $this->info('Pixelfed Avatar Storage Manager');
                                    $this->line(' ');
                                    $segments = [
                            Severity: Major
                            Found in app/Console/Commands/AvatarStorage.php - About 2 hrs to fix

                              File AdminCuratedRegisterController.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              <?php
                              
                              namespace App\Http\Controllers;
                              
                              use App\Mail\CuratedRegisterAcceptUser;
                              Severity: Minor
                              Found in app/Http/Controllers/AdminCuratedRegisterController.php - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language