madbob/GASdottoNG

View on GitHub
code/app/Http/Controllers/MovementsController.php

Summary

Maintainability
D
2 days
Test Coverage

File MovementsController.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
Severity: Minor
Found in code/app/Http/Controllers/MovementsController.php - About 5 hrs to fix

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

        public function document(Request $request, $type, $subtype = 'none')
        {
            $user = $this->checkAuth();
    
            switch ($type) {
    Severity: Major
    Found in code/app/Http/Controllers/MovementsController.php - About 3 hrs to fix

      Function document has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function document(Request $request, $type, $subtype = 'none')
          {
              $user = $this->checkAuth();
      
              switch ($type) {
      Severity: Minor
      Found in code/app/Http/Controllers/MovementsController.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 show has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function show(Request $request, $id)
          {
              $dom_id = $request->input('dom_id', rand());
      
              try {
      Severity: Minor
      Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

        Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create(Request $request)
            {
                $type = $request->input('type', null);
                if (is_null($type)) {
                    return view('movement.create');
        Severity: Minor
        Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

          Method index has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function index(Request $request)
              {
                  try {
                      $data['movements'] = $this->service->list($request->all());
                      $ret = null;
          Severity: Minor
          Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

            Function index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function index(Request $request)
                {
                    try {
                        $data['movements'] = $this->service->list($request->all());
                        $ret = null;
            Severity: Minor
            Found in code/app/Http/Controllers/MovementsController.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 exportIntegralCES has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function exportIntegralCES($gas, $objects, $filename, $body)
                {
                    $currency = Currency::where('context', 'integralces')->first();
            
                    return output_csv($filename, null, $objects, function($object) use ($gas, $currency, $body) {
            Severity: Minor
            Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

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

                  public function getHistoryDetails(Request $request)
                  {
                      $this->checkAuth();
                      $date = $request->input('date');
              
              
              Severity: Minor
              Found in code/app/Http/Controllers/MovementsController.php - About 1 hr to fix

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

                    public function getHistoryDetails(Request $request)
                    {
                        $this->checkAuth();
                        $date = $request->input('date');
                
                
                Severity: Minor
                Found in code/app/Http/Controllers/MovementsController.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 output_csv($filename, $headers, $suppliers, function($supplier) use ($currencies) {
                                        $row = [];
                                        $row[] = $supplier->id;
                                        $row[] = $supplier->printableName();
                
                
                Severity: Major
                Found in code/app/Http/Controllers/MovementsController.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return $this->exportIntegralCES($user->gas, $suppliers, $filename, $body);
                  Severity: Major
                  Found in code/app/Http/Controllers/MovementsController.php - About 30 mins to fix

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

                        public function create(Request $request)
                        {
                            $type = $request->input('type', null);
                            if (is_null($type)) {
                                return view('movement.create');
                    Severity: Minor
                    Found in code/app/Http/Controllers/MovementsController.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