pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Method comment has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function comment(Request $request)
    {
        abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
        $this->validate($request, [
            'sid' => 'required',
Severity: Major
Found in app/Http/Controllers/Stories/StoryApiV1Controller.php - About 2 hrs to fix

    Function getMaxMastodon has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getMaxMastodon($id = false, $start = 0, $limit = 10)
        {
            $ids = self::getRankedMaxId($id, $start, $limit);
    
            if (empty($ids)) {
    Severity: Minor
    Found in app/Services/NotificationService.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 updateUrls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateUrls()
        {
            $this->info('Updating urls...');
            $oldDomain = trim($this->argument('oldDomain'));
            $newDomain = trim($this->argument('newDomain'));
    Severity: Minor
    Found in app/Console/Commands/MediaCloudUrlRewrite.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

    File AdminUserController.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace App\Http\Controllers\Admin;
    
    use Cache, DB;
    Severity: Minor
    Found in app/Http/Controllers/Admin/AdminUserController.php - About 2 hrs to fix

      File ImportPostController.php has 267 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/ImportPostController.php - About 2 hrs to fix

        Method settingsApiUpdatePlatformType has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function settingsApiUpdatePlatformType($request)
            {
                $this->validate($request, [
                    'allow_app_registration' => 'required',
                    'app_registration_rate_limit_attempts' => 'required|integer|min:1',
        Severity: Major
        Found in app/Http/Controllers/Admin/AdminSettingsController.php - About 2 hrs to fix

          Method comment has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function comment(Request $request)
              {
                  abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                  $this->validate($request, [
                      'sid' => 'required',
          Severity: Major
          Found in app/Http/Controllers/StoryComposeController.php - About 2 hrs to fix

            File home.blade.php has 266 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            @extends('admin.partial.template-full')
            
            @section('section')
            <div class="title d-flex justify-content-between align-items-center">
                <h3 class="font-weight-bold">Users</h3>
            Severity: Minor
            Found in resources/views/admin/users/home.blade.php - About 2 hrs to fix

              Method handleFollowActivity has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function handleFollowActivity()
                  {
                      $actor = $this->actorFirstOrCreate($this->payload['actor']);
                      $target = $this->actorFirstOrCreate($this->payload['object']);
                      if(!$actor || !$target) {
              Severity: Major
              Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

                Method getInstancesApi has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getInstancesApi(Request $request)
                    {
                        $this->validate($request, [
                            'filter' => [
                                'nullable',
                Severity: Major
                Found in app/Http/Controllers/Admin/AdminInstanceController.php - About 2 hrs to fix

                  Method transform has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function transform(Profile $profile)
                      {
                          if (! $profile) {
                              return [];
                          }
                  Severity: Major
                  Found in app/Transformer/Api/AccountTransformer.php - About 2 hrs to fix

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

                        public function apiV1Delete(Request $request, $id)
                        {
                            abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                    
                            $user = $request->user();
                    Severity: Major
                    Found in app/Http/Controllers/StoryComposeController.php and 1 other location - About 2 hrs to fix
                    app/Http/Controllers/Stories/StoryApiV1Controller.php on lines 341..358

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

                    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 delete(Request $request, $id)
                        {
                            abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
                    
                            $user = $request->user();
                    Severity: Major
                    Found in app/Http/Controllers/Stories/StoryApiV1Controller.php and 1 other location - About 2 hrs to fix
                    app/Http/Controllers/StoryComposeController.php on lines 197..214

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

                    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

                    Helpers has 22 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Helpers
                    {
                        public static function validateObject($data)
                        {
                            $verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo', 'Tombstone'];
                    Severity: Minor
                    Found in app/Util/ActivityPub/Helpers.php - About 2 hrs to fix

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

                          public function handle()
                          {
                              $id = $this->profileId;
                      
                              if(Cache::has(FollowerService::FOLLOWERS_SYNC_KEY . $id) && Cache::has(FollowerService::FOLLOWING_SYNC_KEY . $id)) {
                      Severity: Major
                      Found in app/Jobs/FollowPipeline/FollowServiceWarmCache.php - About 2 hrs to fix

                        Method remoteToCloud has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function remoteToCloud($media)
                            {
                                $url = $media->remote_url;
                        
                                if (! Helpers::validateUrl($url)) {
                        Severity: Major
                        Found in app/Services/MediaStorageService.php - About 2 hrs to fix

                          Method unlinkRemoveMedia has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function unlinkRemoveMedia($status)
                              {
                                  Media::whereStatusId($status->id)
                                      ->get()
                                      ->each(function ($media) {
                          Severity: Major
                          Found in app/Jobs/StatusPipeline/StatusDelete.php - About 2 hrs to fix

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

                                public static function get($domain)
                                {
                                    $version = config('pixelfed.version');
                                    $appUrl = config('app.url');
                                    $headers = [
                            Severity: Major
                            Found in app/Services/NodeinfoService.php - About 2 hrs to fix

                              Method delete has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function delete(Request $request)
                                  {
                                      $this->authCheck();
                              
                                      $this->validate($request, [
                              Severity: Major
                              Found in app/Http/Controllers/StatusController.php - About 2 hrs to fix

                                Method homeUpdate has 58 lines of code (exceeds 25 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: Major
                                Found in app/Http/Controllers/Settings/HomeSettings.php - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language