pixelfed/pixelfed

View on GitHub
app/Http/Controllers/PortfolioController.php

Summary

Maintainability
D
3 days
Test Coverage

File PortfolioController.php has 465 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/PortfolioController.php - About 7 hrs to fix

    Method storeSettings has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function storeSettings(Request $request)
        {
            abort_if(!$request->user(), 403);
    
            $this->validate($request, [
    Severity: Major
    Found in app/Http/Controllers/PortfolioController.php - About 3 hrs to fix

      Function storeSettings has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function storeSettings(Request $request)
          {
              abort_if(!$request->user(), 403);
      
              $this->validate($request, [
      Severity: Minor
      Found in app/Http/Controllers/PortfolioController.php - About 3 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 getRssFeed has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getRssFeed(Request $request, $username)
          {
              $user = User::whereUsername($username)->first();
      
              if(!$user) {
      Severity: Minor
      Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

        Method getAccountSettings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAccountSettings(Request $request)
            {
                $this->validate($request, [
                    'id' => 'required|integer'
                ]);
        Severity: Minor
        Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

          Method getSettings has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getSettings(Request $request)
              {
                  abort_if(!$request->user(), 403);
          
                  $res = Portfolio::whereUserId($request->user()->id)->get();
          Severity: Minor
          Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

            Method getApFeed has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getApFeed(Request $request, $username)
                {
                    $user = User::whereUsername($username)->first();
            
                    if(!$user) {
            Severity: Minor
            Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

              Method store has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function store(Request $request)
                  {
                      abort_unless($request->user(), 404);
              
                      $this->validate($request, [
              Severity: Minor
              Found in app/Http/Controllers/PortfolioController.php - About 1 hr to fix

                Function getAccountSettings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getAccountSettings(Request $request)
                    {
                        $this->validate($request, [
                            'id' => 'required|integer'
                        ]);
                Severity: Minor
                Found in app/Http/Controllers/PortfolioController.php - About 45 mins 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 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function show(Request $request, $username)
                    {
                        $user = User::whereUsername($username)->first();
                
                        if(!$user) {
                Severity: Minor
                Found in app/Http/Controllers/PortfolioController.php - About 35 mins 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

                Avoid too many return statements within this method.
                Open

                        return view('portfolio.show', compact('user', 'portfolio'));
                Severity: Major
                Found in app/Http/Controllers/PortfolioController.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return view('portfolio.404');
                  Severity: Major
                  Found in app/Http/Controllers/PortfolioController.php - About 30 mins to fix

                    Function getApFeed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getApFeed(Request $request, $username)
                        {
                            $user = User::whereUsername($username)->first();
                    
                            if(!$user) {
                    Severity: Minor
                    Found in app/Http/Controllers/PortfolioController.php - About 25 mins 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

                    There are no issues that match your filters.

                    Category
                    Status