crocodic-studio/crudbooster

View on GitHub

Showing 160 of 160 total issues

Function getUrlParameters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getUrlParameters($exception = null)
    {
        @$get = $_GET;
        $inputhtml = '';

Severity: Minor
Found in src/helpers/CRUDBooster.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 postSaveSetting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    function postSaveSetting()
    {

        if (! CRUDBooster::isSuperadmin()) {
            CRUDBooster::insertLog(cbLang("log_try_view", ['name' => 'Setting', 'module' => 'Setting']));
Severity: Minor
Found in src/controllers/SettingsController.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 getImportData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getImportData()
    {
        $this->cbLoader();
        $data['page_menu'] = Route::getCurrentRoute()->getActionName();
        $data['page_title'] = 'Import Data';
Severity: Minor
Found in src/controllers/CBController.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 postStep2 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function postStep2()
    {
        $this->cbLoader();

        $module = CRUDBooster::getCurrentModule();
Severity: Minor
Found in src/controllers/ModulsController.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 isForeignKey has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isForeignKey($fieldName)
    {
        if (substr($fieldName, 0, 3) == 'id_') {
            $table = substr($fieldName, 3);
        } elseif (substr($fieldName, -3) == '_id') {
Severity: Minor
Found in src/helpers/CRUDBooster.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 postStepFinish has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function postStepFinish()
    {
        $this->cbLoader();
        $id = Request::input('id');
        $row = DB::table('cms_moduls')->where('id', $id)->first();
Severity: Minor
Found in src/controllers/ModulsController.php - About 1 hr to fix

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

        public static function sendFCM($regID = [], $data)
        {
            if (! $data['title'] || ! $data['content']) {
                return 'title , content null !';
            }
    Severity: Minor
    Found in src/helpers/CRUDBooster.php - About 1 hr to fix

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

                  DB::table('cms_menus')->insert([
                      'created_at' => date('Y-m-d H:i:s'),
                      'name' => cbLang("text_default_add_new_module", ['module' => $this->arr['name']]),
                      'icon' => 'fa fa-plus',
                      'path' => $this->arr['controller'].'GetAdd',
      Severity: Major
      Found in src/controllers/ModulsController.php and 1 other location - About 1 hr to fix
      src/controllers/ModulsController.php on lines 706..716

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

      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

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

                  DB::table('cms_menus')->insert([
                      'created_at' => date('Y-m-d H:i:s'),
                      'name' => cbLang("text_default_list_module", ['module' => $this->arr['name']]),
                      'icon' => 'fa fa-bars',
                      'path' => $this->arr['controller'].'GetIndex',
      Severity: Major
      Found in src/controllers/ModulsController.php and 1 other location - About 1 hr to fix
      src/controllers/ModulsController.php on lines 695..705

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

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

          private static function cbRoute() {
              Route::group([
                  'middleware' => ['web', '\crocodicstudio\crudbooster\middlewares\CBBackend'],
                  'prefix' => config('crudbooster.ADMIN_PATH'),
                  'namespace' => static::$cb_namespace,
      Severity: Minor
      Found in src/helpers/CBRouter.php - About 1 hr to fix

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

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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if (! CRUDBooster::isDelete() && $this->global_privilege == false || $this->button_delete == false) {
                      CRUDBooster::insertLog(cbLang("log_try_delete", [
                          'name' => $row->{$this->title_field},
                          'module' => CRUDBooster::getCurrentModule()->name,
                      ]));
          Severity: Major
          Found in src/controllers/CBController.php and 2 other locations - About 1 hr to fix
          src/controllers/CBController.php on lines 1256..1262
          src/controllers/CBController.php on lines 1441..1447

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

          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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if (! CRUDBooster::isRead() && $this->global_privilege == false || $this->button_detail == false) {
                      CRUDBooster::insertLog(cbLang("log_try_view", [
                          'name' => $row->{$this->title_field},
                          'module' => CRUDBooster::getCurrentModule()->name,
                      ]));
          Severity: Major
          Found in src/controllers/CBController.php and 2 other locations - About 1 hr to fix
          src/controllers/CBController.php on lines 1256..1262
          src/controllers/CBController.php on lines 1410..1416

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

          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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                  if (! CRUDBooster::isRead() && $this->global_privilege == false || $this->button_edit == false) {
                      CRUDBooster::insertLog(cbLang("log_try_edit", [
                          'name' => $row->{$this->title_field},
                          'module' => CRUDBooster::getCurrentModule()->name,
                      ]));
          Severity: Major
          Found in src/controllers/CBController.php and 2 other locations - About 1 hr to fix
          src/controllers/CBController.php on lines 1410..1416
          src/controllers/CBController.php on lines 1441..1447

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

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

              public function handle($request, Closure $next)
              {
                  $admin_path = config('crudbooster.ADMIN_PATH') ?: 'admin';
          
                  if (CRUDBooster::myId() == '') {
          Severity: Minor
          Found in src/middlewares/CBBackend.php - About 1 hr to fix

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

                public static function timeAgo($datetime_to, $datetime_from = null, $full = false)
                {
                    $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s');
                    $now = new \DateTime;
                    if ($datetime_from != '') {
            Severity: Minor
            Found in src/helpers/CRUDBooster.php - About 1 hr to fix

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

                  public function cbInit()
                  {
                      $this->table = "cms_statistics";
                      $this->primary_key = "id";
                      $this->title_field = "name";
              Severity: Minor
              Found in src/controllers/StatisticBuilderController.php - About 1 hr to fix

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

                    function postSaveSetting()
                    {
                
                        if (! CRUDBooster::isSuperadmin()) {
                            CRUDBooster::insertLog(cbLang("log_try_view", ['name' => 'Setting', 'module' => 'Setting']));
                Severity: Minor
                Found in src/controllers/SettingsController.php - About 1 hr to fix

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

                      public function handle()
                      {
                  
                          $this->header();
                  
                  
                  Severity: Minor
                  Found in src/commands/CrudboosterInstallationCommand.php - About 1 hr to fix

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

                        public static function generateAPI($controller_name, $table_name, $permalink, $method_type = 'post')
                        {
                            $php = '
                            <?php namespace App\Http\Controllers;
                    
                    
                    Severity: Minor
                    Found in src/helpers/CRUDBooster.php - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language