crocodic-studio/crudbooster

View on GitHub

Showing 160 of 160 total issues

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

    public function postEditSave($id)
    {
        $this->cbLoader();

        $row = CRUDBooster::first($this->table, $id);
Severity: Minor
Found in src/controllers/PrivilegesController.php - About 1 hr to fix

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

        public function cbInit()
        {
            $this->module_name = "Settings";
            $this->table = 'cms_settings';
            $this->primary_key = 'id';
    Severity: Minor
    Found in src/controllers/SettingsController.php - About 1 hr to fix

      Method isJSON has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function isJSON($theData)
          {
              //return either the array or JSON decoded array
              $test = json_decode($theData[0], true);
      
      
      Severity: Minor
      Found in src/controllers/ApiController.php - About 1 hr to fix

        Function getStep1 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getStep1($id = 0)
            {
                $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 urlFilterColumn has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function urlFilterColumn($key, $type, $value = '', $singleSorting = true)
            {
                $params = Request::all();
                $mainpath = trim(self::mainpath(), '/');
        
        
        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 isJSON has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function isJSON($theData)
            {
                //return either the array or JSON decoded array
                $test = json_decode($theData[0], true);
        
        
        Severity: Minor
        Found in src/controllers/ApiController.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 resizeImage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function resizeImage($fullFilePath, $resize_width = null, $resize_height = null, $qty = 100, $thumbQty = 75)
            {
                $images_ext = config('crudbooster.IMAGE_EXTENSIONS', 'jpg,png,gif,bmp');
                $images_ext = explode(',', $images_ext);
        
        
        Severity: Minor
        Found in src/helpers/CRUDBooster.php - About 1 hr to fix

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

                  if ($postdata['type'] == 'Statistic') {
                      $stat = CRUDBooster::first('cms_statistics', ['id' => $postdata['statistic_slug']]);
                      $postdata['path'] = 'statistic_builder/show/'.$stat->slug;
                  } elseif ($postdata['type'] == 'Module') {
                      $stat = CRUDBooster::first('cms_moduls', ['id' => $postdata['module_slug']]);
          Severity: Major
          Found in src/controllers/MenusController.php and 1 other location - About 1 hr to fix
          src/controllers/MenusController.php on lines 312..318

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

          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 ($postdata['type'] == 'Statistic') {
                      $stat = CRUDBooster::first('cms_statistics', ['id' => $postdata['statistic_slug']]);
                      $postdata['path'] = 'statistic_builder/show/'.$stat->slug;
                  } elseif ($postdata['type'] == 'Module') {
                      $stat = CRUDBooster::first('cms_moduls', ['id' => $postdata['module_slug']]);
          Severity: Major
          Found in src/controllers/MenusController.php and 1 other location - About 1 hr to fix
          src/controllers/MenusController.php on lines 285..291

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

          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

          Function cbRoute has a Cognitive Complexity of 12 (exceeds 5 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

          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 handle has a Cognitive Complexity of 12 (exceeds 5 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

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

              function getColumnTable($table, $type = 'list')
              {
                  $this->cbLoader();
                  $result = [];
          
          
          Severity: Minor
          Found in src/controllers/ApiCustomController.php - About 1 hr to fix

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

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

              Method uploadFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function uploadFile($name, $encrypt = false, $resize_width = null, $resize_height = null, $id = null)
                  {
                      if (Request::hasFile($name)) {
                          if (! self::myId()) {
                              $userID = 0;
              Severity: Minor
              Found in src/helpers/CRUDBooster.php - About 1 hr to fix

                Method postActionSelected has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function postActionSelected()
                    {
                        $this->cbLoader();
                        $id_selected = Request::input('checkbox');
                        $button_name = Request::input('button_name');
                Severity: Minor
                Found in src/controllers/CBController.php - About 1 hr to fix

                  Method postLogin has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function postLogin()
                      {
                  
                          $validator = Validator::make(Request::all(), [
                              'email' => 'required|email|exists:'.config('crudbooster.USER_TABLE'),
                  Severity: Minor
                  Found in src/controllers/AdminController.php - About 1 hr to fix

                    Method sendEmailQueue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function sendEmailQueue($queue)
                        {
                            \Config::set('mail.driver', self::getSetting('smtp_driver'));
                            \Config::set('mail.host', self::getSetting('smtp_host'));
                            \Config::set('mail.port', self::getSetting('smtp_port'));
                    Severity: Minor
                    Found in src/helpers/CRUDBooster.php - About 1 hr to fix

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

                          public static function authAPI()
                          {
                              $allowedUserAgent = config('crudbooster.API_USER_AGENT_ALLOWED');
                              $user_agent = Request::header('User-Agent');
                              $authorization = Request::header('Authorization');
                      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 getNameTable has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static function getNameTable($columns)
                          {
                              $name_col_candidate = config('crudbooster.NAME_FIELDS_CANDIDATE');
                              $name_col_candidate = explode(',', $name_col_candidate);
                              $name_col = '';
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language