pixelfed/pixelfed

View on GitHub

Showing 1,558 of 1,561 total issues

Function mimeTypeCheck has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function mimeTypeCheck($mimes)
    {
        $allowed = explode(',', config_cache('pixelfed.media_types'));
        $count = count($mimes);
        $photos = 0;
Severity: Minor
Found in app/Http/Controllers/StatusController.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 reportsHandleStatusAction has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function reportsHandleStatusAction($report, $action)
    {
        switch ($action) {
            case 'ignore':
                Report::whereObjectId($report->object_id)
Severity: Minor
Found in app/Http/Controllers/Admin/AdminReportController.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 storeText has a Cognitive Complexity of 14 (exceeds 5 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: Minor
Found in app/Http/Controllers/ComposeController.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 mediaUpload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function mediaUpload(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/ApiV1Controller.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 store has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function store(Request $request)
    {
        $this->validate($request, [
            'item' => 'required|integer|min:1',
        ]);
Severity: Minor
Found in app/Http/Controllers/BookmarkController.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 accountStatusesById has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function accountStatusesById(Request $request, $id)
    {
        abort_if(! $request->user() || ! $request->user()->token(), 403);
        abort_unless($request->user()->tokenCan('read'), 403);

Severity: Minor
Found in app/Http/Controllers/Api/ApiV1Controller.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 showRegistrationForm has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function showRegistrationForm()
    {
        if((bool) config_cache('pixelfed.open_registration')) {
            if(config('pixelfed.bouncer.cloud_ips.ban_signups')) {
                abort_if(BouncerService::checkIp(request()->ip()), 404);
Severity: Minor
Found in app/Http/Controllers/Auth/RegisterController.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 timelineHashtag has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function timelineHashtag(Request $request, $hashtag)
    {
        abort_if(! $request->user() || ! $request->user()->token(), 403);
        abort_unless($request->user()->tokenCan('read'), 403);

Severity: Minor
Found in app/Http/Controllers/Api/ApiV1Controller.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 14 (exceeds 5 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

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

    public static function decode (string $blurhash, int $width, int $height, float $punch = 1.0, bool $linear = false): array {
        if (empty($blurhash) || strlen($blurhash) < 6) {
            throw new InvalidArgumentException("Blurhash string must be at least 6 characters");
        }

Severity: Minor
Found in app/Util/Blurhash/Blurhash.php - About 1 hr to fix

    Method handleViewActivity has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handleViewActivity()
        {
            if(!isset(
                $this->payload['actor'],
                $this->payload['object']
    Severity: Minor
    Found in app/Util/ActivityPub/Inbox.php - About 1 hr to fix

      Method accounts has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function accounts($initalQuery = false)
          {
              $mastodonMode = self::$mastodonMode;
              $user = request()->user();
              $limit = $this->query->input('limit') ?? 20;
      Severity: Minor
      Found in app/Services/SearchApiV2Service.php - About 1 hr to fix

        Method pronouns has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function pronouns()
            {
                return [
                    'co',
                    'cos',
        Severity: Minor
        Found in app/Services/PronounService.php - About 1 hr to fix

          Method mute has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function mute(Request $request)
              {
                  $this->validate($request, [
                      'type' => 'required|string|in:user',
                      'item' => 'required|integer|min:1',
          Severity: Minor
          Found in app/Http/Controllers/AccountController.php - About 1 hr to fix

            Method labsStore has 43 lines of code (exceeds 25 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

              Method run has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function run($query, $mastodonMode)
                  {
                      if ($profile = Profile::whereUsername($query)->first()) {
                          return $mastodonMode ?
                              AccountService::getMastodon($profile->id, true) :
              Severity: Minor
              Found in app/Services/WebfingerService.php - About 1 hr to fix

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

                    public function handle()
                    {
                        $username = $this->option('username');
                        $email = $this->option('email');
                        if(!$username && !$email) {
                Severity: Minor
                Found in app/Console/Commands/UserRegistrationMagicLink.php - About 1 hr to fix

                  Method scan has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function scan($text, $activitypub = false)
                      {
                          if((bool) config_cache('federation.custom_emoji.enabled') == false) {
                              return [];
                          }
                  Severity: Minor
                  Found in app/Models/CustomEmoji.php - About 1 hr to fix

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

                                        $timeline = Status::select(
                                                    'id',
                                                    'uri',
                                                    'type',
                                                    'scope',
                    Severity: Major
                    Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                    app/Http/Controllers/PublicApiController.php on lines 545..571

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

                    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

                                    $timeline = Status::select(
                                                'id',
                                                'uri',
                                                'type',
                                                'scope',
                    Severity: Major
                    Found in app/Http/Controllers/PublicApiController.php and 1 other location - About 1 hr to fix
                    app/Http/Controllers/PublicApiController.php on lines 574..599

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

                    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