pixelfed/pixelfed

View on GitHub

Showing 1,323 of 1,558 total issues

File ApiV2Controller.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
Severity: Minor
Found in app/Http/Controllers/Api/ApiV2Controller.php - About 2 hrs to fix

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

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

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

          public function handle(): void
          {
              $spamExists = Storage::exists(AutospamService::MODEL_SPAM_PATH);
              if($spamExists) {
                  $spam = json_decode(Storage::get(AutospamService::MODEL_SPAM_PATH), true);
      Severity: Major
      Found in app/Jobs/AutospamPipeline/AutospamUpdateCachedDataPipeline.php - About 2 hrs to fix

        Method searchLocation has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function searchLocation(Request $request)
            {
                abort_if(! $request->user(), 403);
                $this->validate($request, [
                    'q' => 'required|string|max:100',
        Severity: Major
        Found in app/Http/Controllers/ComposeController.php - About 2 hrs to fix

          Method storeText has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function storeText(Request $request)
              {
                  abort_unless(config('exp.top'), 404);
                  $this->validate($request, [
                      'caption' => 'nullable|string|max:'.config_cache('pixelfed.max_caption_length', 500),
          Severity: Major
          Found in app/Http/Controllers/ComposeController.php - About 2 hrs to fix

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

                public function handle()
                {
                    if(config_cache('pixelfed.import.instagram.enabled') != true) {
                        return;
                    }
            Severity: Major
            Found in app/Jobs/ImportPipeline/ImportInstagram.php - About 2 hrs to fix

              Method roleData has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function roleData()
                  {
                      return [
                          'account-force-private' => [
                              'title' => 'Force Private Account',
              Severity: Major
              Found in app/Services/UserRoleService.php - About 2 hrs to fix

                Method instance has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function instance(Request $request)
                    {
                        $res = Cache::remember('api:v1:instance-data-response-v1', 1800, function () {
                            $contact = Cache::remember('api:v1:instance-data:contact', 604800, function () {
                                if (config_cache('instance.admin.pid')) {
                Severity: Major
                Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix

                  Method getProfiles has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function getProfiles()
                      {
                          $tag = $this->term;
                          $remoteKey = $this->cacheKey.'profiles:remote:'.$this->hash;
                          $key = $this->cacheKey.'profiles:'.$this->hash;
                  Severity: Major
                  Found in app/Http/Controllers/SearchController.php - About 2 hrs to fix

                    Method handleSubmit has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method getActor has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getActor()
                          {
                              return [
                                  "@context" => [
                                      "https://www.w3.org/ns/activitystreams",
                      Severity: Major
                      Found in app/Models/InstanceActor.php - About 2 hrs to fix

                        Function handleVerb has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handleVerb()
                            {
                                $verb = (string) $this->payload['type'];
                                switch ($verb) {
                        
                        
                        Severity: Minor
                        Found in app/Util/ActivityPub/Inbox.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 handleImageTransform has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handleImageTransform(Media $media, $thumbnail = false)
                            {
                                $path = $media->media_path;
                                $file = storage_path('app/'.$path);
                                if (!in_array($media->mime, $this->acceptedMimes)) {
                        Severity: Minor
                        Found in app/Util/Media/Image.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 formStore has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function formStore(Request $request)
                            {
                                $this->validate($request, [
                                    'report'  => 'required|alpha_dash',
                                    'type'    => 'required|alpha_dash',
                        Severity: Minor
                        Found in app/Http/Controllers/ReportController.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 homeUpdate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function homeUpdate(Request $request)
                            {
                                $this->validate($request, [
                                    'name'    => 'nullable|string|max:'.config('pixelfed.max_name_length'),
                                    'bio'     => 'nullable|string|max:'.config('pixelfed.max_bio_length'),
                        Severity: Minor
                        Found in app/Http/Controllers/Settings/HomeSettings.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 show has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function show(Request $request, $username, $id)
                            {
                                // redirect authed users to Metro 2.0
                                if ($request->user()) {
                                    // unless they force static view
                        Severity: Minor
                        Found in app/Http/Controllers/StatusController.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 handle has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function handle()
                            {
                                if(config('filesystems.default') !== 'local') {
                                    $this->error('Invalid default filesystem, set FILESYSTEM_DRIVER=local to proceed');
                                    return Command::SUCCESS;
                        Severity: Minor
                        Found in app/Console/Commands/FixMediaDriver.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

                        Method validator has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function validator(array $data)
                            {
                                if(config('database.default') == 'pgsql') {
                                    $data['username'] = strtolower($data['username']);
                                    $data['email'] = strtolower($data['email']);
                        Severity: Major
                        Found in app/Http/Controllers/Auth/RegisterController.php - About 2 hrs to fix

                          Function stringDecode has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function stringDecode (buf) {
                              var end = buf.length
                              var res = []
                          
                              var i = 0
                          Severity: Major
                          Found in resources/assets/js/polyfill.js - About 2 hrs to fix

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

                                public function handle()
                                {
                                    $id = search(
                                        label: 'Search for the account to delete by username',
                                        placeholder: 'john.appleseed',
                            Severity: Major
                            Found in app/Console/Commands/UserAccountDelete.php - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language