pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

    public function exportFollowers()
    {
        $data = Cache::remember('account:export:profile:followers:'.Auth::user()->profile->id, now()->addMinutes(60), function() {
            return Auth::user()->profile->followers()->get()->map(function($i) {
                return $i->url();
Severity: Major
Found in app/Http/Controllers/Settings/ExportSettings.php and 1 other location - About 1 hr to fix
app/Http/Controllers/Settings/ExportSettings.php on lines 51..63

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

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

  function fixFileAndXHR () {
    var isIE = !!global.ActiveXObject || (
      '-ms-scroll-limit' in document.documentElement.style &&
      '-ms-ime-align' in document.documentElement.style
    )
Severity: Minor
Found in resources/assets/js/polyfill.js - About 1 hr to fix

    Method handleCreateActivity has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handleCreateActivity()
        {
            $activity = $this->payload['object'];
            if(config('autospam.live_filters.enabled')) {
                $filters = config('autospam.live_filters.filters');
    Severity: Minor
    Found in app/Util/ActivityPub/Inbox.php - About 1 hr to fix

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

          public function handle()
          {
              $profile = $this->profile;
              $pid = $profile->id;
      
      
      Severity: Minor
      Found in app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php - About 1 hr to fix

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

            public function handle()
            {
                $status = $this->status;
                $comment = $this->comment;
        
        
        Severity: Minor
        Found in app/Jobs/CommentPipeline/CommentPipeline.php - About 1 hr to fix

          Method userEditSubmit has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function userEditSubmit(Request $request, $id)
              {
                  $user = User::findOrFail($id);
                  $profile = $user->profile;
                  $changed = false;
          Severity: Minor
          Found in app/Http/Controllers/Admin/AdminUserController.php - About 1 hr to fix

            Method getAllStats has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getAllStats(Request $request)
                {
                    abort_if(!$request->user() || !$request->user()->token(), 404);
            
                    abort_unless($request->user()->is_admin === 1, 404);
            Severity: Minor
            Found in app/Http/Controllers/Api/AdminApiController.php - About 1 hr to fix

              Method getPosts has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function getPosts()
                  {
                      $tag = $this->term;
                      $hash = hash('sha256', $tag);
                      if (Helpers::validateUrl($tag) != false &&
              Severity: Minor
              Found in app/Http/Controllers/SearchController.php - About 1 hr to fix

                Method composeLookup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function composeLookup(Request $request)
                    {
                        $this->validate($request, [
                            'q' => 'required|string|min:2|max:50',
                            'remote' => 'nullable',
                Severity: Minor
                Found in app/Http/Controllers/DirectMessageController.php - About 1 hr to fix

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

                      public function handle()
                      {
                          $path = $this->argument('path');
                  
                          if (!file_exists($path) || !mime_content_type($path) == 'application/x-tar') {
                  Severity: Minor
                  Found in app/Console/Commands/ImportEmojis.php - About 1 hr to fix

                    Function get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function get(Status $status)
                        {
                            if($status->uri || $status->scope != 'public') {
                                return;
                            }
                    Severity: Minor
                    Found in app/Util/Sentiment/Bouncer.php - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function handle()
                        {
                            $actor = $this->actor;
                            $target = $this->target;
                    
                    
                    Severity: Minor
                    Found in app/Jobs/FollowPipeline/UnfollowPipeline.php - About 1 hr 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 toArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function toArray(Request $request): array
                        {
                            $instance = parse_url($this->uri, PHP_URL_HOST);
                            $statuses = [];
                            if($this->status_ids && count($this->status_ids)) {
                    Severity: Minor
                    Found in app/Http/Resources/AdminRemoteReport.php - About 1 hr 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 labsStore has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function labsStore(Request $request)
                        {
                            $this->validate($request, [
                                'profile_layout' => 'nullable',
                                'dark_mode'    => 'nullable',
                    Severity: Minor
                    Found in app/Http/Controllers/Settings/LabsSettings.php - About 1 hr 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 report has a Cognitive Complexity of 15 (exceeds 5 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: Minor
                    Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 1 hr 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 transform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function transform(Notification $notification)
                        {
                            $res = [
                                'id' => (string) $notification->id,
                                'type' => $this->replaceTypeVerb($notification->action),
                    Severity: Minor
                    Found in app/Transformer/Api/NotificationTransformer.php - About 1 hr 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 buildPath has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function buildPath($id)
                        {
                            $padded = str_pad($id, 19, 0, STR_PAD_LEFT);
                            $parts = str_split($padded, 3);
                            foreach ($parts as $k => $part) {
                    Severity: Minor
                    Found in app/Http/Controllers/AvatarController.php - About 1 hr 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

                        protected function filterCreate(UserFilter $userFilter)
                        {
                            if($userFilter->filterable_type !== 'App\Profile') {
                                return;
                            }
                    Severity: Major
                    Found in app/Observers/UserFilterObserver.php and 1 other location - About 1 hr to fix
                    app/Observers/UserFilterObserver.php on lines 94..111

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

                    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 5 locations. Consider refactoring.
                    Open

                            if (config_cache('pixelfed.enforce_account_limit') == true) {
                                $size = Cache::remember($user->storageUsedKey(), now()->addDays(3), function () use ($user) {
                                    return Media::whereUserId($user->id)->sum('size') / 1000;
                                });
                                $limit = (int) config_cache('pixelfed.max_account_size');
                    Severity: Major
                    Found in app/Http/Controllers/ComposeController.php and 4 other locations - About 1 hr to fix
                    app/Http/Controllers/Api/ApiV1Controller.php on lines 1757..1765
                    app/Http/Controllers/Api/ApiV1Controller.php on lines 1974..1982
                    app/Http/Controllers/Api/ApiV2Controller.php on lines 249..257
                    app/Http/Controllers/DirectMessageController.php on lines 603..611

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

                    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 5 locations. Consider refactoring.
                    Open

                            if(config_cache('pixelfed.enforce_account_limit') == true) {
                                $size = Cache::remember($user->storageUsedKey(), now()->addDays(3), function() use($user) {
                                    return Media::whereUserId($user->id)->sum('size') / 1000;
                                });
                                $limit = (int) config_cache('pixelfed.max_account_size');
                    Severity: Major
                    Found in app/Http/Controllers/DirectMessageController.php and 4 other locations - About 1 hr to fix
                    app/Http/Controllers/Api/ApiV1Controller.php on lines 1757..1765
                    app/Http/Controllers/Api/ApiV1Controller.php on lines 1974..1982
                    app/Http/Controllers/Api/ApiV2Controller.php on lines 249..257
                    app/Http/Controllers/ComposeController.php on lines 87..95

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language