crocodic-studio/crudbooster

View on GitHub

Showing 160 of 160 total issues

Function getFindData has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFindData()
    {
        $q = request('q');
        $id = request('id');
        $limit = request('limit') ?: 10;
Severity: Minor
Found in src/controllers/CBController.php - About 4 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 getPreview has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPreview($one, $two = null, $three = null, $four = null, $five = null)
    {

        if ($two) {
            $fullFilePath = 'uploads'.DIRECTORY_SEPARATOR.$one.DIRECTORY_SEPARATOR.$two;
Severity: Minor
Found in src/controllers/FileController.php - About 4 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

CBController has 36 functions (exceeds 20 allowed). Consider refactoring.
Open

class CBController extends Controller
{
    public $data_inputan;

    public $columns_table;
Severity: Minor
Found in src/controllers/CBController.php - About 4 hrs to fix

    Method validation has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function validation($id = null)
        {
    
            $request_all = Request::all();
            $array_input = [];
    Severity: Major
    Found in src/controllers/CBController.php - About 4 hrs to fix

      Method postEditSave has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function postEditSave($id)
          {
              $this->cbLoader();
              $row = DB::table($this->table)->where($this->primary_key, $id)->first();
      
      
      Severity: Major
      Found in src/controllers/CBController.php - About 4 hrs to fix

        Method input_assignment has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function input_assignment($id = null)
            {
        
                $hide_form = (request('hide_form')) ? unserialize(request('hide_form')) : [];
        
        
        Severity: Major
        Found in src/controllers/CBController.php - About 3 hrs to fix

          Method postAddSave has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function postAddSave()
              {
                  $this->cbLoader();
                  if (! CRUDBooster::isCreate() && $this->global_privilege == false) {
                      CRUDBooster::insertLog(cbLang('log_try_add_save', [
          Severity: Major
          Found in src/controllers/CBController.php - About 3 hrs to fix

            Function getColumnTable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

                function getColumnTable($table, $type = 'list')
                {
                    $this->cbLoader();
                    $result = [];
            
            
            Severity: Minor
            Found in src/controllers/ApiCustomController.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

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

                            if ($ro['relationship_table'] && $ro["datatable_orig"] == "") {
                                $datatable = explode(",", $ro['datatable'])[0];
            
                                $foreignKey2 = CRUDBooster::getForeignKey($datatable, $ro['relationship_table']);
                                $foreignKey = CRUDBooster::getForeignKey($this->table, $ro['relationship_table']);
            Severity: Major
            Found in src/controllers/CBController.php and 1 other location - About 3 hrs to fix
            src/controllers/CBController.php on lines 1303..1320

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

            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 ($ro['relationship_table']) {
                                $datatable = explode(",", $ro['datatable'])[0];
            
                                $foreignKey2 = CRUDBooster::getForeignKey($datatable, $ro['relationship_table']);
                                $foreignKey = CRUDBooster::getForeignKey($this->table, $ro['relationship_table']);
            Severity: Major
            Found in src/controllers/CBController.php and 1 other location - About 3 hrs to fix
            src/controllers/CBController.php on lines 1324..1341

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

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

                public function postDoImportChunk()
                {
                    $this->cbLoader();
                    $file_md5 = md5(request('file'));
            
            
            Severity: Major
            Found in src/controllers/CBController.php - About 3 hrs to fix

              Method getPreview has 84 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPreview($one, $two = null, $three = null, $four = null, $five = null)
                  {
              
                      if ($two) {
                          $fullFilePath = 'uploads'.DIRECTORY_SEPARATOR.$one.DIRECTORY_SEPARATOR.$two;
              Severity: Major
              Found in src/controllers/FileController.php - About 3 hrs to fix

                File MenusController.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php namespace crocodicstudio\crudbooster\controllers;
                
                use CRUDBooster;
                use Illuminate\Support\Facades\Cache;
                use Illuminate\Support\Facades\DB;
                Severity: Minor
                Found in src/controllers/MenusController.php - About 3 hrs to fix

                  Function sidebarMenu has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function sidebarMenu()
                      {
                          $menu_active = DB::table('cms_menus')->whereRaw("cms_menus.id IN (select id_cms_menus from cms_menus_privileges where id_cms_privileges = '".self::myPrivilegeId()."')")->where('parent_id', 0)->where('is_active', 1)->where('is_dashboard', 0)->orderby('sorting', 'asc')->select('cms_menus.*')->get();
                  
                          foreach ($menu_active as &$menu) {
                  Severity: Minor
                  Found in src/helpers/CRUDBooster.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 getFindData has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getFindData()
                      {
                          $q = request('q');
                          $id = request('id');
                          $limit = request('limit') ?: 10;
                  Severity: Major
                  Found in src/controllers/CBController.php - About 3 hrs to fix

                    Method postAddSave has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function postAddSave()
                        {
                            $this->cbLoader();
                    
                            if (! CRUDBooster::isCreate() && $this->global_privilege == false) {
                    Severity: Major
                    Found in src/controllers/ModulsController.php - About 3 hrs to fix

                      Function checkRequirements has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function checkRequirements()
                          {
                              $this->info('System Requirements Checking:');
                              $system_failed = 0;
                              $laravel = app();
                      Severity: Minor
                      Found in src/commands/CrudboosterInstallationCommand.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 checkRequirements has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function checkRequirements()
                          {
                              $this->info('System Requirements Checking:');
                              $system_failed = 0;
                              $laravel = app();
                      Severity: Minor
                      Found in src/commands/CrudboosterUpdateCommand.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

                      File ApiCustomController.php has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php namespace crocodicstudio\crudbooster\controllers;
                      
                      use CRUDbooster;
                      use Illuminate\Support\Facades\DB;
                      use Illuminate\Support\Facades\Excel;
                      Severity: Minor
                      Found in src/controllers/ApiCustomController.php - About 2 hrs to fix

                        Method checkRequirements has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function checkRequirements()
                            {
                                $this->info('System Requirements Checking:');
                                $system_failed = 0;
                                $laravel = app();
                        Severity: Major
                        Found in src/commands/CrudboosterInstallationCommand.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language