pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

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

        if ($author && $res->hasPages()) {
            $links = '';

            if ($res->onFirstPage()) {
                if ($res->nextPageUrl()) {
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 2 hrs to fix
app/Http/Controllers/Api/ApiV1Controller.php on lines 3157..3177

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

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

        if ($author && $res->hasPages()) {
            $links = '';
            if ($res->onFirstPage()) {
                if ($res->nextPageUrl()) {
                    $links = '<'.$res->nextPageUrl().'>; rel="prev"';
Severity: Major
Found in app/Http/Controllers/Api/ApiV1Controller.php and 1 other location - About 2 hrs to fix
app/Http/Controllers/Api/ApiV1Controller.php on lines 3257..3278

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

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

        foreach ($tagged as $tg) {
            $mt = new MediaTag;
            $mt->status_id = $status->id;
            $mt->media_id = $status->media->first()->id;
            $mt->profile_id = $tg['id'];
Severity: Major
Found in app/Http/Controllers/ComposeController.php and 1 other location - About 2 hrs to fix
app/Http/Controllers/ComposeController.php on lines 698..711

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

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

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

                        'attachment'          => $status->media()->orderBy('order')->get()->map(function ($media) {
                            $res = [
                                'type'      => $media->activityVerb(),
                                'mediaType' => $media->mime,
                                'url'       => $media->url(),
            Severity: Major
            Found in app/Transformer/ActivityPub/Verb/Note.php and 1 other location - About 2 hrs to fix
            app/Transformer/ActivityPub/Verb/CreateNote.php on lines 106..123

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

            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

                            'attachment'          => $status->media()->orderBy('order')->get()->map(function ($media) {
                                $res = [
                                    'type'      => $media->activityVerb(),
                                    'mediaType' => $media->mime,
                                    'url'       => $media->url(),
            Severity: Major
            Found in app/Transformer/ActivityPub/Verb/CreateNote.php and 1 other location - About 2 hrs to fix
            app/Transformer/ActivityPub/Verb/Note.php on lines 100..117

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

            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

            Inbox has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Inbox
            {
                protected $headers;
                protected $profile;
                protected $payload;
            Severity: Minor
            Found in app/Util/ActivityPub/Inbox.php - About 2 hrs to fix

              FixDuplicateProfiles has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class FixDuplicateProfiles extends Command
              {
                  /**
                   * The name and signature of the console command.
                   *
              Severity: Minor
              Found in app/Console/Commands/FixDuplicateProfiles.php - About 2 hrs to fix

                Method accountStatuses has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function accountStatuses(Request $request, $id)
                    {
                        $this->validate($request, [
                            'only_media' => 'nullable',
                            'pinned' => 'nullable',
                Severity: Major
                Found in app/Http/Controllers/InternalApiController.php - About 2 hrs to fix

                  Method accountFollowById has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function accountFollowById(Request $request, $id)
                      {
                          abort_if(! $request->user() || ! $request->user()->token(), 403);
                          abort_unless($request->user()->tokenCan('follow'), 403);
                  
                  
                  Severity: Major
                  Found in app/Http/Controllers/Api/ApiV1Controller.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language