carlosafonso/laravel-crud

View on GitHub

Showing 17 of 17 total issues

CrudController has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class CrudController extends BaseController
{
    /**
     * The model instance related to
     * this controller.
Severity: Minor
Found in src/Controllers/CrudController.php - About 2 hrs to fix

    Function getViewFromUri has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getViewFromUri($request)
        {
            $uri = $request->path();
            $method = $request->method();
    
    
    Severity: Minor
    Found in src/Responses/HtmlResponseBuilder.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 update has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function update(Request $request, $id)
        {
            if ($this->readOnly) {
                return $this->response->build(['error' => 'method_not_allowed'], SymfonyResponse::HTTP_METHOD_NOT_ALLOWED);
            }
    Severity: Minor
    Found in src/Controllers/CrudController.php - About 1 hr to fix

      Method getViewFromUri has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getViewFromUri($request)
          {
              $uri = $request->path();
              $method = $request->method();
      
      
      Severity: Minor
      Found in src/Responses/HtmlResponseBuilder.php - About 1 hr to fix

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

            public function store(Request $request)
            {
                if ($this->readOnly) {
                    return $this->response->build(['error' => 'method_not_allowed'], SymfonyResponse::HTTP_METHOD_NOT_ALLOWED);
                }
        Severity: Minor
        Found in src/Controllers/CrudController.php - About 1 hr to fix

          Function update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function update(Request $request, $id)
              {
                  if ($this->readOnly) {
                      return $this->response->build(['error' => 'method_not_allowed'], SymfonyResponse::HTTP_METHOD_NOT_ALLOWED);
                  }
          Severity: Minor
          Found in src/Controllers/CrudController.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 $hookResult;
          Severity: Major
          Found in src/Controllers/CrudController.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->response->build(
                            ['error' => 'unprocessable_entity', 'validation_errors' => $validator->errors()->all()],
                            SymfonyResponse::HTTP_UNPROCESSABLE_ENTITY
                        );
            Severity: Major
            Found in src/Controllers/CrudController.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return "{$view}.update";
              Severity: Major
              Found in src/Responses/HtmlResponseBuilder.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return "{$view}.destroy";
                Severity: Major
                Found in src/Responses/HtmlResponseBuilder.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $hookResult;
                  Severity: Major
                  Found in src/Controllers/CrudController.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $hookResult;
                    Severity: Major
                    Found in src/Controllers/CrudController.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $this->response->build($entity, SymfonyResponse::HTTP_OK);
                      Severity: Major
                      Found in src/Controllers/CrudController.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $this->response->build($entity, SymfonyResponse::HTTP_CREATED);
                        Severity: Major
                        Found in src/Controllers/CrudController.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return "{$view}.edit";
                          Severity: Major
                          Found in src/Responses/HtmlResponseBuilder.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return $hookResult;
                            Severity: Major
                            Found in src/Controllers/CrudController.php - About 30 mins to fix

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

                                  public function store(Request $request)
                                  {
                                      if ($this->readOnly) {
                                          return $this->response->build(['error' => 'method_not_allowed'], SymfonyResponse::HTTP_METHOD_NOT_ALLOWED);
                                      }
                              Severity: Minor
                              Found in src/Controllers/CrudController.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

                              Severity
                              Category
                              Status
                              Source
                              Language