pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Function resolveQuery has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

    protected function resolveQuery()
    {
        $default = [
            'accounts' => [],
            'hashtags' => [],
Severity: Minor
Found in app/Services/SearchApiV2Service.php - About 1 day 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

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

        $usernameRules = [
            'required',
            'min:2',
            'max:15',
            'unique:users',
Severity: Major
Found in app/Http/Controllers/Auth/RegisterController.php and 1 other location - About 1 day to fix
app/Http/Controllers/AdminInviteController.php on lines 64..100

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

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

        $usernameRules = [
            'required',
            'min:2',
            'max:15',
            'unique:users',
Severity: Major
Found in app/Http/Controllers/AdminInviteController.php and 1 other location - About 1 day to fix
app/Http/Controllers/Auth/RegisterController.php on lines 70..106

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

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

    public static function statusFirstOrFetch($url, $replyTo = false)
    {
        $url = self::validateUrl($url);
        if ($url == false) {
            return;
Severity: Minor
Found in app/Util/ActivityPub/Helpers.php - About 1 day 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 3 locations. Consider refactoring.
Open

            'username' => [
                'required',
                'min:2',
                'max:15',
                'unique:users',
Severity: Major
Found in app/Http/Controllers/AdminInviteController.php and 2 other locations - About 1 day to fix
app/Http/Controllers/Api/ApiV1Dot1Controller.php on lines 507..543
app/Http/Controllers/RemoteAuthController.php on lines 489..525

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

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

            'username' => [
                'required',
                'min:2',
                'max:15',
                'unique:users',
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php and 2 other locations - About 1 day to fix
app/Http/Controllers/AdminInviteController.php on lines 152..188
app/Http/Controllers/RemoteAuthController.php on lines 489..525

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

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

            'username' => [
                'required',
                'min:2',
                'max:15',
                'unique:users,username',
Severity: Major
Found in app/Http/Controllers/RemoteAuthController.php and 2 other locations - About 1 day to fix
app/Http/Controllers/Api/ApiV1Dot1Controller.php on lines 507..543
app/Http/Controllers/AdminInviteController.php on lines 152..188

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

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 static function getMaxMastodon($id = false, $start = 0, $limit = 10)
    {
        $ids = self::getRankedMaxId($id, $start, $limit);

        if (empty($ids)) {
Severity: Major
Found in app/Services/NotificationService.php and 1 other location - About 1 day to fix
app/Services/NotificationService.php on lines 152..186

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

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 static function getMinMastodon($id = false, $start = 0, $limit = 10)
    {
        $ids = self::getRankedMinId($id, $start, $limit);

        if (empty($ids)) {
Severity: Major
Found in app/Services/NotificationService.php and 1 other location - About 1 day to fix
app/Services/NotificationService.php on lines 116..150

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

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

File polyfill.js has 634 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Blob.js
 * A Blob, File, FileReader & URL implementation.
 * 2019-04-19
 *
 * By Eli Grey, http://eligrey.com
Severity: Major
Found in resources/assets/js/polyfill.js - About 1 day to fix

    File RemoteAuthController.php has 605 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace App\Http\Controllers;
    
    use App\Models\RemoteAuth;
    Severity: Major
    Found in app/Http/Controllers/RemoteAuthController.php - About 1 day to fix

      Function reportsApiRemoteHandle has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
      Open

          public function reportsApiRemoteHandle(Request $request)
          {
              $this->validate($request, [
                  'id' => 'required|exists:remote_reports,id',
                  'action' => 'required|in:mark-read,cw-posts,unlist-posts,delete-posts,private-posts,mark-all-read-by-domain,mark-all-read-by-username,cw-all-posts,private-all-posts,unlist-all-posts'
      Severity: Minor
      Found in app/Http/Controllers/Admin/AdminReportController.php - About 1 day 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 moderatePost has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
      Open

          public function moderatePost(Request $request, $id)
          {
              abort_if(!$request->user() || !$request->user()->token(), 403);
              abort_if($request->user()->is_admin != true, 403);
              abort_unless($request->user()->tokenCan('admin:write'), 403);
      Severity: Minor
      Found in app/Http/Controllers/Api/ApiV1Dot1Controller.php - About 1 day 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 browse has 253 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function browse(Request $request)
          {
              $this->validate($request, [
                  'a' => 'nullable|string|in:inbox,sent,filtered',
                  'page' => 'nullable|integer|min:1|max:99'
      Severity: Major
      Found in app/Http/Controllers/DirectMessageController.php - About 1 day to fix

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

                    $res = Status::select(
                        'id',
                        'profile_id',
                        'type',
                        'visibility',
        Severity: Major
        Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 day to fix
        app/Http/Controllers/Api/ApiV1Controller.php on lines 2529..2567

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

        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

                    $res = Status::select(
                        'id',
                        'profile_id',
                        'type',
                        'visibility',
        Severity: Major
        Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 1 day to fix
        app/Http/Controllers/Api/ApiV1Controller.php on lines 2474..2513

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

        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

        File AccountController.php has 570 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace App\Http\Controllers;
        
        use Auth;
        Severity: Major
        Found in app/Http/Controllers/AccountController.php - About 1 day to fix

          Method timelinePublic has 234 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function timelinePublic(Request $request)
              {
                  $this->validate($request, [
                      'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
                      'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
          Severity: Major
          Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

            ApiV1Controller has 64 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ApiV1Controller extends Controller
            {
                protected $fractal;
            
                const PF_API_ENTITY_KEY = '_pe';
            Severity: Major
            Found in app/Http/Controllers/Api/ApiV1Controller.php - About 1 day to fix

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

                      if (config('database.default') == 'pgsql') {
                          $s = Cache::remember(self::RECENT_KEY.$pid, self::RECENT_TTL, function () use ($pid) {
                              return Story::select('stories.*', 'followers.following_id')
                                  ->leftJoin('followers', 'followers.following_id', 'stories.profile_id')
                                  ->where('followers.profile_id', $pid)
              Severity: Major
              Found in app/Http/Controllers/Stories/StoryApiV1Controller.php and 1 other location - About 1 day to fix
              app/Http/Controllers/Stories/StoryApiV1Controller.php on lines 148..174

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

              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